Example #1
0
 public static function create(array $data, $place = null)
 {
     if ($place == null) {
         $place = new self();
     }
     if (isset($data['name'])) {
         $place->setName($data['name']);
     }
     if (isset($data['type'])) {
         $place->setType($data['type']);
     }
     if (isset($data['active'])) {
         $place->setActive($data['active']);
     }
     if (isset($data['can_buy'])) {
         $place->setCanBuy($data['can_buy']);
     }
     if (isset($data['position']) && isset($data['position']['latitude']) && isset($data['position']['longitude'])) {
         $position = new Position($data['position']['latitude'], $data['position']['longitude']);
         $place->setPosition($position);
     }
     if (isset($data['address'])) {
         $place->setAddress(Address::create($data['address']));
     }
     if (isset($data['contact'])) {
         $contact = ContactData::create($data['contact']);
         if ($contact !== null) {
             $place->setContact($contact);
         }
     }
     if (isset($data['materials'])) {
         $place->materials = $data['materials'];
     }
     $place->date = new \DateTime();
     return $place;
 }
Example #2
0
 /**
  * @param CategoryEntity $category
  * @return Category
  */
 public static function createFromCategoryEntity(CategoryEntity $category)
 {
     $struct = new self();
     $struct->setId($category->getId());
     $struct->setName($category->getName());
     $struct->setPosition($category->getPosition());
     $struct->setParentId($category->getParentId());
     $path = $category->getPath();
     if ($path) {
         $path = ltrim($path, '|');
         $path = rtrim($path, '|');
         $path = explode('|', $path);
         $struct->setPath(array_reverse($path));
     }
     return $struct;
 }
Example #3
0
 public static function create()
 {
     $banner = new self(new RM_Compositor(array()));
     $banner->setPosition(self::_getMaxPosition());
     return $banner;
 }