本文整理汇总了PHP中RedBeanModel::getSubset方法的典型用法代码示例。如果您正苦于以下问题:PHP RedBeanModel::getSubset方法的具体用法?PHP RedBeanModel::getSubset怎么用?PHP RedBeanModel::getSubset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanModel
的用法示例。
在下文中一共展示了RedBeanModel::getSubset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rebuildViaSlowWay
protected static function rebuildViaSlowWay($modelClassName)
{
// The slow way will remain here as documentation
// for what the optimized way is doing.
$mungeTableName = self::getMungeTableName($modelClassName);
self::recreateTable($mungeTableName);
//Specifically call RedBeanModel to avoid the use of the security in OwnedSecurableItem since for
//rebuild it needs to look at all models regardless of permissions of the current user.
$modelCount = RedBeanModel::getCount(null, null, $modelClassName);
$subset = intval($modelCount / 20);
if ($subset < 100) {
$subset = 100;
} elseif ($subset > 1000) {
$subset = 1000;
}
$users = User::getAll();
$groups = Group::getAll();
$roles = Role::getAll();
for ($i = 0; $i < $modelCount; $i += $subset) {
//Specifically call RedBeanModel to avoid the use of the security in OwnedSecurableItem since for
//rebuild it needs to look at all models regardless of permissions of the current user.
$models = RedBeanModel::getSubset(null, $i, $subset, null, null, $modelClassName);
foreach ($models as $model) {
assert('$model instanceof SecurableItem');
$securableItemId = $model->getClassId('SecurableItem');
foreach ($users as $user) {
list($allowPermissions, $denyPermissions) = $model->getExplicitActualPermissions($user);
$effectiveExplicitPermissions = $allowPermissions & ~$denyPermissions;
if (($effectiveExplicitPermissions & Permission::READ) == Permission::READ) {
self::incrementCount($mungeTableName, $securableItemId, $user);
}
}
foreach ($groups as $group) {
list($allowPermissions, $denyPermissions) = $model->getExplicitActualPermissions($group);
$effectiveExplicitPermissions = $allowPermissions & ~$denyPermissions;
if (($effectiveExplicitPermissions & Permission::READ) == Permission::READ) {
self::incrementCount($mungeTableName, $securableItemId, $group);
foreach ($group->users as $user) {
if ($user->role->id > 0) {
self::incrementParentRolesCounts($mungeTableName, $securableItemId, $user->role);
}
}
foreach ($group->groups as $subGroup) {
self::processNestedGroupWhereParentHasReadPermissionOnSecurableItem($mungeTableName, $securableItemId, $subGroup);
}
}
}
foreach ($roles as $role) {
$count = self::getRoleMungeCount($model, $role);
assert('$count >= 0');
if ($count > 0) {
self::setCount($mungeTableName, $securableItemId, $role, $count);
}
}
}
}
}