lazyrecord\schema\SchemaUtils::findSchemasByArguments PHP Method

findSchemasByArguments() public static method

Returns schema objects.
public static findSchemasByArguments ( ConfigLoader $loader, array $args, CLIFramework\Logger $logger = null ) : array
$loader LazyRecord\ConfigLoader
$args array
$logger CLIFramework\Logger
return array schema objects
    public static function findSchemasByArguments(ConfigLoader $loader, array $args, Logger $logger = null)
    {
        $classes = array_filter($args, function ($class) {
            return class_exists($class, true);
        });
        if (!empty($classes)) {
            return ClassUtils::schema_classes_to_objects(array_unique($classes));
        }
        $paths = array_filter($args, 'file_exists');
        if (empty($paths)) {
            $paths = $loader->getSchemaPaths();
        }
        if (!empty($paths)) {
            $finder = new SchemaFinder($paths);
            $finder->find();
        }
        // load class from class map
        if ($classMap = $loader->getClassMap()) {
            foreach ($classMap as $file => $class) {
                if (is_numeric($file)) {
                    continue;
                }
                require_once $file;
            }
        }
        return SchemaLoader::loadDeclaredSchemas();
    }

Usage Example

Beispiel #1
0
 public function execute()
 {
     $logger = $this->getLogger();
     $config = $this->getConfigLoader();
     $this->logger->debug('Finding schemas...');
     $actionLogger = new ActionLogger(STDERR);
     $schemas = SchemaUtils::findSchemasByArguments($this->getConfigLoader(), func_get_args(), $this->logger);
     foreach ($schemas as $schema) {
         if ($this->logger->isVerbose()) {
             $actionLog = $actionLogger->newAction(get_class($schema), get_class($schema));
             $actionLog->setActionColumnWidth(50);
         } elseif ($this->logger->isDebug()) {
             $filepath = str_replace(getcwd() . '/', '', $schema->getClassFileName());
             $actionLog = $actionLogger->newAction($filepath, get_class($schema));
             $actionLog->setActionColumnWidth(50);
         } else {
             $actionLog = $actionLogger->newAction($schema->getShortClassName(), get_class($schema));
         }
         $actionLog->setStatus('checking');
         if ($schema->requireProxyFileUpdate()) {
             $actionLog->setStatus('modified', 'yellow');
         } else {
             $actionLog->setStatus('up-to-date');
         }
         $actionLog->finalize();
     }
 }
All Usage Examples Of lazyrecord\schema\SchemaUtils::findSchemasByArguments