/**
  * 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, $visible, $this->options);
     }
 }
Exemple #2
0
 /**
  * Returns the vote for class content object, recursively till AbstractClassContent.
  *
  * @param \Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token
  * @param  \BackBee\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\\ClassContent\\AbstractClassContent' !== $parent_class) {
                 $parent_class = NAMESPACE_SEPARATOR . $parent_class;
                 $result = $this->voteForClassContent($token, new $parent_class('*'), $attributes);
             } else {
                 $objectIdentity = new ObjectIdentity('all', 'BackBee\\ClassContent\\AbstractClassContent');
                 $result = parent::vote($token, $objectIdentity, $attributes);
             }
         }
     }
     return $result;
 }
 /**
  * Returns TRUE if something has to be indexed for $content.
  * 
  * @param  AbstractClassContent $content The content to index.
  * 
  * @return boolean
  */
 private static function hasIndexedElements(AbstractClassContent $content)
 {
     return is_array($content->getProperty()) && array_key_exists('indexation', $content->getProperty());
 }