예제 #1
0
 /**
  * Returns BlogController instance.
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return BlogController
  * @override
  **/
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /* @var $serviceLocator Zend\Mvc\Controller\ControllerManager */
     $sm = $serviceLocator->getServiceLocator();
     $em = $sm->get('em');
     $service = new PostService($em);
     $controller = new BlogController();
     $controller->setEntityManager($em);
     $controller->setPostService($service);
     $acl = new Acl();
     $acl->addRole(new Role(UserService::ROLE_GUEST));
     $acl->addRole(new Role(UserService::ROLE_ADMIN));
     $acl->addResource($controller);
     $acl->allow(UserService::ROLE_ADMIN, $controller);
     $acl->allow(UserService::ROLE_GUEST, $controller);
     $acl->deny(UserService::ROLE_GUEST, $controller, array('create', 'edit', 'view-all'));
     $controller->setAcl($acl);
     return $controller;
 }