protected function _setProperties($var) { $this->_data = array(); if (ObjectModel::getObjectExtends($var)) { $properties = ObjectModel::getObjectProperties(ObjectModel::getObjectExtends($var)); } else { $properties = array(); } if (is_array(ObjectModel::getObjectProperties($var))) { $properties += ObjectModel::getObjectProperties($var); } if ($properties !== false) { foreach ($properties as $propertyId => $propertyParams) { $type = isset($propertyParams['type']) ? $propertyParams['type'] : null; $this->_data[$propertyId] = Property::factory($propertyId, $type, $propertyParams); $this->_data[$propertyId]->setParent($this); } } else { throw new DataObject\Exception(array("MISSING_DEFINITION", $var)); } }
public function formatValue($key = null) { if ($key == null) { return ''; } // value is already available (foreign key with no specific constraint in it if (isset($this->_enumValues[$key])) { return $this->_enumValues[$key]; } // value no more available to select, though we need to display it ! if (is_string($key)) { $uri = new ObjectModel\ObjectUri($key); $uri->setClass($this->getCollection()->getClass()); $_do = clone $this->_collection->getDataObject(); $_do->setUri($uri); Backend::read($_do); } else { $_do = $key->getDataObject(); } return Property::parseDisplayProperty($_do, $this->getParameter('display')); }
/** * Returns the matching t41_Property_* object instance * * @param string $str value must be of form <class_id>.<property_id> * @return t41_Property_Abstract * @throws ObjectModel\Exception */ public static function getObjectProperty($str) { list($class, $property) = explode('.', $str); if (!$class || !$property) { throw new ObjectModel\Exception(array("INCORRECT_PROPERTY_DESCRIPTOR", $str)); } $props = self::getObjectProperties($class); if (isset($props[$property])) { require_once 't41/Property.php'; return ObjectModel\Property::factory($property, $props[$property]['type'], $props[$property]); } else { require_once 't41/Object/Exception.php'; throw new ObjectModel\Exception("NO_SUCH_PROPERTY"); } }