예제 #1
0
 /**
  * 
  * Object constructor
  * @param t41_Data_Object|t41_Object_Uri|string $val
  * @param array $params
  */
 public function __construct($val = null, array $params = null)
 {
     $this->_setParameterObjects();
     if (is_array($params)) {
         $this->_setParameters($params);
     }
     /* build data object and populate it if possible */
     if ($val instanceof DataObject) {
         if ($val->getClass() != get_class($this)) {
             throw new Exception("Provided Data Object is not build on class definition");
         }
         $this->_dataObject = $val;
         /* get object rules from config */
         $this->setRules();
     } else {
         $this->_dataObject = DataObject::factory(get_class($this));
         /* get object rules from config */
         $this->setRules();
         /* get object rules from config */
         //$this->_rules = t41_Object::getRules(get_class($this), $this->_dataObject);
         if (!is_null($val)) {
             if (!$val instanceof ObjectUri) {
                 $val = new ObjectUri($val);
                 $val->setClass(get_class($this));
             }
             $this->_dataObject->setUri($val);
             $this->read();
         }
     }
 }
예제 #2
0
 protected function _getTableFromUri(t41_Object_Uri $uri)
 {
     if ($uri->getUrl()) {
         $els = explode('/', $uri->getUrl());
         if (count($els) > 1 && $els[count($els) - 2] != $this->_database) {
             return $els[count($els) - 2];
         } else {
             return $this->_getTableFromClass($uri->getClass());
         }
     } else {
         return $this->_getTableFromClass($uri->getClass());
     }
 }