Haris Mehmood
Haris Mehmood

Reputation: 902

Serialization of Closure is not allowed - ZF2 and BjyAuthorize

So I am using BjyAuthorize for route guards & rules for resources, I am using assertion in rule providers of BjyAuthorize but they seem to throw this error

Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'Closure' is not allowed' in /home/haris/Glide/vcgca/vendor/zendframework/zend-stdlib/src/PriorityQueue.php on line 178

Exception: Serialization of 'Closure' is not allowed in /home/haris/Glide/vcgca/vendor/zendframework/zend-stdlib/src/PriorityQueue.php on line 178

Here is my config for rule provider:

'bjyauthorize' => array(
        'resource_providers' => array(
            'BjyAuthorize\Provider\Resource\Config' => array(
                'Page' => array(),
            ),
        ),
        'rule_providers' => array(
            'BjyAuthorize\Provider\Rule\Config' => array(
                'allow' => array(
                    array(array('user', 'user1'), 'Page', array('edit'), 'assertion.CheckManager'),
                ),
            ),
        ),
    ),

Here is my assertion class factory:

class PageManagerAssertionFactory implements FactoryInterface {

    public function createService(ServiceLocatorInterface $serviceLocator) {
        $authentication = $serviceLocator->get('zfcuser_auth_service');
        $entityManager = $serviceLocator->get('doctrine.entitymanager.orm_default');
        return new PageManagerAssertion($authentication, $entityManager);
    }

}

This is my assertion class:

class PageManagerAssertion implements AssertionInterface {

    protected $authentication;
    protected $entityManager;

    public function __construct($authentication, EntityManager $entityManager) {
        $this->authentication = $authentication;
        $this->entityManager = $entityManager;
    }

    public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null) {

        if ($resource instanceof Page) {
            return false;
        } else {
            return true;
        }
    }

}

I have included this class in service service_manager config in module.config.php

'service_manager' => array(
        'factories' => array(
            //ASSERTIONS
            'assertion.CheckManager' => 'AlphaPage\Assertion\PageManagerAssertionFactory',
            //OTHERS
            ......
        ),
    ),

I have no idea why am I getting this error, I followed all the steps to use the modules, I have assertions in other modules that are working totally fine.

Any help in this regard will be highly appreciated.

Upvotes: 1

Views: 230

Answers (0)

Related Questions