Skip to content

Commit

Permalink
add bulk update
Browse files Browse the repository at this point in the history
  • Loading branch information
ArrayIterator committed Oct 21, 2023
1 parent b8836f9 commit a8f321e
Show file tree
Hide file tree
Showing 41 changed files with 1,383 additions and 806 deletions.
4 changes: 3 additions & 1 deletion config.example.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
'environment' => [
// site debugging (set false in production)
'displayErrorDetails' => false,
// site debugging (set false in production)
'debug' => true,
// site profiling (benchmarking)
// profiling is consume high memory footprints (set false in production)
'profiling' => false,
Expand Down Expand Up @@ -60,7 +62,7 @@
// dev mode for development environment without cache (set false in production)
'devMode' => false,
// proxy entities directory
'proxyDir' => __DIR__ . '/storage/database/proxy',
'proxyDirectory' => __DIR__ . '/storage/database/proxy',
// additional doctrine config
'options' => [
],
Expand Down
21 changes: 10 additions & 11 deletions src/Bin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace ArrayAccess\TrayDigita;

use ArrayAccess\TrayDigita\Console\Application;
use ArrayAccess\TrayDigita\Container\Container;
use ArrayAccess\TrayDigita\Container\Interfaces\SystemContainerInterface;
use ArrayAccess\TrayDigita\Http\Exceptions\HttpException;
use ArrayAccess\TrayDigita\Http\ServerRequest;
use ArrayAccess\TrayDigita\Kernel\Decorator;
Expand Down Expand Up @@ -45,7 +45,6 @@ final private function __construct()
/**
* @noinspection PhpMissingReturnTypeInspection
* @noinspection PhpIssetCanBeReplacedWithCoalesceInspection
* @noinspection DuplicatedCode
* @throws Throwable
*/
final public static function run()
Expand Down Expand Up @@ -106,22 +105,22 @@ final public static function run()
chdir($root);
# TD_APP_DIRECTORY='app' php bin/console
if (!defined('TD_APP_DIRECTORY')) {
$appDir = getenv('TD_APP_DIRECTORY')?: null;
if ($appDir && is_string($appDir)) {
$appDir = realpath($appDir) ?: (
realpath($cwd . DIRECTORY_SEPARATOR . $appDir) ?: (
realpath(TD_ROOT_COMPOSER_DIR . DIRECTORY_SEPARATOR . $appDir) ?: null
$appDirectory = getenv('TD_APP_DIRECTORY')?: null;
if ($appDirectory && is_string($appDirectory)) {
$appDirectory = realpath($appDirectory) ?: (
realpath($cwd . DIRECTORY_SEPARATOR . $appDirectory) ?: (
realpath(TD_ROOT_COMPOSER_DIR . DIRECTORY_SEPARATOR . $appDirectory) ?: null
)
);
}

$appDir = isset($appDir) ? $appDir : TD_ROOT_COMPOSER_DIR . DIRECTORY_SEPARATOR . 'app';
/*if (!is_dir($appDir)) {
$appDirectory = isset($appDirectory) ? $appDirectory : TD_ROOT_COMPOSER_DIR . DIRECTORY_SEPARATOR . 'app';
/*if (!is_dir($appDirectory)) {
echo "\n\033[0;31mCould not detect application directory\033[0m\n";
echo "\n";
exit(255);
}*/
define('TD_APP_DIRECTORY', $appDir);
define('TD_APP_DIRECTORY', $appDirectory);
} elseif (!is_string(TD_APP_DIRECTORY)) {
echo "\n\033[0;31mConstant \033[0;0m`TD_APP_DIRECTORY`\033[0;31m is invalid\033[0m\n";
echo "\n";
Expand Down Expand Up @@ -158,7 +157,7 @@ final public static function run()
$kernel->boot();

/**
* @var Container $container
* @var SystemContainerInterface $container
*/
$container = $kernel->getContainer();
$manager = $kernel->getManager();
Expand Down
42 changes: 21 additions & 21 deletions src/ComposerCreateProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,36 +64,36 @@ public static function composerDoCreateProject($event)
return;
}

$installDir = getcwd();
$installDirectory = getcwd();
///*
// $package = $event->getComposer()->getPackage();
// $event->getComposer()->getInstallationManager()->getInstallPath($package);
$prefixUnix = DIRECTORY_SEPARATOR === '/'
? "#!/usr/bin/env php\n"
: '';
$vendorDir = $event->getComposer()->getConfig()->get('vendor-dir');
$vendorDirectory = $event->getComposer()->getConfig()->get('vendor-dir');
$consoleIO->write(
sprintf('<info>Install Directory</info> [%s]', $installDir),
sprintf('<info>Install Directory</info> [%s]', $installDirectory),
true,
$consoleIO::VERY_VERBOSE
);
$consoleIO->write(
sprintf('<info>Vendor Directory</info> [%s]', $vendorDir),
sprintf('<info>Vendor Directory</info> [%s]', $vendorDirectory),
true,
$consoleIO::VERY_VERBOSE
);
if (!$vendorDir) {
if (!$vendorDirectory) {
return;
}
$vendorDir = rtrim($vendorDir, '\\/');
$installDir = realpath($installDir)?:$installDir;
$installDir = rtrim($installDir, '\\/');
$vendorDir = str_replace('\\', '/', $vendorDir);
$installDir = str_replace('\\', '/', $installDir);
if (!str_starts_with($vendorDir, $installDir . '/')) {
$vendorDirectory = rtrim($vendorDirectory, '\\/');
$installDirectory = realpath($installDirectory)?:$installDirectory;
$installDirectory = rtrim($installDirectory, '\\/');
$vendorDirectory = str_replace('\\', '/', $vendorDirectory);
$installDirectory = str_replace('\\', '/', $installDirectory);
if (!str_starts_with($vendorDirectory, $installDirectory . '/')) {
return;
}
$vendor = substr($vendorDir, strlen($installDir) + 1);
$vendor = substr($vendorDirectory, strlen($installDirectory) + 1);
$vendor = addcslashes($vendor, "'");
$createFiles = [
'data/README.md' => <<<MD
Expand Down Expand Up @@ -349,9 +349,9 @@ public static function composerDoCreateProject($event)
PHP
];
$consoleIO->write('<info>Preparing to create application structures</info>');
if (!file_exists($installDir . DIRECTORY_SEPARATOR . 'config.php')) {
if (!is_dir($installDir)) {
mkdir($installDir, 0755, true);
if (!file_exists($installDirectory . DIRECTORY_SEPARATOR . 'config.php')) {
if (!is_dir($installDirectory)) {
mkdir($installDirectory, 0755, true);
}
$configFile = file_get_contents(dirname(__DIR__) .'/config.example.php');
$configFile = str_replace(
Expand All @@ -370,15 +370,15 @@ public static function composerDoCreateProject($event)
$consoleIO->write(
sprintf(
'[GENERATING CONFIG] <comment>%s</comment>',
$installDir . '/config.php'
$installDirectory . '/config.php'
),
true,
$consoleIO::VERBOSE
);
file_put_contents($installDir . '/config.php', $configFile);
file_put_contents($installDirectory . '/config.php', $configFile);
}
foreach ($createFiles as $pathName => $content) {
$path = $installDir . DIRECTORY_SEPARATOR . $pathName;
$path = $installDirectory . DIRECTORY_SEPARATOR . $pathName;
$isConsole = $pathName === 'bin/tray-digita';
if (file_exists($path)) {
if (!$isConsole || is_link($path)) {
Expand Down Expand Up @@ -418,7 +418,7 @@ public static function composerDoCreateProject($event)
chmod($path, 0744);
}
}
$langDir = $installDir . '/app/Languages';
$langDirectory = $installDirectory . '/app/Languages';
$consoleIO->write(
'<info>Copying language files</info>',
true,
Expand All @@ -436,10 +436,10 @@ public static function composerDoCreateProject($event)
continue;
}
$baseName = $directory->getBasename();
if (file_exists($langDir . DIRECTORY_SEPARATOR . $baseName)) {
if (file_exists($langDirectory . DIRECTORY_SEPARATOR . $baseName)) {
continue;
}
copy($directory->getRealPath(), $langDir . DIRECTORY_SEPARATOR . $baseName);
copy($directory->getRealPath(), $langDirectory . DIRECTORY_SEPARATOR . $baseName);
}
$consoleIO->write(
'<info>Done</info>',
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Command/ApplicationChecker/ContainerChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace ArrayAccess\TrayDigita\Console\Command\ApplicationChecker;

use ArrayAccess\TrayDigita\Console\Command\Traits\WriterHelperTrait;
use ArrayAccess\TrayDigita\Container\Container;
use ArrayAccess\TrayDigita\Container\Interfaces\SystemContainerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -36,7 +36,7 @@ public function check(InputInterface $input, OutputInterface $output) : int
true
);
if ($output->isVerbose()) {
if ($container instanceof Container) {
if ($container instanceof SystemContainerInterface) {
$output->writeln('', OutputInterface::VERBOSITY_VERY_VERBOSE);
$this->writeIndent(
$output,
Expand Down
18 changes: 9 additions & 9 deletions src/Console/Command/CommandGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CommandGenerator extends Command implements ContainerAllocatorInterface, M
ManagerAllocatorTrait,
TranslatorTrait;

private ?string $commandDir = null;
private ?string $commandDirectory = null;
private string $commandNamespace;

protected function configure() : void
Expand All @@ -60,7 +60,7 @@ protected function configure() : void
);
if ($kernel instanceof BaseKernel) {
$this->commandNamespace = $kernel->getCommandNameSpace();
$this->commandDir = $kernel->getRegisteredDirectories()[$this->commandNamespace]??null;
$this->commandDirectory = $kernel->getRegisteredDirectories()[$this->commandNamespace]??null;
} else {
$namespace = dirname(
str_replace(
Expand Down Expand Up @@ -140,7 +140,7 @@ private function isFileExists(string $className) : bool
$lowerClassName = strtolower($className);
if ($this->commandList === null) {
$this->commandList = [];
$commandDirectory = $this->commandDir;
$commandDirectory = $this->commandDirectory;
$lengthStart = strlen($commandDirectory) + 1;
foreach (Finder::create()
->in($commandDirectory)
Expand Down Expand Up @@ -241,17 +241,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$input->setInteractive(true);
$container = $this->getContainer();
if (!$this->commandDir) {
if (!$this->commandDirectory) {
$config = ContainerHelper::getNull(Config::class, $container) ?? new Config();
$path = $config->get('path');
$path = $path instanceof Config ? $path : null;
$commandDir = $path?->get('command');
if (is_string($commandDir) && is_dir($commandDir)) {
$this->commandDir = realpath($commandDir) ?? $commandDir;
$commandDirectory = $path?->get('command');
if (is_string($commandDirectory) && is_dir($commandDirectory)) {
$this->commandDirectory = realpath($commandDirectory) ?? $commandDirectory;
}
}

if (!$this->commandDir) {
if (!$this->commandDirectory) {
$output->writeln(
sprintf(
$this->translateContext(
Expand All @@ -278,7 +278,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return self::FAILURE;
}

$fileName = $this->commandDir
$fileName = $this->commandDirectory
. DIRECTORY_SEPARATOR
. str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $named['className'])
. '.php';
Expand Down
18 changes: 9 additions & 9 deletions src/Console/Command/ControllerGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ControllerGenerator extends Command implements ContainerAllocatorInterface
ManagerAllocatorTrait,
TranslatorTrait;

private ?string $controllerDir = null;
private ?string $controllerDirectory = null;

private string $controllerNameSpace;

Expand All @@ -61,7 +61,7 @@ protected function configure() : void
);
if ($kernel instanceof BaseKernel) {
$this->controllerNameSpace = $kernel->getControllerNameSpace();
$this->controllerDir = $kernel->getRegisteredDirectories()[$this->controllerNameSpace]??null;
$this->controllerDirectory = $kernel->getRegisteredDirectories()[$this->controllerNameSpace]??null;
} else {
$namespace = dirname(
str_replace(
Expand Down Expand Up @@ -131,7 +131,7 @@ private function isFileExists(string $className) : bool
$lowerClassName = strtolower($className);
if ($this->controllerList === null) {
$this->controllerList = [];
$controllerDirectory = $this->controllerDir;
$controllerDirectory = $this->controllerDirectory;
$lengthStart = strlen($controllerDirectory) + 1;
foreach (Finder::create()
->in($controllerDirectory)
Expand Down Expand Up @@ -211,17 +211,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$input->setInteractive(true);
$container = $this->getContainer();
if (!$this->controllerDir) {
if (!$this->controllerDirectory) {
$config = ContainerHelper::getNull(Config::class, $container) ?? new Config();
$path = $config->get('path');
$path = $path instanceof Config ? $path : null;
$controllerDir = $path?->get('controller');
if (is_string($controllerDir) && is_dir($controllerDir)) {
$this->controllerDir = realpath($controllerDir) ?? $controllerDir;
$controllerDirectory = $path?->get('controller');
if (is_string($controllerDirectory) && is_dir($controllerDirectory)) {
$this->controllerDirectory = realpath($controllerDirectory) ?? $controllerDirectory;
}
}

if (!$this->controllerDir) {
if (!$this->controllerDirectory) {
$output->writeln(
sprintf(
$this->translateContext(
Expand All @@ -248,7 +248,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return self::FAILURE;
}

$fileName = $this->controllerDir
$fileName = $this->controllerDirectory
. DIRECTORY_SEPARATOR
. str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $name)
. '.php';
Expand Down
16 changes: 8 additions & 8 deletions src/Console/Command/DatabaseEventGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class DatabaseEventGenerator extends Command implements ContainerAllocatorInterf
ManagerAllocatorTrait,
TranslatorTrait;

private ?string $databaseEventDir = null;
private ?string $databaseEventDirectory = null;
private string $databaseEventNamespace;

protected function configure() : void
Expand All @@ -60,7 +60,7 @@ protected function configure() : void
);
if ($kernel instanceof BaseKernel) {
$this->databaseEventNamespace = $kernel->getDatabaseEventNameSpace();
$this->databaseEventDir = $kernel->getRegisteredDirectories()[$this->databaseEventNamespace]??null;
$this->databaseEventDirectory = $kernel->getRegisteredDirectories()[$this->databaseEventNamespace]??null;
} else {
$namespace = dirname(
str_replace(
Expand Down Expand Up @@ -143,7 +143,7 @@ private function isFileExists(string $className) : bool
$lowerClassName = strtolower($className);
if ($this->databaseEventList === null) {
$this->databaseEventList = [];
$databaseEventDirectory = $this->databaseEventDir;
$databaseEventDirectory = $this->databaseEventDirectory;
$lengthStart = strlen($databaseEventDirectory) + 1;
foreach (Finder::create()
->in($databaseEventDirectory)
Expand Down Expand Up @@ -244,12 +244,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$config = ContainerHelper::use(Config::class, $container)??new Config();
$path = $config->get('path');
$path = $path instanceof Config ? $path : null;
$databaseEventDir = $path?->get('databaseEvent');
if (is_string($databaseEventDir) && is_dir($databaseEventDir)) {
$this->databaseEventDir = realpath($databaseEventDir)??$databaseEventDir;
$databaseEventDirectory = $path?->get('databaseEvent');
if (is_string($databaseEventDirectory) && is_dir($databaseEventDirectory)) {
$this->databaseEventDirectory = realpath($databaseEventDirectory)??$databaseEventDirectory;
}

if (!$this->databaseEventDir) {
if (!$this->databaseEventDirectory) {
$output->writeln(
sprintf(
$this->translateContext(
Expand All @@ -276,7 +276,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return self::FAILURE;
}

$fileName = $this->databaseEventDir
$fileName = $this->databaseEventDirectory
. DIRECTORY_SEPARATOR
. str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $named['className'])
. '.php';
Expand Down
Loading

0 comments on commit a8f321e

Please sign in to comment.