Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
yaza-putu committed Jul 10, 2022
2 parents 4c20c3c + 78a34bb commit 33ba024
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Commands/MakeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function createRepository(string $className, $isDefault = true)
$repositoryPath,
__DIR__ . "/stubs/$stubName"
);
$this->line("<info>Created $className repository:</info> " . $repositoryName);
$this->line("<info>Created $className repository implement:</info> " . $repositoryName);

return $repositoryNamespace . "\\" . $className;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/MakeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function createService(string $className)
$this->getServicePath($className, $nameOfService),
$stubPath
);
$this->line("<info>Created service:</info> {$serviceName}");
$this->line("<info>Created $className service implement:</info> {$serviceName}");
}

/**
Expand Down Expand Up @@ -103,7 +103,7 @@ public function createServiceInterface(string $className)
$this->getServiceInterfacePath($className,$serviceName),
__DIR__ . "/stubs/service-interface.stub"
);
$this->line("<info>Created interface of service:</info> {$serviceName}");
$this->line("<info>Created $className service interface:</info> {$serviceName}");
}

/**
Expand Down
31 changes: 17 additions & 14 deletions src/RepositoryServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ class RepositoryServiceProvider extends ServiceProvider
*/
public function register()
{
// check ensure main folder services
$this->app->make(Filesystem::class)->ensureDirectoryExists(config("easy-repository.service_directory"));
// check ensure main folder repository
$this->app->make(Filesystem::class)->ensureDirectoryExists(config("easy-repository.repository_directory"));

$this->files = $this->app->make(Filesystem::class);
if ($this->isConfigPublished()) {
$this->bindAllRepositories();
Expand Down Expand Up @@ -125,16 +120,20 @@ public function getRepository()
*/
private function getRepositoryPath()
{
$dirs = File::directories($this->app->basePath() .
"/" . config("easy-repository.repository_directory"));
$folders = [];
if(file_exists($this->app->basePath() . "/" . config("easy-repository.repository_directory"))) {
$dirs = File::directories($this->app->basePath() .
"/" . config("easy-repository.repository_directory"));
foreach ($dirs as $dir) {
$arr = explode("/", $dir);

foreach ($dirs as $dir) {
$arr = explode("/", $dir);
$folders[] = end($arr);
}
} else {

$folders[] = end($arr);
}


return $folders;
}

Expand Down Expand Up @@ -195,13 +194,17 @@ private function getRepositoryFiles()
private function getServicePath() {
$root = $this->app->basePath() .
"/" . config("easy-repository.service_directory");
$servicePath = [];

$path = Search::file($root, ["php"]);
if(file_exists($root)) {
$path = Search::file($root, ["php"]);

$servicePath = [];
foreach ($path as $file) {
$servicePath[] = str_replace("Services/","",strstr($file->getPath(), "Services"));

foreach ($path as $file) {
$servicePath[] = str_replace("Services/","",strstr($file->getPath(), "Services"));
}
}

return array_unique($servicePath);
}

Expand Down

0 comments on commit 33ba024

Please sign in to comment.