本文整理汇总了PHP中static::hydrate方法的典型用法代码示例。如果您正苦于以下问题:PHP static::hydrate方法的具体用法?PHP static::hydrate怎么用?PHP static::hydrate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::hydrate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromArray
/**
* @param Client $client
* @param Project $project
* @param array $data
* @return Event
*/
public static function fromArray(Client $client, Project $project, array $data)
{
$event = new static($project, $client);
if (isset($data['author_id'])) {
$data['author'] = new User($data['author_id'], $client);
}
return $event->hydrate($data);
}
示例2: fromArray
/**
* @param Client $client
* @param Project $project
* @param array $data
* @return Snippet
*/
public static function fromArray(Client $client, Project $project, array $data)
{
$snippet = new static($project, $data['id'], $client);
if (isset($data['author'])) {
$data['author'] = User::fromArray($client, $data['author']);
}
return $snippet->hydrate($data);
}
示例3: fromArray
/**
* @param Client $client
* @param Noteable $type
* @param array $data
* @return mixed
*/
public static function fromArray(Client $client, Noteable $type, array $data)
{
$comment = new static($type, $client);
if (isset($data['author'])) {
$data['author'] = User::fromArray($client, $data['author']);
}
return $comment->hydrate($data);
}
示例4: fromArray
/**
* @param Client $client
* @param Project $project
* @param array $data
* @return Branch
*/
public static function fromArray(Client $client, Project $project, array $data)
{
$branch = new static($project, $data['name'], $client);
if (isset($data['commit'])) {
$data['commit'] = Commit::fromArray($client, $project, $data['commit']);
}
return $branch->hydrate($data);
}
示例5: fromArray
/**
* @param \GitlabCI\Client $oClient
* @param array $aData
* @return \GitlabCI\Model\Project
* @throws \GitlabCI\Exception\InvalidArgumentException
*/
public static function fromArray(\GitlabCI\Client $oClient, array $aData)
{
if (empty($aData['id'])) {
throw new \GitlabCI\Exception\InvalidArgumentException('Data "id" is empty');
}
$oProject = new static($aData['id']);
$oProject->setClient($oClient);
return $oProject->hydrate($aData);
}
示例6: fromArray
/**
* @param Client $client
* @param array $data
* @return Project
*/
public static function fromArray(Client $client, array $data)
{
$project = new static($data['id']);
$project->setClient($client);
if (isset($data['owner'])) {
$data['owner'] = User::fromArray($client, $data['owner']);
}
if (isset($data['namespace']) && is_array($data['namespace'])) {
$data['namespace'] = ProjectNamespace::fromArray($client, $data['namespace']);
}
return $project->hydrate($data);
}
示例7: fromArray
/**
* @param Client $client
* @param array $data
* @return Group
*/
public static function fromArray(Client $client, array $data)
{
$group = new static($data['id'], $client);
if (isset($data['projects'])) {
$projects = array();
foreach ($data['projects'] as $project) {
$projects[] = Project::fromArray($client, $project);
}
$data['projects'] = $projects;
}
return $group->hydrate($data);
}
示例8: hasCustomFields
public static function hasCustomFields($postType = null, callable $addMeta = null, callable $save = null)
{
$addMeta = $addMeta ?: function ($type, $wpPost) use($postType) {
$post = new static($wpPost->ID);
$post->hydrate();
$post->registerFields($postType);
};
$save = $save ?: function ($id, $wpPost, $update) {
$post = new static($id);
$saved = $post->save();
};
// TODO use post-specific action, e.g. add_meta_boxes_post...
add_action('add_meta_boxes', $addMeta, Plugin::ACTION_PRIORITY, $numArgs = 2);
add_action('save_post', $save, Plugin::ACTION_PRIORITY, $numArgs = 3);
}
示例9: fromArray
/**
* @param Client $client
* @param Project $project
* @param array $data
* @return Commit
*/
public static function fromArray(Client $client, Project $project, array $data)
{
$commit = new static($project, $data['id'], $client);
if (isset($data['parents'])) {
$parents = array();
foreach ($data['parents'] as $parent) {
$parents[] = static::fromArray($client, $project, $parent);
}
$data['parents'] = $parents;
}
if (isset($data['author'])) {
$data['author'] = User::fromArray($client, $data['author']);
}
if (isset($data['committer'])) {
$data['committer'] = User::fromArray($client, $data['committer']);
}
return $commit->hydrate($data);
}
示例10: fromArray
/**
* @param Client $client
* @param Project $project
* @param array $data
* @return MergeRequest
*/
public static function fromArray(Client $client, Project $project, array $data)
{
$mr = new static($project, $data['id'], $client);
if (isset($data['author'])) {
$data['author'] = User::fromArray($client, $data['author']);
}
if (isset($data['assignee'])) {
$data['assignee'] = User::fromArray($client, $data['assignee']);
}
if (isset($data['milestone'])) {
$data['milestone'] = Milestone::fromArray($client, $project, $data['milestone']);
}
if (isset($data['files'])) {
$files = array();
foreach ($data['files'] as $file) {
$files[] = File::fromArray($client, $project, $file);
}
$data['files'] = $files;
}
return $mr->hydrate($data);
}
示例11: fromArray
/**
* @param Client $client
* @param Project $project
* @param array $data
* @return Comparison
*/
public static function fromArray(Client $client, Project $project, array $data)
{
$file = new static($project, $client);
if (isset($data['commit'])) {
$data['commit'] = Commit::fromArray($client, $project, $data['commit']);
}
if (isset($data['commits'])) {
$commits = array();
foreach ($data['commits'] as $commit) {
$commits[] = Commit::fromArray($client, $project, $commit);
}
$data['commits'] = $commits;
}
if (isset($data['diffs'])) {
$diffs = array();
foreach ($data['diffs'] as $diff) {
$diffs[] = Diff::fromArray($client, $project, $diff);
}
$data['diffs'] = $diffs;
}
return $file->hydrate($data);
}
示例12: findOne
/**
* Find one model from criteria
*
* @param array $where - associative array ex:
* simple criteria array('idMarque' => 1)
* custom operator array('idMarque' => array('operator' => '<=','value' => ''))
* raw SQL array('idMarque' => array('IN (5,6,4)'))
* @param array $order - associative array ex:array('libMarque'=>'ASC')
*
* @return static
*/
public static function findOne($where = array(), $order = array())
{
// try to fetch a model from database
if ($dataModel = self::select(array('*'), $where, $order, 1)) {
// hydrate new model instance with fetched data
$model = new static();
$model->hydrate($dataModel);
return $model;
} else {
return null;
}
}
示例13: saveAsNew
/**
* @param $newKey
*
* @return static
*/
public function saveAsNew($newKey = null)
{
$new = new static();
// hydrate new mapper with existing values
$new->hydrate(call_user_func('get_object_vars', $this));
// hydrate new mapper with specified keys
$new->setId($newKey);
// unset autoTimestamps
if (static::useAutoTimestamp()) {
$new->updatedAt = null;
$new->createdAt = null;
}
$new->save();
return $new;
}
示例14: fromArray
/**
* @param Client $client
* @param array $data
* @return User
*/
public static function fromArray(Client $client, array $data)
{
$id = isset($data['id']) ? $data['id'] : 0;
$user = new static($id, $client);
return $user->hydrate($data);
}
示例15: createFromResponse
/**
* @param ConfigItemResponse $item
*
* @return static
*/
public static function createFromResponse(ConfigItemResponse $item)
{
$config = new static();
$config->hydrate($item);
return $config;
}