예제 #1
0
 /**
  * Create a new entity for the data store
  *
  * @param ModelContextDatabase $context A model context object
  * @return  ModelEntityComposite The model entity
  */
 protected function _actionCreate(ModelContextDatabase $context)
 {
     //Get the data
     $data = ModelContext::unbox($context->properties);
     if (!is_numeric(key($data))) {
         $data = array($data);
     }
     //Entity options
     $options = array('data' => $data, 'identity_column' => $context->getIdentityKey());
     return $this->getTable()->createRowset($options);
 }
예제 #2
0
 /**
  * Fetch a new entity from the data store
  *
  * @param ModelContext $context A model context object
  * @return ModelEntityInterface The entity
  */
 protected function _actionFetch(ModelContext $context)
 {
     $identifier = $this->getIdentifier()->toArray();
     $identifier['path'] = array('model', 'entity');
     $identifier['name'] = StringInflector::pluralize($identifier['name']);
     $options = array('identity_key' => $context->getIdentityKey());
     return $this->getObject($identifier, $options);
 }