protected function getPermissions(UserGroupInterface $group) { $collection = new ArrayCollection(); foreach ($this->container->get('router')->getRouteCollection()->all() as $name => $route) { if ($route->hasOption('require_admin_permission')) { $permission = new UserGroupPermission(); $permission->setEnabled(true); $permission->setName($route->getOption('require_admin_permission')); $permission->setGroup($group); $collection->add($permission); } } return $collection; }
protected function createCollection(array $values = [], UserGroupInterface $userGroup) { $collection = new ArrayCollection(); foreach ($values as $permissionType => $actions) { foreach ($actions as $action => $enabled) { $name = sprintf('%s.%s', $permissionType, $action); $permission = new UserGroupPermission(); $permission->setGroup($userGroup); $permission->setName($name); $permission->setEnabled($enabled); $collection->add($permission); } } return $collection; }