@@ -22,60 +22,60 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class HeadScriptFactory implements FactoryInterface |
| 24 | 24 | { |
| 25 | - public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
| 26 | - { |
|
| 27 | - /* @var $helper \Zend\View\Helper\Headscript|\Callable */ |
|
| 28 | - /* @var $container \Zend\ServiceManager\AbstractPluginManager */ |
|
| 29 | - /* @var $services \Zend\ServiceManager\ServiceLocatorInterface */ |
|
| 30 | - $viewHelperManager = $container->get('ViewHelperManager'); |
|
| 31 | - $helper = $viewHelperManager->get('headscript'); //new HeadScript(); |
|
| 32 | - $services = $container; |
|
| 33 | - $config = $services->get('Config'); |
|
| 25 | + public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
| 26 | + { |
|
| 27 | + /* @var $helper \Zend\View\Helper\Headscript|\Callable */ |
|
| 28 | + /* @var $container \Zend\ServiceManager\AbstractPluginManager */ |
|
| 29 | + /* @var $services \Zend\ServiceManager\ServiceLocatorInterface */ |
|
| 30 | + $viewHelperManager = $container->get('ViewHelperManager'); |
|
| 31 | + $helper = $viewHelperManager->get('headscript'); //new HeadScript(); |
|
| 32 | + $services = $container; |
|
| 33 | + $config = $services->get('Config'); |
|
| 34 | 34 | |
| 35 | - if (!isset($config['view_helper_config']['headscript'])) { |
|
| 36 | - return $helper; |
|
| 37 | - } |
|
| 35 | + if (!isset($config['view_helper_config']['headscript'])) { |
|
| 36 | + return $helper; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - $config = $config['view_helper_config']['headscript']; |
|
| 39 | + $config = $config['view_helper_config']['headscript']; |
|
| 40 | 40 | |
| 41 | - /* @var $routeMatch \Zend\Router\RouteMatch */ |
|
| 42 | - $routeMatch = $services->get('Application')->getMvcEvent()->getRouteMatch(); |
|
| 43 | - $routeName = $routeMatch ? $routeMatch->getMatchedRouteName() : ''; |
|
| 44 | - $basepath = $viewHelperManager->get('basepath'); /* @var $basepath \Zend\View\Helper\BasePath */ |
|
| 41 | + /* @var $routeMatch \Zend\Router\RouteMatch */ |
|
| 42 | + $routeMatch = $services->get('Application')->getMvcEvent()->getRouteMatch(); |
|
| 43 | + $routeName = $routeMatch ? $routeMatch->getMatchedRouteName() : ''; |
|
| 44 | + $basepath = $viewHelperManager->get('basepath'); /* @var $basepath \Zend\View\Helper\BasePath */ |
|
| 45 | 45 | |
| 46 | - foreach ($config as $routeStart => $specs) { |
|
| 47 | - if (!is_int($routeStart)) { |
|
| 48 | - if (0 !== strpos($routeName, $routeStart)) { |
|
| 49 | - continue; |
|
| 50 | - } |
|
| 51 | - } else { |
|
| 52 | - $specs = array($specs); |
|
| 53 | - } |
|
| 46 | + foreach ($config as $routeStart => $specs) { |
|
| 47 | + if (!is_int($routeStart)) { |
|
| 48 | + if (0 !== strpos($routeName, $routeStart)) { |
|
| 49 | + continue; |
|
| 50 | + } |
|
| 51 | + } else { |
|
| 52 | + $specs = array($specs); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - if (is_string($specs)) { |
|
| 56 | - $helper->appendScript('// if you are missing the script ' . $specs . ' look up your config and enclose it in an array'); |
|
| 57 | - continue; |
|
| 58 | - } |
|
| 55 | + if (is_string($specs)) { |
|
| 56 | + $helper->appendScript('// if you are missing the script ' . $specs . ' look up your config and enclose it in an array'); |
|
| 57 | + continue; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - foreach ($specs as $spec) { |
|
| 61 | - if (is_string($spec)) { |
|
| 62 | - $helper->appendFile($basepath($spec)); |
|
| 63 | - continue; |
|
| 64 | - } |
|
| 60 | + foreach ($specs as $spec) { |
|
| 61 | + if (is_string($spec)) { |
|
| 62 | + $helper->appendFile($basepath($spec)); |
|
| 63 | + continue; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - if ($helper::SCRIPT != $spec[0]) { |
|
| 67 | - $spec[1] = $basepath($spec[1]); |
|
| 68 | - } |
|
| 66 | + if ($helper::SCRIPT != $spec[0]) { |
|
| 67 | + $spec[1] = $basepath($spec[1]); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - call_user_func_array($helper, $spec); |
|
| 71 | - } |
|
| 72 | - } |
|
| 70 | + call_user_func_array($helper, $spec); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - return $helper; |
|
| 75 | - } |
|
| 74 | + return $helper; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | 77 | |
| 78 | - /** |
|
| 78 | + /** |
|
| 79 | 79 | * Creates an instance of \Zend\View\Helper\Headscript |
| 80 | 80 | * |
| 81 | 81 | * - injects the MvcEvent instance |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | * |
| 32 | 32 | * @param EventManagerInterface $events |
| 33 | 33 | * @param integer $priority |
| 34 | - */ |
|
| 34 | + */ |
|
| 35 | 35 | public function attach(EventManagerInterface $events, $priority = 1) |
| 36 | 36 | { |
| 37 | 37 | $this->listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'handleError'), $priority); |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | */ |
| 48 | 48 | protected $paginator; |
| 49 | 49 | |
| 50 | - /** |
|
| 50 | + /** |
|
| 51 | 51 | * @return string |
| 52 | 52 | */ |
| 53 | 53 | public function getPaginatorName() |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | protected $hasRunned = true; |
| 37 | 37 | |
| 38 | - /** |
|
| 38 | + /** |
|
| 39 | 39 | * @param SharedEventManagerInterface $events |
| 40 | 40 | * |
| 41 | 41 | * @return $this |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public function add($event) |
| 69 | 69 | { |
| 70 | - //@TODO: [ZF3] $event->getNotification() is not working |
|
| 71 | - $target = $event->getTarget(); |
|
| 72 | - if($target instanceof NotificationEvent){ |
|
| 73 | - $notification = $target->getNotification(); |
|
| 74 | - $this->notifications[] = $notification; |
|
| 75 | - $this->hasRunned = false; |
|
| 76 | - } |
|
| 70 | + //@TODO: [ZF3] $event->getNotification() is not working |
|
| 71 | + $target = $event->getTarget(); |
|
| 72 | + if($target instanceof NotificationEvent){ |
|
| 73 | + $notification = $target->getNotification(); |
|
| 74 | + $this->notifications[] = $notification; |
|
| 75 | + $this->hasRunned = false; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | 78 | return $this; |
| 79 | 79 | } |
@@ -133,16 +133,16 @@ discard block |
||
| 133 | 133 | return $this; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - /** |
|
| 137 | - * @param ContainerInterface $container |
|
| 138 | - * |
|
| 139 | - * @return NotificationListener |
|
| 140 | - */ |
|
| 136 | + /** |
|
| 137 | + * @param ContainerInterface $container |
|
| 138 | + * |
|
| 139 | + * @return NotificationListener |
|
| 140 | + */ |
|
| 141 | 141 | static public function factory(ContainerInterface $container) |
| 142 | 142 | { |
| 143 | - $sharedManager = $container->get('Application')->getEventManager()->getSharedManager(); |
|
| 144 | - $instance = new NotificationListener($sharedManager); |
|
| 145 | - $instance->setEventPrototype(new NotificationEvent()); |
|
| 146 | - return $instance; |
|
| 143 | + $sharedManager = $container->get('Application')->getEventManager()->getSharedManager(); |
|
| 144 | + $instance = new NotificationListener($sharedManager); |
|
| 145 | + $instance->setEventPrototype(new NotificationEvent()); |
|
| 146 | + return $instance; |
|
| 147 | 147 | } |
| 148 | 148 | } |
@@ -14,10 +14,10 @@ |
||
| 14 | 14 | |
| 15 | 15 | interface ContainerAwareInterface |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @param ContainerInterface $container |
|
| 19 | - * |
|
| 20 | - * @return mixed |
|
| 21 | - */ |
|
| 22 | - public function setContainer(ContainerInterface $container); |
|
| 17 | + /** |
|
| 18 | + * @param ContainerInterface $container |
|
| 19 | + * |
|
| 20 | + * @return mixed |
|
| 21 | + */ |
|
| 22 | + public function setContainer(ContainerInterface $container); |
|
| 23 | 23 | } |
| 24 | 24 | \ No newline at end of file |
@@ -38,15 +38,15 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | protected $serviceLocator; |
| 40 | 40 | |
| 41 | - public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
| 42 | - { |
|
| 43 | - $this->serviceLocator = $container; |
|
| 44 | - $service = new RestClient($this->getUri(), $this->getConfig()); |
|
| 45 | - return $service; |
|
| 46 | - } |
|
| 41 | + public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
| 42 | + { |
|
| 43 | + $this->serviceLocator = $container; |
|
| 44 | + $service = new RestClient($this->getUri(), $this->getConfig()); |
|
| 45 | + return $service; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | 48 | |
| 49 | - /** |
|
| 49 | + /** |
|
| 50 | 50 | * Create the settings service |
| 51 | 51 | * |
| 52 | 52 | * @param ServiceLocatorInterface $serviceLocator |
@@ -239,9 +239,9 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | $events->setIdentifiers($config['identifiers']); |
| 241 | 241 | |
| 242 | - /* @var \Zend\EventManager\EventInterface $event */ |
|
| 243 | - $event = $services->has($config['event']) ? $services->get($config['event']) : new $config['event'](); |
|
| 244 | - $events->setEventPrototype($event); |
|
| 242 | + /* @var \Zend\EventManager\EventInterface $event */ |
|
| 243 | + $event = $services->has($config['event']) ? $services->get($config['event']) : new $config['event'](); |
|
| 244 | + $events->setEventPrototype($event); |
|
| 245 | 245 | |
| 246 | 246 | if ('EventManager' != $config['service'] && method_exists($events, 'setSharedManager') && $services->has('SharedEventManager')) { |
| 247 | 247 | /* @var \Zend\EventManager\SharedEventManagerInterface $sharedEvents */ |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | /* @var \Core\Listener\DeferredListenerAggregate $aggregate */ |
| 308 | 308 | $aggregate = $services->get('Core/Listener/DeferredListenerAggregate'); |
| 309 | 309 | $aggregate->setListeners($lazyListeners) |
| 310 | - ->attach($eventManager); |
|
| 310 | + ->attach($eventManager); |
|
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
@@ -24,57 +24,57 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | class LazyControllerFactory implements AbstractFactoryInterface |
| 26 | 26 | { |
| 27 | - protected $aliases = [ |
|
| 28 | - FormElementManager::class => 'FormElementManager', |
|
| 29 | - ValidatorPluginManager::class => 'ValidatorManager', |
|
| 30 | - Translator::class => 'translator', |
|
| 31 | - ModuleManager::class => 'ModuleManager', |
|
| 32 | - EventManager::class => 'Core/EventManager' |
|
| 33 | - ]; |
|
| 27 | + protected $aliases = [ |
|
| 28 | + FormElementManager::class => 'FormElementManager', |
|
| 29 | + ValidatorPluginManager::class => 'ValidatorManager', |
|
| 30 | + Translator::class => 'translator', |
|
| 31 | + ModuleManager::class => 'ModuleManager', |
|
| 32 | + EventManager::class => 'Core/EventManager' |
|
| 33 | + ]; |
|
| 34 | 34 | |
| 35 | - public function canCreate( ContainerInterface $container, $requestedName ) |
|
| 36 | - { |
|
| 37 | - list( $module, ) = explode( '\\', __NAMESPACE__, 2 ); |
|
| 38 | - return strstr( $requestedName, $module . '\Controller') !== false; |
|
| 39 | - } |
|
| 35 | + public function canCreate( ContainerInterface $container, $requestedName ) |
|
| 36 | + { |
|
| 37 | + list( $module, ) = explode( '\\', __NAMESPACE__, 2 ); |
|
| 38 | + return strstr( $requestedName, $module . '\Controller') !== false; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
| 42 | - { |
|
| 43 | - $class = new \ReflectionClass($requestedName); |
|
| 44 | - $parentLocator = $container; |
|
| 45 | - if( $constructor = $class->getConstructor() ) |
|
| 46 | - { |
|
| 47 | - if( $params = $constructor->getParameters() ) |
|
| 48 | - { |
|
| 49 | - $parameter_instances = []; |
|
| 50 | - foreach( $params as $p ) |
|
| 51 | - { |
|
| 41 | + public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
| 42 | + { |
|
| 43 | + $class = new \ReflectionClass($requestedName); |
|
| 44 | + $parentLocator = $container; |
|
| 45 | + if( $constructor = $class->getConstructor() ) |
|
| 46 | + { |
|
| 47 | + if( $params = $constructor->getParameters() ) |
|
| 48 | + { |
|
| 49 | + $parameter_instances = []; |
|
| 50 | + foreach( $params as $p ) |
|
| 51 | + { |
|
| 52 | 52 | |
| 53 | - if( $p->getClass() ) { |
|
| 54 | - $cn = $p->getClass()->getName(); |
|
| 55 | - if (array_key_exists($cn, $this->aliases)) { |
|
| 56 | - $cn = $this->aliases[$cn]; |
|
| 57 | - } |
|
| 53 | + if( $p->getClass() ) { |
|
| 54 | + $cn = $p->getClass()->getName(); |
|
| 55 | + if (array_key_exists($cn, $this->aliases)) { |
|
| 56 | + $cn = $this->aliases[$cn]; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - try { |
|
| 60 | - $parameter_instances[] = $parentLocator->get($cn); |
|
| 61 | - } |
|
| 62 | - catch (\Exception $x) { |
|
| 63 | - echo __CLASS__ |
|
| 64 | - . " couldn't create an instance of $cn to satisfy the constructor for $requestedName."; |
|
| 65 | - exit; |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - else{ |
|
| 69 | - if( $p->isArray() && $p->getName() == 'config' ) |
|
| 70 | - $parameter_instances[] = $parentLocator->get('config'); |
|
| 71 | - } |
|
| 59 | + try { |
|
| 60 | + $parameter_instances[] = $parentLocator->get($cn); |
|
| 61 | + } |
|
| 62 | + catch (\Exception $x) { |
|
| 63 | + echo __CLASS__ |
|
| 64 | + . " couldn't create an instance of $cn to satisfy the constructor for $requestedName."; |
|
| 65 | + exit; |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + else{ |
|
| 69 | + if( $p->isArray() && $p->getName() == 'config' ) |
|
| 70 | + $parameter_instances[] = $parentLocator->get('config'); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - } |
|
| 74 | - return $class->newInstanceArgs($parameter_instances); |
|
| 75 | - } |
|
| 76 | - } |
|
| 73 | + } |
|
| 74 | + return $class->newInstanceArgs($parameter_instances); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - return new $requestedName; |
|
| 79 | - } |
|
| 78 | + return new $requestedName; |
|
| 79 | + } |
|
| 80 | 80 | } |
| 81 | 81 | \ No newline at end of file |
@@ -39,27 +39,27 @@ |
||
| 39 | 39 | * @throws ContainerException if any other error occurs |
| 40 | 40 | */ |
| 41 | 41 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { |
| 42 | - $basePath = $container->get( 'ViewHelperManager' )->get( 'basepath' ); |
|
| 43 | - $config = $container->get( 'Config' ); |
|
| 42 | + $basePath = $container->get( 'ViewHelperManager' )->get( 'basepath' ); |
|
| 43 | + $config = $container->get( 'Config' ); |
|
| 44 | 44 | |
| 45 | - /* @var \Zend\Mvc\MvcEvent $event */ |
|
| 46 | - $event = $container->get( 'application' )->getMvcEvent(); |
|
| 45 | + /* @var \Zend\Mvc\MvcEvent $event */ |
|
| 46 | + $event = $container->get( 'application' )->getMvcEvent(); |
|
| 47 | 47 | |
| 48 | - $lang = $event->getRouteMatch()->getParam( 'lang' ); |
|
| 48 | + $lang = $event->getRouteMatch()->getParam( 'lang' ); |
|
| 49 | 49 | |
| 50 | - $helper = new FormEditorLight(); |
|
| 51 | - if ( isset( $config['view_helper_config']['form_editor']['light'] ) && is_array( $config['view_helper_config']['form_editor']['light'] ) ) { |
|
| 52 | - $helper->setOptions( $config['view_helper_config']['form_editor']['light'] ); |
|
| 53 | - } |
|
| 50 | + $helper = new FormEditorLight(); |
|
| 51 | + if ( isset( $config['view_helper_config']['form_editor']['light'] ) && is_array( $config['view_helper_config']['form_editor']['light'] ) ) { |
|
| 52 | + $helper->setOptions( $config['view_helper_config']['form_editor']['light'] ); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - $helper->setOption( 'theme', 'modern' ); |
|
| 56 | - $helper->setOption( 'selector', 'div.tinymce_light' ); |
|
| 55 | + $helper->setOption( 'theme', 'modern' ); |
|
| 56 | + $helper->setOption( 'selector', 'div.tinymce_light' ); |
|
| 57 | 57 | |
| 58 | - if ( in_array( $lang, [ 'de', 'fr', 'it', 'es', 'hi', 'ar', 'ru', 'zh', 'tr' ] ) ) { |
|
| 59 | - $helper->setOption( 'language', $lang ); |
|
| 60 | - $helper->setOption( 'language_url', $basePath( '/js/tinymce-lang/' ) . $lang . '.js' ); |
|
| 61 | - } |
|
| 58 | + if ( in_array( $lang, [ 'de', 'fr', 'it', 'es', 'hi', 'ar', 'ru', 'zh', 'tr' ] ) ) { |
|
| 59 | + $helper->setOption( 'language', $lang ); |
|
| 60 | + $helper->setOption( 'language_url', $basePath( '/js/tinymce-lang/' ) . $lang . '.js' ); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return $helper; |
|
| 63 | + return $helper; |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | \ No newline at end of file |