App\Source\Factory\ModelsFactory::getModel PHP Метод

getModel() публичный статический Метод

public static getModel ( $modelName, $data = [] )
    public static function getModel($modelName, $data = [])
    {
        $modelName = self::$namespaceModel . Str::ucfirst($modelName);
        if (class_exists($modelName)) {
            return !empty($data) ? new $modelName($data) : new $modelName();
        }
        return new \stdClass();
    }

Usage Example

Пример #1
0
 public function afterInitialization()
 {
     parent::afterInitialization();
     $this->container->dispatcher->addListener('publiccontroller.render.before', function ($event) {
         $page = $event->getParams()->pageData['pageData'];
         if ($page instanceof \App\Models\Sections) {
             $path = $page->path;
             $url = $event->getContainer()->router->pathFor('page.s' . $page->id);
         }
         if ($page instanceof \App\Models\Pages && $page->category_id > 0) {
             $path = ModelsFactory::getModel('sections')->find($page->category_id)['path'];
             $path .= $page->category_id;
             $url = $event->getContainer()->router->pathFor('page.sp' . $page->category_id, ['pageCode' => $page->code]);
         }
         if ($page instanceof \App\Models\Pages && $page->category_id <= 0) {
             $path = '0' . \App\Models\Sections::PATH_DELIMITER;
             //$url = $event->getContainer()->router->pathFor('page.'.$page->id);
         }
         $bc = new BreadcrumbsBuilder($path);
         if (true) {
             $bc->parsePath()->addLastItem($url, $page->name);
         }
         $event->getParams()->pageData['breadcrumbs'] = $bc;
     });
 }
All Usage Examples Of App\Source\Factory\ModelsFactory::getModel