Stores ACL in registry

@return void
323926
public function store() {
        $options = $this->getOptions();
        $key = self::DEFAULT_REGISTRY_KEY;

        if (isset($options['storage']['registry']['key'])
            && !empty($options['storage']['registry']['key'])
        ) {
            $key = $options['storage']['registry']['key'];
        }

        Zend_Registry::set($key, $this->_acl);
    }
511764
public function storeResource()
    {
        $this->validate($this->request, [
            'resource' => 'required|alpha_num',
        ]);

        $permissions = Permission::createResource($this->request->resource);
        foreach ($permissions as $permission) {
            $permission->syncRoles($this->request->get('roles', []));
        }

        return redirect()->route('administrator.permissions.index');
    }
347492
protected function registerFacadesAliases()
    {
        $loader = AliasLoader::getInstance();
        $loader->alias('AuzoToolsPermissionRegistrar', AuzoToolsPermissionRegistrarFacade::class);
        $loader->alias('GenerateAbilities', GenerateAbilitiesFacade::class);
    }
1223042
public static function register(array $permissions): void
    {
        $permissions = self::format($permissions);

        self::$permissions = array_merge(self::$permissions, $permissions);
    }
195099
protected function controlAccessCredentials()
    {
        if (empty($this->current_user['hash']) || empty($this->current_user['status'])) {
            $this->session->delete();
            $this->url->redirect('login');
        }

        if (!gplcart_string_equals($this->current_user['hash'], $this->user->getSession('hash'))) {
            $this->session->delete();
            $this->url->redirect('login');
        }

        if ($this->current_user['role_id'] != $this->user->getRoleId()) {
            $this->session->delete();
            $this->url->redirect('login');
        }
    }
297304
public static function reload()
    {
        global $PPHP;
        $db = $PPHP['db'];
        $_SESSION['ACL_INFO'] = null;
        if (!array_key_exists('id', $_SESSION['user'])) {
            return;
        };
        $userId = $_SESSION['user']['id'];

        $flat = $db->selectArray(
            "
            SELECT action, objectType, objectId
            FROM acl_users
            WHERE userId=?
            ",
            array($userId)
        );
        self::_load($flat);

        $flat = $db->selectArray(
            "
            SELECT action, objectType, objectId
            FROM users_roles
            INNER JOIN acl_roles ON acl_roles.role=users_roles.role
            WHERE users_roles.userId=?
            ",
            array($userId)
        );
        self::_load($flat);

        $_SESSION['ACL_ROLES'] = self::getRoles($userId);
    }
1181600
protected function registerOpisSecurityKey()
    {
        if (Str::startsWith($key = $this->app['config']->get('app.key'), 'base64:')) {
            $key = base64_decode(substr($key, 7));
        }

        SerializableClosure::setSecretKey($key);
    }
1314672
public function store()
    {
        $this->validate($this->request, [
            'name' => 'required',
            'slug' => 'required|unique:roles,slug',
        ]);

        $role = Role::create($this->request->all());
        $role->syncPermissions($this->request->get('permissions', []));
        flash()->success('Role ' . $role->name . ' successfully created!');

        return redirect()->route('administrator.roles.index');
    }
218575
protected function adminAcl()
    {
        if (!isset($this->aclManager)) {
            throw new RuntimeException(sprintf(
                'ACL Manager is not defined for "%s"',
                get_class($this)
            ));
        }

        return $this->aclManager;
    }
1030621
protected function initiate()
    {
        $name = $this->name;
        $data = ['acl' => [], 'actions' => [], 'roles' => []];
        $data = \array_merge($data, $this->memory->get("acl_{$name}", []));

        // Loop through all the roles and actions in memory and add it to
        // this ACL instance.
        $this->roles->attach($data['roles']);
        $this->actions->attach($data['actions']);

        // Loop through all the ACL in memory and add it to this ACL
        // instance.
        foreach ($data['acl'] as $id => $allow) {
            list($role, $action) = \explode(':', $id);
            $this->assign($role, $action, $allow);
        }

        return $this->sync();
    }
59718
public function processAcls(array &$configuration)
    {
        if (!isset($configuration['acls'])) {
            return;
        }
        $newRolesConfiguration = isset($configuration['roles']) ? $configuration['roles'] : array();
        foreach ($configuration['acls'] as $roleIdentifier => $aclConfiguration) {
            $roleIdentifier = $this->expandRoleIdentifier($roleIdentifier);
            if (!isset($newRolesConfiguration[$roleIdentifier])) {
                $newRolesConfiguration[$roleIdentifier] = array();
            }
            if (!isset($newRolesConfiguration[$roleIdentifier]['privileges'])) {
                $newRolesConfiguration[$roleIdentifier]['privileges'] = array();
            }
            foreach ($aclConfiguration as $resourceType => $permissions) {
                if ($resourceType !== 'methods' && $resourceType !== 'entities') {
                    $this->showWarning('Resource type "' . $resourceType . '" is not supported...');
                    continue;
                }
                foreach ($permissions as $resourceName => $permission) {
                    $newRolesConfiguration[$roleIdentifier]['privileges'][] = array('privilegeTarget' => $resourceName, 'permission' => $permission);
                }
            }
        }
        unset($configuration['acls']);
        $configuration['roles'] = $newRolesConfiguration;
    }
