Esempio n. 1
0
 /**
  *
  */
 public function find()
 {
     $content = [];
     $duplicates = [];
     $repositories = $this->inheritanceFinder->findExtends('\\Prettus\\Repository\\Eloquent\\BaseRepository');
     $models = $this->modelFinder->find();
     foreach ($repositories as $repository) {
         $fullQualifiedNamespace = $repository->getFullQualifiedNamespace();
         if ($fullQualifiedNamespace !== 'Synga\\ModelManager\\Repository\\EmptyRepository') {
             try {
                 if ($repository->getClassType() === PhpClass::TYPE_CLASS || $repository->getClassType() === PhpClass::TYPE_FINAL_CLASS) {
                     $repositoryObject = $this->resolver->resolve($repository->getFullQualifiedNamespace());
                     $modelName = $this->getClassName($repositoryObject->model());
                     if (in_array($modelName, $models['content'])) {
                         if (isset($content[$modelName])) {
                             $this->manageDuplicates($duplicates, $modelName, $fullQualifiedNamespace, $content[$content[$modelName]]);
                         } else {
                             $content[array_search($modelName, $models['content'])] = $repository->getFullQualifiedNamespace();
                         }
                     }
                 }
             } catch (\Exception $e) {
                 //                    var_dump($e->getMessage());
             }
         }
     }
     $combinedContent = $content;
     foreach ($models['combined'] as $modelName => $modelCheck) {
         if (!isset($combinedContent[$modelCheck]) && !isset($combinedContent[$modelName])) {
             $combinedContent[$modelName] = '\\Synga\\ModelManager\\Repository\\EmptyRepository';
         }
     }
     return ['content' => $content, 'duplicates' => $duplicates, 'combined' => $combinedContent];
 }
Esempio n. 2
0
 public function execute(BuilderFactory $factory)
 {
     $models = $this->modelFinder->find();
     $repositories = $this->repositoryFinder->find();
     $factory->addClassMethod()->setClass('Synga\\ModelManager\\ModelManagerInterface')->setMethod('getModel')->setAllContent($models['combined']);
     $factory->addClassMethod()->setClass('Synga\\ModelManager\\ModelManagerInterface')->setMethod('getRepository')->setAllContent($repositories['combined']);
     \Artisan::call('model-manager:cache');
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle(Model $modelFinder, Repository $repositoryFinder)
 {
     $models = $modelFinder->find();
     $repositories = $repositoryFinder->find();
     $models = ['models' => $models['combined'], 'repositories' => $repositories['combined']];
     $this->createDirectory();
     file_put_contents(storage_path('model-manager') . '/models.cache', serialize($models));
 }