Exemplo n.º 1
0
 /**
  * 
  * Object constructor
  * @param t41\ObjectModel\DataObject|t41\ObjectModel\ObjectUri|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;
     } else {
         if (!is_null($val)) {
             if (!$val instanceof ObjectUri) {
                 // provide backend if uri is partial
                 $backendUri = null;
                 //substr($val,0,1) != Backend::PREFIX ? ObjectModel::getObjectBackend(get_class($this)) : null;
                 $val = new ObjectUri($val, $backendUri);
                 $val->setClass(get_class($this));
             }
             $this->_dataObject = Core::_($val, get_class($this), ObjectModel::DATA);
         } else {
             $this->_dataObject = DataObject::factory(get_class($this));
         }
     }
     /* get object rules from config */
     $this->setRules();
 }
Exemplo n.º 2
0
 /**
  * Return the number of distinct objects matching the given property
  * @param string $string
  * @param unknown_type $backend
  * @throws Backend\Exception
  * @return array
  */
 public function returnsDistinct($string, $backend = null)
 {
     $prop = $this->_do->getProperty($string);
     if (!$prop instanceof Property\AbstractProperty) {
         throw new Backend\Exception(array("CONDITION_UNKNOWN_PROPERTY", $string));
     }
     if (is_null($backend)) {
         $backend = ObjectModel::getObjectBackend($this->_do->getClass());
     }
     return (array) Backend::returnsDistinct($this, $prop, $backend);
 }