本文整理汇总了PHP中Entity::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::create方法的具体用法?PHP Entity::create怎么用?PHP Entity::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createObject
/**
* @param Entity $entity
* @param array $record
* @param Metadata\Relation[] $relations
* @param $readOnly
*
* @return mixed
*/
private function createObject(Entity $entity, array $record, array $relations, $readOnly)
{
$fields = $entity->getFieldNames();
$object = $entity->create(array_intersect_key($record, $fields), true);
$entity->setReadOnly($object, $readOnly);
foreach ($relations as $relation) {
$relation->set($object, $relation->getEmptyValue());
}
return $object;
}
示例2: sync
public static function sync($e)
{
$entity = Entity::load($e->entity_service, $e->entity_type, $e->entity_id);
if (empty($entity)) {
// create
echo "CREATE {$e->entity_service}, {$e->entity_type}, {$e->entity_id}\n";
Entity::create($e);
} else {
echo "UPDATE {$e->entity_service}, {$e->entity_type}, {$e->entity_id}\n";
// sync
$entity->update($e);
}
}
示例3: createAmenity
/**
* Create a new amenity.
* @param $clustername : cluster's name from the url
* @param $name : the name of the amenity to be created
*
*/
public function createAmenity(Cluster $cluster, $name)
{
$content = Request::instance()->getContent();
if (empty($content)) {
return $this->_sendErrorMessage(400, "Payload.Null", "Received payload is empty.");
}
if (Input::json() == null) {
return $this->_sendErrorMessage(400, "Payload.Invalid", "Received payload is invalid.");
}
if (!strcmp($cluster->clustername, Auth::user()->clustername) || Auth::user()->isAdmin()) {
/* This Validator verify that the schema value is a valid json-schema
definition. */
$amenity_validator = Validator::make(Input::json()->all(), array('description' => 'required', 'schema' => 'required|schema'));
if (!$amenity_validator->fails()) {
$amenity = Entity::where('name', '=', $name)->first();
if (isset($amenity)) {
$amenity->body = json_encode(Input::json()->get('schema'));
$amenity->save();
} else {
return Entity::create(array('name' => $name, 'type' => 'amenity', 'body' => json_encode(Input::json()->get('schema')), 'user_id' => $cluster->user->id));
}
} else {
return $this->_sendValidationErrorMessage($amenity_validator);
}
} else {
return $this->_sendErrorMessage(403, "WriteAccessForbiden", "You can't create amenities on behalf of another user.");
}
}
示例4: sync
public static function sync($e)
{
$entity = Entity::load($e->entity_service, $e->entity_type, $e->entity_id);
if (empty($entity)) {
// create
Entity::create($e);
} else {
// sync
$entity->update($e);
}
}
示例5: create
/**
* @param $id Order id description
*/
public function create($attributes = array())
{
return parent::create($attributes);
}