Skip to content

Commit

Permalink
feat: Lion-Files v7.1.0 is integrated
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleon4 committed Nov 18, 2024
1 parent c204d37 commit d8a09fb
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 46 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"lion/database": "^10.3",
"lion/dependency-injection": "^3.0",
"lion/exceptions": "^1.3",
"lion/files": "^7.0",
"lion/files": "^7.1",
"lion/helpers": "^4.0",
"lion/mailer": "^6.3",
"lion/request": "^6.9",
Expand Down
19 changes: 10 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/LionBundle/Commands/CommandHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ private function getCommands(string $pathCommands, string $namespace, string $pa
/** @var array<int, Command> $commands */
$commands = [];

foreach ($this->store->view($pathCommands) as $file) {
foreach ($this->store->getFiles($pathCommands) as $file) {
if (isSuccess($this->store->validate([$file], ['php']))) {
$class = getNamespaceFromFile($file, $namespace, $pathSplit);
$class = $this->store->getNamespaceFromFile($file, $namespace, $pathSplit);

$commands[] = $this->container->resolve($class);
}
Expand Down
4 changes: 2 additions & 2 deletions src/LionBundle/Commands/Lion/DB/DBSeedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
/** @var array<int, SeedInterface> $files */
$files = [];

foreach ($this->store->view('./database/Seed/') as $seed) {
foreach ($this->store->getFiles('./database/Seed/') as $seed) {
if (isSuccess($this->store->validate([$seed], ['php']))) {
$class = getNamespaceFromFile($seed, 'Database\\Seed\\', 'Seed/');
$class = $this->store->getNamespaceFromFile($seed, 'Database\\Seed\\', 'Seed/');

/** @var SeedInterface $seedInterface */
$seedInterface = new $class();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ private function getMigrations(): array
StoreProcedureInterface::class => [],
];

foreach ($this->store->view('./database/Migrations/') as $migration) {
foreach ($this->store->getFiles('./database/Migrations/') as $migration) {
if (isSuccess($this->store->validate([$migration], ['php']))) {
$namespace = getNamespaceFromFile($migration, 'Database\\Migrations\\', 'Migrations/');
$namespace = $this->store->getNamespaceFromFile($migration, 'Database\\Migrations\\', 'Migrations/');

$tableMigration = include_once($migration);

Expand Down
4 changes: 2 additions & 2 deletions src/LionBundle/Commands/Lion/Schedule/ListScheduleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$size = 0;

foreach ($this->store->view('app/Console/Cron/') as $file) {
foreach ($this->store->getFiles('app/Console/Cron/') as $file) {
if (isSuccess($this->store->validate([$file], ['php']))) {
$namespace = getNamespaceFromFile(
$namespace = $this->store->getNamespaceFromFile(
(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? str_replace('\\', '/', $file) : $file),
'App\\Console\\Cron\\',
$this->store->normalizePath('Cron/')
Expand Down
4 changes: 2 additions & 2 deletions src/LionBundle/Commands/Lion/Schedule/UpScheduleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
/** @var array<int, ScheduleInterface> $files */
$files = [];

foreach ($this->store->view('app/Console/Cron/') as $file) {
foreach ($this->store->getFiles('app/Console/Cron/') as $file) {
if (isSuccess($this->store->validate([$file], ['php']))) {
$namespace = getNamespaceFromFile(
$namespace = $this->store->getNamespaceFromFile(
$this->store->normalizePath($file),
'App\\Console\\Cron\\',
$this->store->normalizePath('Cron/')
Expand Down
4 changes: 2 additions & 2 deletions src/LionBundle/Commands/Lion/Sockets/ServerSocketCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ private function selectSocket(InputInterface $input, OutputInterface $output): s
{
$classList = [];

foreach ($this->store->view('./app/Sockets/') as $file) {
foreach ($this->store->getFiles('./app/Sockets/') as $file) {
if (isSuccess($this->store->validate([$file], [ClassFactory::PHP_EXTENSION]))) {
$classList[] = getNamespaceFromFile($file, 'App\\Sockets\\', 'Sockets/');
$classList[] = $this->store->getNamespaceFromFile($file, 'App\\Sockets\\', 'Sockets/');
}
}

Expand Down
24 changes: 0 additions & 24 deletions src/LionBundle/Helpers/Bundle/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,27 +355,3 @@ function env(string $key, mixed $default = null): mixed
return Env::get($key, $default);
}
}

if (!function_exists('getNamespaceFromFile')) {
/**
* Gets the namespace of a class through a defined path
*
* @param string $file [File path]
* @param string $namespace [Namespace for the file]
* @param string $split [Separator to obtain the namespace]
*
* @return string
*
* @internal
*/
function getNamespaceFromFile(string $file, string $namespace, string $split = '/'): string
{
$splitFile = explode($split, $file);

$namespace = str_replace("/", "\\", "{$namespace}{$splitFile[1]}");

$namespace = str_replace('.php', '', $namespace);

return trim($namespace);
}
}

0 comments on commit d8a09fb

Please sign in to comment.