/** * Here we read rules from DB and put them into a form that BjyAuthorize's Controller.php understands * @return \Zend\Permissions\Acl\Resource\ResourceInterface[] */ public function getResources() { $resources = []; // get the doctrine shemaManager $schemaManager = $this->objectManager->getConnection()->getSchemaManager(); // check if the roles table exists, if it does not, do not bother querying if ($schemaManager->tablesExist(['admin_rule']) === true) { //read from object store a set of (controller) $result = $this->service->fetchAllResources([], [], ['controller_id']); // if a result set exists if (count($result)) { //transform to object BjyAuthorize will understand foreach ($result as $resource) { $resources[$resource->getControllerId()] = []; } } } return $resources; }
public function getServiceConfig() { return ['invokables' => [], 'factories' => ['Zend\\Authentication\\AuthenticationService' => function ($sm) { return $sm->get('doctrine.authenticationservice.orm_default'); }, 'zfcuser_module_options' => function ($sm) { $config = $sm->get('Configuration'); return new ModuleOptions(isset($config['zfcuser']) ? $config['zfcuser'] : []); }, 'zfmuscle_user_service' => function ($sm) { $service = new UserService(); $service->setServiceManager($sm); $provider = new UserProvider(); $em = $sm->get('doctrine.entitymanager.orm_default'); $provider->setEntityManager($em); $service->setProvider($provider); return $service; }, 'zfmuscle_role_service' => function ($sm) { $service = new RoleService(); $service->setServiceManager($sm); $formHydrator = $sm->get('default_hydrator'); $service->setFormHydrator($formHydrator); $provider = new RoleProvider(); $em = $sm->get('doctrine.entitymanager.orm_default'); $provider->setEntityManager($em); $service->setProvider($provider); return $service; }, 'zfmuscle_resource_service' => function ($sm) { $service = new ResourceService(); $service->setServiceManager($sm); $provider = new ResourceProvider(); $em = $sm->get('doctrine.entitymanager.orm_default'); $provider->setEntityManager($em); $service->setProvider($provider); return $service; }, 'zfmuscle_application_service' => function ($sm) { $service = new ApplicationService(); $service->setServiceManager($sm); $service->setXmlInstallPath("config" . DIRECTORY_SEPARATOR . "local.xml"); return $service; }, 'zfcuser_login_form' => function ($sm) { $options = $sm->get('zfcuser_module_options'); $form = new Login(null, $options); $form->setInputFilter(new LoginFilter($options)); return $form; }, 'zfcuser_register_form' => function ($sm) { $em = $sm->get('doctrine.entitymanager.orm_default'); $options = $sm->get('zfcuser_module_options'); $form = new User($em, null, $options); // $form->setCaptchaElement($sm->get('zfcuser_captcha_element')); $form->setInputFilter(new RegisterFilter(new NoRecordExists(['mapper' => $sm->get('zfcuser_user_mapper'), 'key' => 'email']), new NoRecordExists(['mapper' => $sm->get('zfcuser_user_mapper'), 'key' => 'username']), $options)); return $form; }, 'zfmuscle_role_form' => function ($sm) { $em = $sm->get('doctrine.entitymanager.orm_default'); $form = new Role($em); // $form->setServiceManager($sm); return $form; }, 'AuthSessionStorage' => function ($sm) { $config = $sm->get('config'); $authSessionStorage = new AuthSessionStorage('zfMuscle', null, $sm->get('Zend\\Session\\SessionManager')); $authSessionStorage->setAllowedIdleTimeInSeconds($config['session']['config']['authentication_expiration_time']); return $authSessionStorage; }, 'default_hydrator' => function ($sm) { $hydrator = new ClassMethods(); return $hydrator; }]]; }