supports() public method

Returns true if this provider supports given entity-class.
public supports ( string $entityClass ) : boolean
$entityClass string
return boolean
Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function getRouteByName($name)
 {
     if (strpos($name, self::ROUTE_PREFIX) !== 0) {
         throw new RouteNotFoundException();
     }
     $routeId = substr($name, strlen(self::ROUTE_PREFIX));
     if (array_key_exists($routeId, $this->symfonyRouteCache)) {
         return $this->symfonyRouteCache[$routeId];
     }
     /** @var RouteInterface $route */
     $route = $this->routeRepository->find($routeId);
     if (!$route || !$this->routeDefaultsProvider->supports($route->getEntityClass()) || !$this->routeDefaultsProvider->isPublished($route->getEntityClass(), $route->getEntityId(), $route->getLocale())) {
         throw new RouteNotFoundException();
     }
     return $this->createRoute($route, $this->requestStack->getCurrentRequest());
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function render($object, $id, $webspaceKey, $locale, $partial = false)
 {
     $portalInformations = $this->webspaceManager->findPortalInformationsByWebspaceKeyAndLocale($webspaceKey, $locale, $this->environment);
     if (count($portalInformations) === 0) {
         throw new PortalNotFoundException($object, $id, $webspaceKey, $locale);
     }
     if (!$this->routeDefaultsProvider->supports(get_class($object))) {
         throw new RouteDefaultsProviderNotFoundException($object, $id, $webspaceKey, $locale);
     }
     /** @var PortalInformation $portalInformation */
     $portalInformation = reset($portalInformations);
     $webspace = $portalInformation->getWebspace();
     $localization = $webspace->getLocalization($locale);
     $query = [];
     $request = [];
     $cookies = [];
     $currentRequest = $this->requestStack->getCurrentRequest();
     if ($currentRequest !== null) {
         $query = $currentRequest->query->all();
         $request = $currentRequest->request->all();
         $cookies = $currentRequest->cookies->all();
     }
     $attributes = new RequestAttributes(['webspace' => $webspace, 'locale' => $locale, 'localization' => $localization, 'portal' => $portalInformation->getPortal(), 'portalUrl' => $portalInformation->getUrl(), 'resourceLocatorPrefix' => $portalInformation->getPrefix(), 'getParameters' => $query, 'postParameters' => $request, 'analyticsKey' => $this->previewDefaults['analyticsKey'], 'portalInformation' => $portalInformation]);
     $defaults = $this->routeDefaultsProvider->getByEntity(get_class($object), $id, $locale, $object);
     // Controller arguments
     $defaults['object'] = $object;
     $defaults['preview'] = true;
     $defaults['partial'] = $partial;
     $defaults['_sulu'] = $attributes;
     $request = new Request($query, $request, $defaults, $cookies);
     $request->setLocale($locale);
     $this->eventDispatcher->dispatch(Events::PRE_RENDER, new PreRenderEvent($attributes));
     try {
         $response = $this->handle($request);
     } catch (\Twig_Error $e) {
         throw new TwigException($e, $object, $id, $webspace, $locale);
     } catch (\InvalidArgumentException $e) {
         throw new TemplateNotFoundException($e, $object, $id, $webspace, $locale);
     } catch (\Exception $e) {
         throw new UnexpectedException($e, $object, $id, $webspace, $locale);
     }
     return $response->getContent();
 }