Пример #1
0
 /**
  * Get the business entities
  *
  * @return array BusinessEntity
  */
 public function getBusinessEntities()
 {
     //generate the business entities on demand
     if ($this->businessEntities === null) {
         $annotationReader = $this->annotationReader;
         $businessEntities = $annotationReader->getBusinessClasses();
         $businessEntitiesObjects = array();
         foreach ($businessEntities as $name => $class) {
             $be = new BusinessEntity();
             $be->setId($name);
             $be->setName($name);
             $be->setClass($class);
             //the business properties of the business entity
             $businessProperties = $annotationReader->getBusinessProperties($class);
             //parse the array of the annotation reader
             foreach ($businessProperties as $type => $properties) {
                 foreach ($properties as $property) {
                     $bp = new BusinessProperty();
                     $bp->setType($type);
                     $bp->setEntityProperty($property);
                     //add the business property to the business entity object
                     $be->addBusinessProperty($bp);
                     unset($bp);
                 }
             }
             $businessEntitiesObjects[] = $be;
         }
         $this->businessEntities = $businessEntitiesObjects;
     }
     return $this->businessEntities;
 }
Пример #2
0
 /**
  * Replace the code string with the value of the entity attribute
  *
  * @param string           $string
  * @param BusinessProperty $businessProperty
  * @param Object           $entity
  *
  * @throws \Exception
  *
  * @return string The updated string
  */
 public function setBusinessPropertyInstance($string, BusinessProperty $businessProperty, $entity)
 {
     //test parameters
     if ($entity === null) {
         throw new \Exception('The parameter entity can not be null');
     }
     //the attribute to set
     $entityProperty = $businessProperty->getEntityProperty();
     //the string to replace
     $stringToReplace = '{{item.' . $entityProperty . '}}';
     //the value of the attribute
     $attributeValue = $entity->getEntityAttributeValue($entityProperty);
     //we provide a default value
     if ($attributeValue === null) {
         $attributeValue = '';
     }
     //we replace the string
     $string = str_replace($stringToReplace, $attributeValue, $string);
     return $string;
 }
Пример #3
0
 /**
  * create a BusinessEntity from an annotation object.
  *
  * @param string $className
  * @param array  $businessProperties
  *
  * @return BusinessEntity
  **/
 public static function createBusinessEntity($className, array $businessProperties)
 {
     $businessEntity = new BusinessEntity();
     $classNameArray = explode('\\', $className);
     $entityName = array_pop($classNameArray);
     $businessEntity->setId(strtolower($entityName));
     $businessEntity->setName($entityName);
     $businessEntity->setClass($className);
     //parse the array of the annotation reader
     foreach ($businessProperties as $type => $properties) {
         foreach ($properties as $property) {
             $businessProperty = new BusinessProperty();
             $businessProperty->setType($type);
             $businessProperty->setEntityProperty($property);
             //add the business property to the business entity object
             $businessEntity->addBusinessProperty($businessProperty);
             unset($businessProperty);
         }
     }
     return $businessEntity;
 }