Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Call to undefined method Phalcon\Acl\Adapter\Memory::addResource()

Hi, i'm migrating from phalcon 2.0 to 4.0 and I don't know how can I upgrade this library.

protected function addResources()
    {
        if (!(array)$this->resources->get('resource')) {
            throw new Exception('Key "resource" must exist and must be traversable.');
        }
        foreach ($this->resources->resource as $name => $resource) {

            $actions = (array)$resource->get('actions');
            if (!$actions)   $actions = NULL;

            $this->acl->addResource($this->makeResource($name, $resource->description), $actions);
        }
        return $this;
    }

( ! ) Fatal error: Uncaught Error: Call to undefined method Phalcon\Acl\Adapter\Memory::addResource() in /var/www/html/src/Common/Library/Memory.php on line 91 ( ! ) Error: Call to undefined method Phalcon\Acl\Adapter\Memory::addResource() in /var/www/html/src/Common/Library/Memory.php on line 91 Call Stack

Time Memory Function Location

1 0.0065 410736 {main}( ) .../index.php:0 2 0.6051 3663312 Identify\Application->run( ) .../index.php:58 3 0.6051 3663512 handle ( ) .../Application.php:173 4 0.7129 4136936 dispatch ( ) .../Application.php:173 5 0.7653 4609944 Identify\Backend\Controllers\IndexController->initialize( ) .../Application.php:173 6 0.7653 4609944 Identify\Backend\Controllers\IndexController->initialize( ) .../IndexController.php:28 7 0.7762 4673832 Identify\Backend\Controllers\IndexController->buildProfile( ) .../BaseController.php:146 8 0.7836 4773232 Identify\Common\Library\ProfileBuilder->getPermissions( ) .../BaseController.php:198 9 0.7836 4773232 Identify\Common\Library\ProfileBuilder->setPermissions( ) .../ProfileBuilder.php:50 10 0.7891 4912792 Identify\Common\Library\Memory->create( ) .../ProfileBuilder.php:67 11 0.7891 4913992 Identify\Common\Library\Memory->addResources( )

Thanks a lot!



116.1k
Accepted
answer

I don't think v4's ACL has a concept of "Resources". My guess is the closest equivalent would be "Components"

https://docs.phalcon.io/4.0/en/acl#adding-components