当前位置: 首页>>代码示例>>PHP>>正文


PHP Group::getConstants方法代码示例

本文整理汇总了PHP中app\models\Group::getConstants方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::getConstants方法的具体用法?PHP Group::getConstants怎么用?PHP Group::getConstants使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Group的用法示例。


在下文中一共展示了Group::getConstants方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     $handle = fopen($this->baseDir . 'users_groups_permissions.tsv', 'r');
     $headers = fgetcsv($handle, 1024, '	');
     $entityPermissions = array_fill_keys($headers, '');
     while (($data = fgetcsv($handle, 2048, '	')) != false) {
         reset($headers);
         foreach ($data as $val) {
             $entityPermissions[$headers[key($headers)]][] = $val;
             next($headers);
         }
     }
     fclose($handle);
     $groupList = Models\Group::getConstants();
     $permissionCategories = array();
     $permissionCategoryList = array();
     $permissionCategoryID = 1;
     $permissionEntities = array();
     $permissionEntityList = array();
     $permissionEntityID = 1;
     $permissionActions = array();
     $permissionActionList = array();
     $permissionActionID = 1;
     $permissionManagementActions = array();
     $permissionManagementActionList = array();
     $permissionManagementActionID = 1;
     $handle = fopen($this->baseDir . 'permission_entities_actions.tsv', 'r');
     fgetcsv($handle, 1024, '	');
     while (($data = fgetcsv($handle, 1024, '	')) != false) {
         if (!empty($data[3])) {
             if (!isset($permissionCategoryList[$data[3]])) {
                 $permissionCategoryList[$data[3]] = $permissionCategoryID++;
                 $permissionCategories[] = ['name' => $data[3]];
             }
         }
         $permissionEntities[] = ['name' => $data[0], 'permission_category_id' => $permissionCategoryList[$data[3]]];
         $permissionEntityList[$data[0]] = $permissionEntityID;
         $tmp = explode(';', $data[1]);
         foreach ($tmp as $item) {
             $permissionActions[] = array('name' => $item, 'permission_entity_id' => $permissionEntityID);
             $permissionActionList[$data[0]][$item] = $permissionActionID++;
         }
         $tmp = explode(';', $data[2]);
         foreach ($tmp as $item) {
             $permissionManagementActions[] = array('name' => $item, 'permission_entity_id' => $permissionEntityID);
             $permissionManagementActionList[$data[0]][$item] = $permissionManagementActionID++;
         }
         $permissionEntityID++;
     }
     fclose($handle);
     $permissionGroup = array();
     $permissionManagementGroup = array();
     $permissionManagementID = 1;
     $permissionManagement = array();
     $permissionID = 1;
     $permission = array();
     $permissionListForUserInGroup = array();
     $permissionManagementListForUserInGroup = array();
     reset($entityPermissions);
     $permissionGroupList = $entityPermissions[key($entityPermissions)];
     next($entityPermissions);
     while (list($entity, $val) = each($entityPermissions)) {
         if (strpos($entity, '_management') !== false) {
             foreach ($val as $groupKey => $actions) {
                 $tmp = explode(';', $actions);
                 foreach ($tmp as $item) {
                     if (!empty($item)) {
                         $permissionManagement[] = array('permission_management_action_id' => $permissionManagementActionList[str_replace('_management', '', $entity)][$item], 'permission_recipient_type_id' => Models\PermissionRecipientType::group);
                         $permissionManagementGroup[] = array('type_id' => $groupList[$permissionGroupList[$groupKey]], 'permission_management_id' => $permissionManagementID++);
                         $permissionManagementListForUserInGroup[$groupList[$permissionGroupList[$groupKey]]][] = array('permission_management_action_id' => $permissionManagementActionList[str_replace('_management', '', $entity)][$item], 'permission_recipient_type_id' => Models\PermissionRecipientType::user);
                     }
                 }
             }
         } else {
             foreach ($val as $groupKey => $actions) {
                 $tmp = explode(';', $actions);
                 foreach ($tmp as $item) {
                     if (!empty($item)) {
                         $permission[] = array('permission_action_id' => $permissionActionList[$entity][$item], 'permission_recipient_type_id' => Models\PermissionRecipientType::group);
                         $permissionGroup[] = array('type_id' => $groupList[$permissionGroupList[$groupKey]], 'permission_id' => $permissionID++);
                         $permissionListForUserInGroup[$groupList[$permissionGroupList[$groupKey]]][] = array('permission_action_id' => $permissionActionList[$entity][$item], 'permission_recipient_type_id' => Models\PermissionRecipientType::user);
                     }
                 }
             }
         }
     }
     $permissionUser = array();
     $permissionManagementUser = array();
     $alreadyGivenPermissions = $alreadyGivenManagementPermissions = [];
     $userGroups = Models\UserGroup::all();
     foreach ($userGroups as $userGroup) {
         if (isset($permissionListForUserInGroup[$userGroup->group_id])) {
             foreach ($permissionListForUserInGroup[$userGroup->group_id] as $p) {
                 if (!isset($alreadyGivenPermissions[$userGroup->user_id][$p['permission_action_id']])) {
                     $alreadyGivenPermissions[$userGroup->user_id][$p['permission_action_id']] = true;
                     $permission[] = $p;
                     $permissionUser[] = ['type_id' => $userGroup->user_id, 'permission_id' => $permissionID++];
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:linguisticteam,项目名称:laravel-boilerplate,代码行数:101,代码来源:PermissionSeeder.php


注:本文中的app\models\Group::getConstants方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。