| @@ 19-58 (lines=40) @@ | ||
| 16 | /** |
|
| 17 | * Factory for creating the Auth view helper. |
|
| 18 | */ |
|
| 19 | class CheckPermissionsListenerFactory implements FactoryInterface |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * Create an object |
|
| 23 | * |
|
| 24 | * @param ContainerInterface $container |
|
| 25 | * @param string $requestedName |
|
| 26 | * @param null|array $options |
|
| 27 | * |
|
| 28 | * @return object |
|
| 29 | * @throws ServiceNotFoundException if unable to resolve the service. |
|
| 30 | * @throws ServiceNotCreatedException if an exception is raised when |
|
| 31 | * creating a service. |
|
| 32 | * @throws ContainerException if any other error occurs |
|
| 33 | */ |
|
| 34 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
| 35 | { |
|
| 36 | $acl = $container->get('acl'); |
|
| 37 | $user = $container->get('AuthenticationService')->getUser(); |
|
| 38 | $config = $container->get('Config'); |
|
| 39 | $exceptionMap = isset($config['acl']['exceptions']) ? $config['acl']['exceptions'] : array(); |
|
| 40 | $listener = new CheckPermissionsListener($acl, $user, $exceptionMap); |
|
| 41 | ||
| 42 | return $listener; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * Creates an instance of \Auth\View\Helper\Auth |
|
| 47 | * |
|
| 48 | * - Injects the AuthenticationService |
|
| 49 | * |
|
| 50 | * @param ServiceLocatorInterface $helpers |
|
| 51 | * @return \Auth\View\Helper\Auth |
|
| 52 | * @see \Zend\ServiceManager\FactoryInterface::createService() |
|
| 53 | */ |
|
| 54 | public function createService(ServiceLocatorInterface $serviceLocator) |
|
| 55 | { |
|
| 56 | return $this($serviceLocator, CheckPermissionsListener::class); |
|
| 57 | } |
|
| 58 | } |
|
| 59 | ||
| @@ 25-64 (lines=40) @@ | ||
| 22 | * @author Mathias Gelhausen <[email protected]> |
|
| 23 | * @since 0,29 |
|
| 24 | */ |
|
| 25 | class SnippetFactory implements FactoryInterface |
|
| 26 | { |
|
| 27 | ||
| 28 | /** |
|
| 29 | * Creates snippet view helper |
|
| 30 | * |
|
| 31 | * @param ContainerInterface $container |
|
| 32 | * @param string $requestedName |
|
| 33 | * @param array $options |
|
| 34 | * |
|
| 35 | * @return Snippet |
|
| 36 | */ |
|
| 37 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
| 38 | { |
|
| 39 | $config = $container->get('Config'); |
|
| 40 | $config = isset($config['view_helper_config']['snippets']) ? $config['view_helper_config']['snippets'] : []; |
|
| 41 | ||
| 42 | $events = $container->get('Core/ViewSnippets/Events'); |
|
| 43 | ||
| 44 | $helpers = $container->get('ViewHelperManager'); |
|
| 45 | $partials = $helpers->get('partial'); |
|
| 46 | ||
| 47 | return new Snippet($partials, $events, $config); |
|
| 48 | } |
|
| 49 | ||
| 50 | ||
| 51 | /** |
|
| 52 | * Creates snippet view helper- |
|
| 53 | * |
|
| 54 | * @param ServiceLocatorInterface|AbstractPluginManager $serviceLocator |
|
| 55 | * |
|
| 56 | * @return Snippet |
|
| 57 | */ |
|
| 58 | public function createService(ServiceLocatorInterface $serviceLocator) |
|
| 59 | { |
|
| 60 | $container = $serviceLocator->getServiceLocator(); |
|
| 61 | ||
| 62 | return $this($container, Snippet::class); |
|
| 63 | } |
|
| 64 | } |
|