1250877
public function setupAcl()
    {
        $this->insertRoles($this->findRoles())
            ->insertResources($this->findResources())
            ->insertPrivileges($this->findPrivileges());

        $this->loaded = true;

        return $this;
    }
1009582
public function loadRegistry()
    {
        if (empty($this->registry)) {
            $cacheItemPool = cache()->getItemPool('default');

            if (cache()->hasItemPool('registry')) {
                $cacheItemPool = cache()->getItemPool('registry');
            }

            if ($cacheItemPool instanceof CacheItemPoolInterface) {
                if ($cacheItemPool->hasItem('o2languages')) {
                    $this->registry = $cacheItemPool->getItem('o2languages')->get();
                } else {
                    $this->registry = $this->fetchRegistry();
                    $cacheItemPool->save(new Item('o2languages', $this->registry, false));
                }
            } else {
                $this->registry = $this->fetchRegistry();
            }
        }
    }
1369903
public function hasAcl()
    {
        if ($this->acl instanceof Acl\Acl
            || static::$defaultAcl instanceof Acl\Acl
        ) {
            return true;
        }

        return false;
    }
104556
public function register()
    {
        if (! $this->isRegistered) {
            spl_autoload_register([$this, 'load'], true, true);
            $this->isRegistered = true;
        }

        return $this;
    }
225195
private function unserializeAcl($serialized)
    {
        $acl      = unserialize($serialized);
        $parentId = $acl->getParentAcl();

        if (null !== $parentId) {
            $parentAcl = $this->getFromCacheById($parentId);

            if (null === $parentAcl) {
                return null;
            }

            $acl->setParentAcl($parentAcl);
        }

        $reflectionProperty = new \ReflectionProperty($acl, 'permissionGrantingStrategy');

        $reflectionProperty->setAccessible(true);
        $reflectionProperty->setValue($acl, $this->permissionGrantingStrategy);
        $reflectionProperty->setAccessible(false);

        $aceAclProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'acl');

        $aceAclProperty->setAccessible(true);

        foreach ($acl->getObjectAces() as $ace) {
            $aceAclProperty->setValue($ace, $acl);
        }

        foreach ($acl->getClassAces() as $ace) {
            $aceAclProperty->setValue($ace, $acl);
        }

        $aceClassFieldProperty = new \ReflectionProperty($acl, 'classFieldAces');

        $aceClassFieldProperty->setAccessible(true);

        foreach ($aceClassFieldProperty->getValue($acl) as $aces) {
            foreach ($aces as $ace) {
                $aceAclProperty->setValue($ace, $acl);
            }
        }

        $aceClassFieldProperty->setAccessible(false);

        $aceObjectFieldProperty = new \ReflectionProperty($acl, 'objectFieldAces');

        $aceObjectFieldProperty->setAccessible(true);

        foreach ($aceObjectFieldProperty->getValue($acl) as $aces) {
            foreach ($aces as $ace) {
                $aceAclProperty->setValue($ace, $acl);
            }
        }

        $aceObjectFieldProperty->setAccessible(false);

        $aceAclProperty->setAccessible(false);

        return $acl;
    }
