Skip to content

Commit

Permalink
refactor: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Alavi committed Dec 31, 2024
1 parent ccd1ccc commit 08bdcb1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

namespace Apiato\Core\Loaders;

use Apiato\Core\Foundation\Facades\Apiato;
use Apiato\Core\Utilities\PathHelper;
use Illuminate\Support\Facades\File;

trait CommandsLoaderTrait
trait CommandLoaderTrait
{
public function loadCommandsFromContainers($containerPath): void
public function loadContainerCommands($containerPath): void
{
$containerCommandsDirectory = $containerPath . '/UI/CLI/Commands';
$this->loadTheConsoles($containerCommandsDirectory);
$this->loadCommands($containerCommandsDirectory);
}

private function loadTheConsoles($directory): void
private function loadCommands($directory): void
{
if (File::isDirectory($directory)) {
$files = File::allFiles($directory);

foreach ($files as $consoleFile) {
// Do not load route files
if (!$this->isRouteFile($consoleFile)) {
$consoleClass = Apiato::getClassFullNameFromFile($consoleFile->getPathname());
$consoleClass = PathHelper::getFQCNFromFile($consoleFile->getPathname());
// When user from the Main Service Provider, which extends Laravel
// service provider you get access to `$this->commands`
$this->commands([$consoleClass]);
Expand All @@ -35,15 +35,15 @@ private function isRouteFile($consoleFile): bool
return 'closures.php' === $consoleFile->getFilename();
}

public function loadCommandsFromShip(): void
public function loadShipCommands(): void
{
$shipCommandsDirectory = base_path('app/Ship/Commands');
$this->loadTheConsoles($shipCommandsDirectory);
$this->loadCommands($shipCommandsDirectory);
}

public function loadCommandsFromCore(): void
public function loadCoreCommands(): void
{
$coreCommandsDirectory = __DIR__ . '/../Commands';
$this->loadTheConsoles($coreCommandsDirectory);
$this->loadCommands($coreCommandsDirectory);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Support\Facades\File;

trait HelpersLoaderTrait
trait HelperLoaderTrait
{
public function loadHelpersFromContainers($containerPath): void
public function loadContainerHelpers($containerPath): void
{
$containerHelpersDirectory = $containerPath . '/Helpers';
$this->loadHelpers($containerHelpersDirectory);
Expand All @@ -27,7 +27,7 @@ private function loadHelpers($helpersFolder): void
}
}

public function loadHelpersFromShip(): void
public function loadShipHelpers(): void
{
$shipHelpersDirectory = base_path('app/Ship/Helpers');
$this->loadHelpers($shipHelpersDirectory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;

trait LocalizationLoaderTrait
trait LanguageLoaderTrait
{
public function loadLocalsFromContainers($containerPath): void
public function loadContainerLanguages($containerPath): void
{
$containerLocaleDirectory = $containerPath . '/Languages';
$containerName = basename($containerPath);
Expand All @@ -30,7 +30,7 @@ private function buildLocaleNamespace(string|null $sectionName, string $containe
return $sectionName ? (Str::camel($sectionName) . '@' . Str::camel($containerName)) : Str::camel($containerName);
}

public function loadLocalsFromShip(): void
public function loadShipLanguages(): void
{
$shipLocaleDirectory = base_path('app/Ship/Languages');
$this->loadLocals($shipLocaleDirectory, 'ship');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use Illuminate\Support\Facades\File;

trait MigrationsLoaderTrait
trait MigrationLoaderTrait
{
public function loadMigrationsFromContainers($containerPath): void
public function loadContainerMigrations($containerPath): void
{
$containerMigrationDirectory = $containerPath . '/Data/Migrations';
$this->loadMigrations($containerMigrationDirectory);
Expand All @@ -19,7 +19,7 @@ private function loadMigrations($directory): void
}
}

public function loadMigrationsFromShip(): void
public function loadShipMigrations(): void
{
$shipMigrationDirectory = base_path('app/Ship/Migrations');
$this->loadMigrations($shipMigrationDirectory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;

trait ViewsLoaderTrait
trait ViewLoaderTrait
{
public function loadViewsFromContainers($containerPath): void
public function loadContainerViews($containerPath): void
{
$containerViewDirectory = $containerPath . '/UI/WEB/Views/';
$containerMailTemplatesDirectory = $containerPath . '/Mails/Templates/';
Expand All @@ -29,10 +29,14 @@ private function loadViews($directory, $containerName, $sectionName = null): voi

private function buildViewNamespace(string|null $sectionName, string $containerName): string
{
return $sectionName ? (Str::camel($sectionName) . '@' . Str::camel($containerName)) : Str::camel($containerName);
if ($sectionName) {
return Str::camel($sectionName) . '@' . Str::camel($containerName);
}

return Str::camel($containerName);
}

public function loadViewsFromShip(): void
public function loadShipViews(): void
{
$shipMailTemplatesDirectory = base_path('app/Ship/Mails/Templates/');
$this->loadViews($shipMailTemplatesDirectory, 'ship');
Expand Down

0 comments on commit 08bdcb1

Please sign in to comment.