/** * @param $routePrefix * @param $entityName * @param ListViewProviderInterface $listViewProvider * @param AbstractType $formType * @param CrudManagerInterface $crudManager * @param string $view * @param array|ActionsProvider $actions * * @throws \Exception * @return CrudController */ public function get($entityName, $routePrefix = '', ListViewProviderInterface $listViewProvider = null, AbstractType $formType = null, CrudManagerInterface $crudManager = null, $view = null, $actions = []) { $repo = $this->entityManager->getRepository($entityName); if ($repo === null) { throw new \Exception('CrudFactory: Invalid entity alias "' . $entityName . '"'); } $this->securityClassPool->addClass($repo->getClassName()); $dataProvider = new DataProvider($repo, $this->entityManager, $crudManager); $controller = new CrudController($dataProvider, $routePrefix, $listViewProvider, $formType, $view); $controller->setContainer($this->container); if ($actions instanceof ActionsProvider) { $controller->setActions($actions->getActions()); } elseif (!empty($actions)) { $controller->setActions(new ArrayCollection($actions)); } else { $controller->setActions($this->actions); } return $controller; }
protected function registerSupportedClass($class) { if ($this->securityClassPool) { $this->securityClassPool->addClass($class); } }
/** * @inheritDoc */ public function supports($attribute, $subject) : bool { $supportedClass = $this->classesPool->getClasses(); $attributes = $this->typesPool->getTypes()->getKeys(); return $subject instanceof $supportedClass && in_array($attribute, $attributes); }