本文整理汇总了PHP中Pimcore\Model\User::create方法的典型用法代码示例。如果您正苦于以下问题:PHP User::create方法的具体用法?PHP User::create怎么用?PHP User::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Model\User
的用法示例。
在下文中一共展示了User::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createOrUpdateUser
/**
* @param array $config
*/
public function createOrUpdateUser($config = array())
{
$defaultConfig = array("username" => "admin", "password" => md5(microtime()));
$settings = array_replace_recursive($defaultConfig, $config);
if ($user = Model\User::getByName($settings["username"])) {
$user->delete();
}
$user = Model\User::create(array("parentId" => 0, "username" => $settings["username"], "password" => \Pimcore\Tool\Authentication::getPasswordHash($settings["username"], $settings["password"]), "active" => true));
$user->setAdmin(true);
$user->save();
}
示例2: installUser
private function installUser(\Pimcore\Model\User\Role $userRole)
{
$userM = new \Pimcore\Model\User();
$user = $userM->getByName('kunde');
if ($user !== FALSE) {
return $user;
}
$user = \Pimcore\Model\User::create(array('parentId' => 0, 'name' => 'kunde', 'password' => \Pimcore\Tool\Authentication::getPasswordHash('kunde', 'kunde'), 'active' => 1, 'language' => 'de', 'admin' => FALSE, 'roles' => array(0 => $userRole->getId())));
$user->save();
return $user;
}
示例3: enableTestMode
/**
* Enables the test mode. X-pimcore-unit-test-request=true header will be sent.
*/
public function enableTestMode()
{
$this->client->setHeaders("X-pimcore-unit-test-request", "true");
if (!$this->getApiKey()) {
$username = "rest";
$password = $username;
$user = User::getByName("{$username}");
if (!$user) {
$apikey = md5(time()) . md5($username);
$user = User::create(array("parentId" => 0, "username" => "rest", "password" => \Pimcore\Tool\Authentication::getPasswordHash($username, $username), "active" => true, "apiKey" => $apikey, "admin" => true));
}
$apikey = $user->getApiKey();
$this->setApiKey($apikey);
}
$this->setTestMode(true);
}