本文整理汇总了PHP中Cake\ORM\Table::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::getUser方法的具体用法?PHP Table::getUser怎么用?PHP Table::getUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\ORM\Table
的用法示例。
在下文中一共展示了Table::getUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUser
/**
* Gets an user based on it's user id.
*
* - `viewVar` it sets the entity to the view. It's set by default to `user`. To
* disable setting the view var just set it to false.
*
* @param int|string $userId UUID or integer type user id.
* @param array $options Configuration options.
* @return mixed
*/
public function getUser($userId = null, $options = [])
{
$options = Hash::merge($this->_config['getUser'], $options);
if (is_null($userId)) {
if (isset($this->request->params['pass'][0])) {
$userId = $this->request->params['pass'][0];
}
}
$entity = $this->UserTable->getUser($userId);
if ($options['viewVar'] !== false) {
$this->_controller->set($options['viewVar'], $entity);
$this->_controller->set('_serialize', [$options['viewVar']]);
}
return $entity;
}