private function createObject($data) { $table = new ObjectArray(); foreach ($data as $key => $value) { $table->setColName($key, $value); } return $table; }
/** * Add Basket Item the the basketItems field * @see Reserve::basketItems * @param BasketItem $item * @return $this */ public function addBasketItem(BasketItem $item) { if (empty($this->basketItems)) { $this->basketItems = new ObjectArray(); } $this->basketItems->append($item); return $this; }
/** * Constructor * * @param ObjectConfig $config An optional ObjectConfig object with configuration options. */ public function __construct(ObjectConfig $config) { ObjectArray::__construct($config); $this->_identity_key = $config->identity_key; //Set the status if (isset($config->status)) { $this->_status = $config->status; } // Set the entity data if (isset($config->data)) { $this->_data = $config->data->toArray(); } else { $this->_data = array(); } //Set the status message if (!empty($config->status_message)) { $this->_status_message = $config->status_message; } }
/** * Unset an item in the array * * Required by interface ArrayAccess * * @param int $offset * @return void */ public function offsetUnset($offset) { ObjectArray::offsetUnset($offset); }
/** * Initializes the options for the object * * Called from {@link __construct()} as a first step of object instantiation. * * @param ObjectConfig $config An optional ObjectConfig object with configuration options */ protected function _initialize(ObjectConfig $config) { $config->append(array('model' => null, 'defaults' => array())); parent::_initialize($config); }
/** * Return an associative array of the data * * Skip the properties that start with an underscore as they are considered private * * @return array */ public function toArray() { $data = parent::toArray(); foreach ($this->getComputedProperties() as $property) { if ($this->{$property} instanceof ModelEntityInterface) { $data[$property] = array_values($this->{$property}->toArray()); } else { $data[$property] = $this->{$property}; } } foreach (array_keys($data) as $key) { if (substr($key, 0, 1) === '_') { unset($data[$key]); } } return $data; }
/** * Initializes the options for the object * * Called from {@link __construct()} as a first step of object instantiation. * * @param ObjectConfig $object An optional ObjectConfig object with configuration options * @return void */ protected function _initialize(ObjectConfig $config) { $config->append(array('parameters' => array())); parent::_initialize($config); }
/** * Initializes the options for the object * * Called from {@link __construct()} as a first step of object instantiation. * * @param ObjectConfig $object An optional ObjectConfig object with configuration options * @return void */ protected function _initialize(ObjectConfig $config) { $config->append(array('namespace' => '__nooku_' . $this->getIdentifier()->name, 'separator' => '.')); parent::_initialize($config); }
/** * Search the mixin method map and call the method or trigger an error * * This function implements a just in time mixin strategy. Available table behaviors are only mixed when needed. * Lazy mixing is triggered by calling DatabaseRowsetTable::is[Behaviorable](); * * @param string $method The function name * @param array $arguments The function arguments * @throws \BadMethodCallException If method could not be found * @return mixed The result of the function */ public function __call($method, $arguments) { if ($this->isConnected()) { $parts = StringInflector::explode($method); //Check if a behavior is mixed if ($parts[0] == 'is' && isset($parts[1])) { if (!$this->isMixedMethod($method)) { //Lazy mix behaviors $behavior = strtolower($parts[1]); if ($this->getTable()->hasBehavior($behavior)) { $this->mixin($this->getTable()->getBehavior($behavior)); } else { return false; } } } } return parent::__call($method, $arguments); }
/** * Remove a row field * * @param string $column The column name. * @return void */ public function offsetUnset($column) { parent::offsetUnset($column); unset($this->_modified[$column]); }