예제 #1
0
 /**
  * Executes load<Entity>ById & get<Entity>List & create<Entity> methods
  **/
 public function __call($method, $args)
 {
     if (preg_match('/load(\\w+)ById/', $method, $match)) {
         return $this->_mapper->loadById(strtolower($match[1]), $args[0]);
     } else {
         if (preg_match('/get(\\w+)List/', $method, $match)) {
             return $this->_mapper->getList(strtolower($match[1]));
         } else {
             if (preg_match('/create(\\w+)/', $method, $match)) {
                 return $this->_mapper->createEntity(strtolower($match[1]), $args[0], @$args[1]);
             } else {
                 if (isset($this->_extension[strtolower($method)])) {
                     $extension = strtolower($method);
                     if (!is_object($this->_extension[$extension])) {
                         $extension_class = 'RM_Gpc_Extension_' . ucfirst($extension);
                         $this->_extension[$extension] = new $extension_class($this->_mapper);
                     }
                     return $this->_extension[$extension];
                 } else {
                     throw new Exception("Unknown method `{$method}'");
                 }
             }
         }
     }
 }
예제 #2
0
 public function create($data = NULL)
 {
     if (!isset($data['level'])) {
         $data['level'] = 0;
     }
     $entities = $this->_mapper->entities();
     $entity = $entities[$data['level']];
     $my_data = array();
     foreach ($data as $k => $v) {
         if (strstr($k, $entity . '_') == $k) {
             $my_data[str_replace($entity . '_', '', $k)] = $v;
         }
     }
     $my_data['type'] = $entity;
     if (!isset($this->_objects[$my_data['type']][$my_data['id']])) {
         $this->_objects[$my_data['type']][$my_data['id']] = new RM_Gpc_Tree_Entity($my_data);
     }
     if ($data['level'] < count($entities) - 1) {
         $this->_objects[$my_data['type']][$my_data['id']]->addChildren($this->create(array_merge($data, array('level' => ++$data['level']))));
     }
     return $this->_objects[$my_data['type']][$my_data['id']];
 }
예제 #3
0
 /**
  * @see RM_Gpc_Mapper::resetTimeOfModification()
  **/
 public function resetTimeOfModification()
 {
     $this->_mapper->resetTimeOfModification($this->type());
     $this->_mapper->resetTimeOfModification('tree');
 }
예제 #4
0
 /**
  * @see RM_Gpc_Mapper::resetTimeOfModification()
  **/
 public function resetTimeOfModification()
 {
     $this->_mapper->resetTimeOfModification('attribute');
 }
예제 #5
0
 /**
  * Removes Flavour2Barcode relation
  *
  * @param 		RM_Barcode_Object		obBarcode
  * @param 		string|NULL				flavour_type
  * @return		bool
  **/
 public function removeBarcode(RM_Barcode_Object $obBarcode, $flavour_type = NULL)
 {
     return $this->_mapper->removeFlavourFromBarcode($obBarcode, $this, $flavour_type);
 }
예제 #6
0
 /**
  * @see RM_Gpc_Mapper::resetTimeOfModification()
  **/
 public function resetTimeOfModification()
 {
     $this->_mapper->resetTimeOfModification('value');
 }