1226541
protected function registerPermissions()
    {
        $permissionGroup = PermissionFacade::add('category')
            ->label('Category Permissions');

        $permissionGroup->addPermission('admin-category-list')
            ->label('Category List')
            ->routes('admin.category.index');

        $permissionGroup->addPermission('admin-category-create')
            ->label('Create Category')
            ->routes('admin.category.create,admin.category.store');

        $permissionGroup->addPermission('admin-category-update')
            ->label('Update Category')
            ->routes('admin.category.edit,admin.category.update');

        $permissionGroup->addPermission('admin-category-destroy')
            ->label('Destroy Category')
            ->routes('admin.category.destroy');

        $permissionGroup = PermissionFacade::add('product')
            ->label('Product Permissions');

        $permissionGroup->addPermission('admin-product-list')
            ->label('Product List')
            ->routes('admin.product.index');
        $permissionGroup->addPermission('admin-product-create')
            ->label('Create Product')
            ->routes('admin.product.create,admin.product.store');
        $permissionGroup->addPermission('admin-product-update')
            ->label('Update Product')
            ->routes('admin.product.edit,admin.product.update');
        $permissionGroup->addPermission('admin-product-destroy')
            ->label('Destroy Product')
            ->routes('admin.product.destroy');

        $permissionGroup = PermissionFacade::add('attribute')
            ->label('Attribute Permissions');

        $permissionGroup->addPermission('admin-attribute-list')
            ->label('Attribute List')
            ->routes('admin.attribute.index');
        $permissionGroup->addPermission('admin-attribute-create')
            ->label('Attribute')
            ->routes('admin.attribute.create,admin.attribute.store');
        $permissionGroup->addPermission('admin-attribute-update')
            ->label('Attribute')
            ->routes('admin.attribute.edit,admin.attribute.update');
        $permissionGroup->addPermission('admin-attribute-destroy')
            ->label('Attribute')
            ->routes('admin.attribute.destroy');

        $permissionGroup = PermissionFacade::add('property')
            ->label('Attribute Permissions');

        $permissionGroup->addPermission('admin-property-list')
            ->label('Property List')
            ->routes('admin.property.index');
        $permissionGroup->addPermission('admin-property-create')
            ->label('Property Create')
            ->routes('admin.property.create,admin.property.store');
        $permissionGroup->addPermission('admin-attribute-update')
            ->label('Property Update')
            ->routes('admin.property.edit,admin.property.update');
        $permissionGroup->addPermission('admin-property-destroy')
            ->label('Property Destroy')
            ->routes('admin.property.destroy');

        $permissionGroup = PermissionFacade::add('admin-user')
            ->label('Admin User Permissions');

        $permissionGroup->addPermission('admin-admin-user-list')
            ->label('Admin User List')
            ->routes('admin.admin-user.index');

        $permissionGroup->addPermission('admin-admin-user-create')
            ->label('Admin User Create')
            ->routes('admin.admin-user.create,admin.admin-user.store');

        $permissionGroup->addPermission('admin-admin-user-update')
            ->label('Admin User Update')
            ->routes('admin.admin-user.edit,admin.admin-user.update');

        $permissionGroup->addPermission('admin-admin-user-destroy')
            ->label('Admin User Destroy')
            ->routes('admin.admin-user.destroy');

        $permissionGroup = PermissionFacade::add('role')
            ->label('Role Permissions');

        $permissionGroup->addPermission('admin-role-list')
            ->label('Role List')
            ->routes('admin.role.index');

        $permissionGroup->addPermission('admin-role-create')
            ->label('Role Create')
            ->routes('admin.role.create,admin.role.store');

        $permissionGroup->addPermission('admin-role-update')
            ->label('Role Update')
            ->routes('admin.role.edit,admin.role.update');

        $permissionGroup->addPermission('admin-role-destroy')
            ->label('Role Destroy')
            ->routes('admin.role.destroy');

        $permissionGroup = PermissionFacade::add('role')
            ->label('Theme Permissions');

        $permissionGroup->addPermission('admin-theme-list')
            ->label('Theme List')
            ->routes('admin.theme.index');

        $permissionGroup->addPermission('admin-theme-create')
            ->label('Theme Upload/Create')
            ->routes('admin.create.index', 'admin.theme.store');

        $permissionGroup->addPermission('admin-theme-activated')
            ->label('Theme Activated')
            ->routes('admin.activated.index');

        $permissionGroup->addPermission('admin-theme-deactivated')
            ->label('Theme Deactivated')
            ->routes('admin.deactivated.index');

        $permissionGroup->addPermission('admin-theme-destroy')
            ->label('Theme Destroy')
            ->routes('admin.destroy.index');

        $permissionGroup = PermissionFacade::add('configuration')
            ->label('Configuration Permissions');

        $permissionGroup->addPermission('admin-configuration')
            ->label('Configuration')
            ->routes('admin.configuration');

        $permissionGroup->addPermission('admin-configuration-store')
            ->label('Configuration Store')
            ->routes('admin.configuration.store');

        $permissionGroup = PermissionFacade::add('order')
            ->label('Order Permissions');

        $permissionGroup->addPermission('admin-order-list')
            ->label('Order List')
            ->routes('admin.order.index');

        $permissionGroup->addPermission('admin-order-view')
            ->label('Order View')
            ->routes('admin.order.view');

        $permissionGroup->addPermission('admin-order-send-invoice-email')
            ->label('Order Sent Invoice By Email')
            ->routes('admin.order.send-email-invoice');

        $permissionGroup->addPermission('admin-order-change-status')
            ->label('Order Change Status')
            ->routes('admin.order.change-status,admin.order.update-status');

        Blade::if('hasPermission', function ($routeName) {
            $condition = false;
            $user = Auth::guard('admin')->user();

            if (!$user) {
                $condition = $user->hasPermission($routeName) ?: false;
            }

            $converted_res = ($condition) ? 'true' : 'false';

            return "<?php if ($converted_res): ?>";
        });
    }