protected function canAdminContentHandler(\NyroDev\NyroCmsBundle\Model\ContentHandler $contentHandler)
 {
     $canAdmin = false;
     $nyrocmsAdmin = $this->get('nyrocms_admin');
     foreach ($contentHandler->getContents() as $content) {
         $canAdmin = $canAdmin || $nyrocmsAdmin->canAdminContent($content);
     }
     if (!$canAdmin) {
         throw $this->createAccessDeniedException();
     }
 }
Пример #2
0
 public function getHandler(ContentHandler $contentHandler)
 {
     if (!isset($this->handlers[$contentHandler->getId()])) {
         $class = $contentHandler->getClass();
         if (!class_exists($class)) {
             throw new \RuntimeException($class . ' not found when trying to create handler.');
         }
         if (strpos(get_class($contentHandler), 'Proxies') === 0) {
             $contentHandler = $this->get('nyrocms_db')->getContentHandlerRepository()->find($contentHandler->getId());
         }
         $this->handlers[$contentHandler->getId()] = new $class($contentHandler, $this->container);
     }
     return $this->handlers[$contentHandler->getId()];
 }
Пример #3
0
 public function getTotalContentSpec(Content $content = null, $state = ContentSpec::STATE_ACTIVE)
 {
     return $this->getContentSpecRespository()->countForHandler($this->contentHandler->getId(), $state, $this->hasContentSpecificContent() ? $content : null);
 }