本文整理汇总了PHP中thebuggenie\core\entities\User::loadFixtures方法的典型用法代码示例。如果您正苦于以下问题:PHP User::loadFixtures方法的具体用法?PHP User::loadFixtures怎么用?PHP User::loadFixtures使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thebuggenie\core\entities\User
的用法示例。
在下文中一共展示了User::loadFixtures方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadFixtures
public static function loadFixtures(\thebuggenie\core\entities\Scope $scope)
{
$scope_id = $scope->getID();
$admin_group = new \thebuggenie\core\entities\Group();
$admin_group->setName('Administrators');
$admin_group->setScope($scope);
$admin_group->save();
\thebuggenie\core\framework\Settings::saveSetting('admingroup', $admin_group->getID(), 'core', $scope_id);
$user_group = new \thebuggenie\core\entities\Group();
$user_group->setName('Regular users');
$user_group->setScope($scope);
$user_group->save();
\thebuggenie\core\framework\Settings::saveSetting('defaultgroup', $user_group->getID(), 'core', $scope_id);
$guest_group = new \thebuggenie\core\entities\Group();
$guest_group->setName('Guests');
$guest_group->setScope($scope);
$guest_group->save();
// Set up initial users, and their permissions
if ($scope->isDefault()) {
list($guestuser_id, $adminuser_id) = \thebuggenie\core\entities\User::loadFixtures($scope, $admin_group, $user_group, $guest_group);
tables\UserScopes::getTable()->addUserToScope($guestuser_id, $scope->getID(), $guest_group->getID(), true);
tables\UserScopes::getTable()->addUserToScope($adminuser_id, $scope->getID(), $admin_group->getID(), true);
} else {
$default_scope_id = \thebuggenie\core\framework\Settings::getDefaultScopeID();
$default_user_id = (int) \thebuggenie\core\framework\Settings::get(\thebuggenie\core\framework\Settings::SETTING_DEFAULT_USER_ID, 'core', $default_scope_id);
tables\UserScopes::getTable()->addUserToScope($default_user_id, $scope->getID(), $user_group->getID(), true);
tables\UserScopes::getTable()->addUserToScope(1, $scope->getID(), $admin_group->getID());
\thebuggenie\core\framework\Settings::saveSetting(\thebuggenie\core\framework\Settings::SETTING_DEFAULT_USER_ID, $default_user_id, 'core', $scope->getID());
}
tables\Permissions::getTable()->loadFixtures($scope, $admin_group->getID(), $guest_group->getID());
}