Ejemplo n.º 1
0
 /**
  * Build and/or hydrate Category object with provided classcontent.
  *
  * @param AbstractClassContent $content
  */
 private function buildCategoryFromClassContent(AbstractClassContent $content)
 {
     foreach ((array) $content->getProperty('category') as $category) {
         $visible = true;
         if ('!' === $category[0]) {
             $visible = false;
             $category = substr($category, 1);
         }
         $id = $this->buildCategoryId($category);
         if (false === array_key_exists($id, $this->categories)) {
             $this->categories[$id] = new Category($category, $this->options);
             ksort($this->categories);
         }
         $this->categories[$id]->addBlock($content->getProperty('name'), $content->getProperty('description'), $content->getContentType(), $visible);
     }
 }
Ejemplo n.º 2
0
 /**
  * Returns the vote for class content object, recursively till AbstractClassContent.
  *
  * @param \Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token
  * @param  \BackBee\CoreDomain\ClassContent\AbstractClassContent $content
  * @param  array                                                                $attributes
  * @return integer                                                              either ACCESS_GRANTED, ACCESS_ABSTAIN, or ACCESS_DENIED
  */
 private function voteForClassContent(TokenInterface $token, AbstractClassContent $content, array $attributes)
 {
     if (null === $content->getProperty('category')) {
         return self::ACCESS_GRANTED;
     }
     if (self::ACCESS_DENIED === ($result = $this->voteForObject($token, $content, $attributes))) {
         if (false !== ($parent_class = get_parent_class($content))) {
             if ('BackBee\\CoreDomain\\ClassContent\\AbstractClassContent' !== $parent_class) {
                 $parent_class = NAMESPACE_SEPARATOR . $parent_class;
                 $result = $this->voteForClassContent($token, new $parent_class('*'), $attributes);
             } else {
                 $objectIdentity = new ObjectIdentity('all', 'BackBee\\CoreDomain\\ClassContent\\AbstractClassContent');
                 $result = parent::vote($token, $objectIdentity, $attributes);
             }
         }
     }
     return $result;
 }