Ejemplo n.º 1
0
 /**
  * Get the entity from the page and the id given
  *
  * @param BusinessEntityPagePattern $page             The page
  * @param string                    $entityIdentifier The identifier for the business entity
  * @param string                    $attributeName    The name of the attribute used to identify an entity
  *
  * @throws \Exception
  *
  * @return The entity
  */
 public function getEntityByPageAndBusinessIdentifier(BusinessEntityPagePattern $page, $entityIdentifier, $attributeName)
 {
     $entity = null;
     $businessEntityName = $page->getBusinessEntityName();
     $businessEntity = $this->findById($businessEntityName);
     //test the result
     if ($businessEntity === null) {
         throw new \Exception('The business entity [' . $businessEntityName . '] was not found.');
     }
     $entity = $this->findEntityByBusinessEntityAndAttribute($businessEntity, $attributeName, $entityIdentifier);
     //test the result
     if ($entity === null) {
         throw new \Exception('The entity [' . $entityIdentifier . '] was not found.');
     }
     return $entity;
 }
Ejemplo n.º 2
0
 /**
  * Get the position of the identifier in the url of a business entity page pattern
  *
  * @param BusinessEntityPagePattern $bepPattern
  *
  * @return integer The position
  */
 public function getIdentifierPositionInUrl(BusinessEntityPagePattern $bepPattern)
 {
     $position = null;
     $url = $bepPattern->getUrl();
     // split on the / character
     $keywords = preg_split("/\\//", $url);
     // preg_match_all('/\{\%\s*([^\%\}]*)\s*\%\}|\{\{\s*([^\}\}]*)\s*\}\}/i', $url, $matches);
     //the business property link to the page
     $businessEntityId = $bepPattern->getBusinessEntityName();
     $businessEntity = $this->businessEntityHelper->findById($businessEntityId);
     //the business properties usable in a url
     $businessProperties = $businessEntity->getBusinessPropertiesByType('businessParameter');
     //we parse the words of the url
     foreach ($keywords as $index => $keyword) {
         foreach ($businessProperties as $businessProperty) {
             $entityProperty = $businessProperty->getEntityProperty();
             $searchWord = '{{item.' . $entityProperty . '}}';
             if ($searchWord === $keyword) {
                 //the array start at index 0 but we want the position to start at 1
                 $position = array('position' => $index + 1, 'businessProperty' => $businessProperty);
             }
         }
     }
     return $position;
 }
Ejemplo n.º 3
0
 /**
  * Create an instance of the business entity page
  * @param BusinessEntityPagePattern $businessEntityPagePattern The business entity page
  * @param entity                    $entity                    The entity
  * @param string                    $url                       The new url
  *
  * @return \Victoire\Bundle\PageBundle\Entity\Page
  */
 public function createPageInstanceFromBusinessEntityPagePattern(BusinessEntityPagePattern $businessEntityPagePattern, $entity, $url)
 {
     //create a new page
     $newPage = new Page();
     $parentPage = $businessEntityPagePattern->getParent();
     //set the page parameter by the business entity page
     $newPage->setParent($parentPage);
     $newPage->setTemplate($businessEntityPagePattern);
     $newPage->setUrl($url);
     $newPage->setTitle($businessEntityPagePattern->getTitle());
     //update the parameters of the page
     $this->updatePageParametersByEntity($newPage, $entity);
     $businessEntity = $this->businessEntityHelper->findByEntityInstance($entity);
     $entityProxy = new EntityProxy();
     $entityProxy->setEntity($entity, $businessEntity->getName());
     $newPage->setEntityProxy($entityProxy);
     return $newPage;
 }
 /**
  * Get an array of business properties by the business entity page pattern
  *
  * @param BusinessEntityPagePattern $view
  *
  * @return array of business properties
  */
 private function getBusinessProperties(BusinessEntityPagePattern $view)
 {
     $businessEntityHelper = $this->get('victoire_core.helper.business_entity_helper');
     //the name of the business entity link to the business entity page pattern
     $businessEntityName = $view->getBusinessEntityName();
     $businessEntity = $businessEntityHelper->findById($businessEntityName);
     $businessProperties = $businessEntity->getBusinessPropertiesByType('businessParameter');
     $businessProperty = array();
     foreach ($businessProperties as $bp) {
         $entityProperty = $bp->getEntityProperty();
         $businessProperty[$entityProperty] = $entityProperty;
     }
     return $businessProperty;
 }
Ejemplo n.º 5
0
 /**
  * @param BusinessEntityPagePattern $view
  * @param $etmplateName the future name of the clone
  *
  * this methods allows you to clone a BusinessEntityPagePattern
  *
  */
 protected function cloneBusinessEntityPagePattern(BusinessEntityPagePattern $view)
 {
     $businessEntityId = $view->getBusinessEntityName();
     $businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($businessEntityId);
     $businessProperties = $businessEntity->getBusinessPropertiesByType('seoable');
 }