示例#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
 /**
  * Create a new entity for the data store
  *
  * @param ModelContext $context A model context object
  *
  * @return ModelEntityInterface The entity
  */
 protected function _actionCreate(ModelContext $context)
 {
     //Get the data
     $data = ModelContext::unbox($context->entity);
     //Create the entity identifier
     $identifier = $this->getIdentifier()->toArray();
     $identifier['path'] = array('model', 'entity');
     if (!is_numeric(key($data))) {
         $identifier['name'] = StringInflector::singularize($identifier['name']);
     } else {
         $identifier['name'] = StringInflector::pluralize($identifier['name']);
     }
     $options = array('data' => $data, 'identity_key' => $context->getIdentityKey());
     return $this->getObject($identifier, $options);
 }