- First commit, routes and database builder are usable
This commit is contained in:
commit
5f6ce82fd2
23 files changed
+787
No files matched your search
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Lean\Console\Lib;
|
||||
|
||||
class DatabaseMigrations
|
||||
{
|
||||
public array $folderList;
|
||||
|
||||
public array $entities;
|
||||
|
||||
public function __construct(array $folders = [])
|
||||
{
|
||||
$this->folderList = $folders;
|
||||
}
|
||||
|
||||
public function getEntities() : void
|
||||
{
|
||||
$this->entities = [];
|
||||
|
||||
foreach($this->folderList as $folder => $namespace) {
|
||||
foreach(static::files($folder) as $file) {
|
||||
$name = $file->getBasename(".".$file->getExtension());
|
||||
$entity = rtrim($namespace, "\\") . "\\{$name}";
|
||||
$this->entities[$entity] = $entity::resolveEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static function files(string $path, string $fileExtension = "") : \Generator
|
||||
{
|
||||
if ( \file_exists($path) ) {
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST, \RecursiveIteratorIterator::CATCH_GET_CHILD);
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
if ( $file->isFile() || $file->isDir() ) {
|
||||
if ($fileExtension && ( $file->getExtension() === $fileExtension )) {
|
||||
yield $file;
|
||||
}
|
||||
else {
|
||||
yield $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user