Exemplo n.º 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;
 }
Exemplo n.º 2
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;
 }