本文整理匯總了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());
}