#!/usr/bin/env php 3t zftool.pharzf.phpKS*RKx, Module.php8S*R8 :!vendor/composer/autoload_real.phpS*R:%vendor/composer/autoload_classmap.phpaS*Ra·vendor/composer/ClassLoader.php< S*R< Q¶'vendor/composer/autoload_namespaces.php%S*R%(¶vendor/autoload.phpS*R6vendor/zendframework/zend-mvc/Zend/Mvc/Application.phpWS*RWZI<vendor/zendframework/zend-mvc/Zend/Mvc/Router/Http/Chain.php S*R d=vendor/zendframework/zend-mvc/Zend/Mvc/Router/Http/Scheme.php\S*R\-?vendor/zendframework/zend-mvc/Zend/Mvc/Router/Http/Hostname.phpS*REvendor/zendframework/zend-mvc/Zend/Mvc/Router/Http/TreeRouteStack.phpS*R7hݶTvendor/zendframework/zend-mvc/Zend/Mvc/Router/Http/TranslatorAwareTreeRouteStack.phpQS*RQ„<vendor/zendframework/zend-mvc/Zend/Mvc/Router/Http/Query.phpS*RS#<vendor/zendframework/zend-mvc/Zend/Mvc/Router/Http/Regex.phpS*RIu>vendor/zendframework/zend-mvc/Zend/Mvc/Router/Http/Segment.phpS*R>;vendor/zendframework/zend-mvc/Zend/Mvc/Router/Http/Part.phpS*R?vendor/zendframework/zend-mvc/Zend/Mvc/Router/Http/Wildcard.phpW S*RW 3y=vendor/zendframework/zend-mvc/Zend/Mvc/Router/Http/Method.phpmS*RmEvendor/zendframework/zend-mvc/Zend/Mvc/Router/Http/RouteInterface.phpS*RGvAvendor/zendframework/zend-mvc/Zend/Mvc/Router/Http/RouteMatch.phpS*RBA8>vendor/zendframework/zend-mvc/Zend/Mvc/Router/Http/Literal.php5S*R5Evendor/zendframework/zend-mvc/Zend/Mvc/Router/RouteStackInterface.phpS*RqVOTvendor/zendframework/zend-mvc/Zend/Mvc/Router/Exception/InvalidArgumentException.phpS*RNvendor/zendframework/zend-mvc/Zend/Mvc/Router/Exception/ExceptionInterface.phpS*Rm}Lvendor/zendframework/zend-mvc/Zend/Mvc/Router/Exception/RuntimeException.phpS*RY$>vendor/zendframework/zend-mvc/Zend/Mvc/Router/PriorityList.phpDS*RDEsݝ@vendor/zendframework/zend-mvc/Zend/Mvc/Router/RouteInterface.phpS*RZ]Dvendor/zendframework/zend-mvc/Zend/Mvc/Router/RoutePluginManager.phpS*R_<vendor/zendframework/zend-mvc/Zend/Mvc/Router/RouteMatch.phpS*RԒBvendor/zendframework/zend-mvc/Zend/Mvc/Router/SimpleRouteStack.phpS*RYBvendor/zendframework/zend-mvc/Zend/Mvc/Router/Console/Catchall.phpS*RWHvendor/zendframework/zend-mvc/Zend/Mvc/Router/Console/RouteInterface.phpS*R`˶Dvendor/zendframework/zend-mvc/Zend/Mvc/Router/Console/RouteMatch.phpS*R]ysJvendor/zendframework/zend-mvc/Zend/Mvc/Router/Console/SimpleRouteStack.phpS*RVp֦@vendor/zendframework/zend-mvc/Zend/Mvc/Router/Console/Simple.php3S*R3Vܶ>vendor/zendframework/zend-mvc/Zend/Mvc/ModuleRouteListener.phpS*R:vendor/zendframework/zend-mvc/Zend/Mvc/I18n/Translator.phpS*RJ=ضKvendor/zendframework/zend-mvc/Zend/Mvc/Exception/InvalidPluginException.phpwS*RwzVDvendor/zendframework/zend-mvc/Zend/Mvc/Exception/DomainException.phpvS*RvרEMvendor/zendframework/zend-mvc/Zend/Mvc/Exception/InvalidArgumentException.phpS*Rd2Ovendor/zendframework/zend-mvc/Zend/Mvc/Exception/InvalidControllerException.php{S*R{>.Gvendor/zendframework/zend-mvc/Zend/Mvc/Exception/ExceptionInterface.phpFS*RFwWEvendor/zendframework/zend-mvc/Zend/Mvc/Exception/RuntimeException.phpxS*Rx϶Lvendor/zendframework/zend-mvc/Zend/Mvc/Exception/MissingLocatorException.php`S*R`a2Evendor/zendframework/zend-mvc/Zend/Mvc/Service/ApplicationFactory.phpeS*Re8EIvendor/zendframework/zend-mvc/Zend/Mvc/Service/HydratorManagerFactory.phpS*RHXvendor/zendframework/zend-mvc/Zend/Mvc/Service/DiStrictAbstractServiceFactoryFactory.phpS*RV9Gvendor/zendframework/zend-mvc/Zend/Mvc/Service/FilterManagerFactory.phpS*RI¶Qvendor/zendframework/zend-mvc/Zend/Mvc/Service/ViewTemplateMapResolverFactory.php`S*R`i>Jvendor/zendframework/zend-mvc/Zend/Mvc/Service/ValidatorManagerFactory.phpS*RG ضOvendor/zendframework/zend-mvc/Zend/Mvc/Service/ViewTemplatePathStackFactory.phpS*Rgi&-Nvendor/zendframework/zend-mvc/Zend/Mvc/Service/DiServiceInitializerFactory.phpS*RwPIնJvendor/zendframework/zend-mvc/Zend/Mvc/Service/ViewFeedRendererFactory.phpfS*RfKvendor/zendframework/zend-mvc/Zend/Mvc/Service/ViewHelperManagerFactory.php S*R cBhQvendor/zendframework/zend-mvc/Zend/Mvc/Service/ControllerPluginManagerFactory.phpS*R(PgCXvendor/zendframework/zend-mvc/Zend/Mvc/Service/SerializerAdapterPluginManagerFactory.phpS*RköIvendor/zendframework/zend-mvc/Zend/Mvc/Service/HttpViewManagerFactory.php[S*R[@vendor/zendframework/zend-mvc/Zend/Mvc/Service/RouterFactory.phpS*RQIvendor/zendframework/zend-mvc/Zend/Mvc/Service/ServiceListenerFactory.phpS*R۶Jvendor/zendframework/zend-mvc/Zend/Mvc/Service/ControllerLoaderFactory.phpS*RMLvendor/zendframework/zend-mvc/Zend/Mvc/Service/ConsoleViewManagerFactory.php]S*R]dAvendor/zendframework/zend-mvc/Zend/Mvc/Service/RequestFactory.phpS*RAƼFvendor/zendframework/zend-mvc/Zend/Mvc/Service/EventManagerFactory.phpS*RV Fvendor/zendframework/zend-mvc/Zend/Mvc/Service/ViewResolverFactory.phpS*RxQvendor/zendframework/zend-mvc/Zend/Mvc/Service/DiStrictAbstractServiceFactory.php S*R ZLvendor/zendframework/zend-mvc/Zend/Mvc/Service/InputFilterManagerFactory.phpS*RYEvendor/zendframework/zend-mvc/Zend/Mvc/Service/ViewManagerFactory.phpS*RضGvendor/zendframework/zend-mvc/Zend/Mvc/Service/ModuleManagerFactory.phpc S*Rc '9<vendor/zendframework/zend-mvc/Zend/Mvc/Service/DiFactory.phpS*R Gvendor/zendframework/zend-mvc/Zend/Mvc/Service/ServiceManagerConfig.php S*R {Jvendor/zendframework/zend-mvc/Zend/Mvc/Service/ViewJsonStrategyFactory.phpS*R.Jvendor/zendframework/zend-mvc/Zend/Mvc/Service/ViewJsonRendererFactory.phpfS*Rf_PPvendor/zendframework/zend-mvc/Zend/Mvc/Service/PaginatorPluginManagerFactory.phptS*RtY Rvendor/zendframework/zend-mvc/Zend/Mvc/Service/DiAbstractServiceFactoryFactory.phpPS*RPѤLvendor/zendframework/zend-mvc/Zend/Mvc/Service/FormElementManagerFactory.phpS*R2Hvendor/zendframework/zend-mvc/Zend/Mvc/Service/ConsoleAdapterFactory.phpS*RtBvendor/zendframework/zend-mvc/Zend/Mvc/Service/ResponseFactory.phpS*R rocKvendor/zendframework/zend-mvc/Zend/Mvc/Service/TranslatorServiceFactory.phpS*RRhS׶Jvendor/zendframework/zend-mvc/Zend/Mvc/Service/ViewFeedStrategyFactory.phpS*Rhbg϶@vendor/zendframework/zend-mvc/Zend/Mvc/Service/ConfigFactory.phpS*R pOvendor/zendframework/zend-mvc/Zend/Mvc/Service/AbstractPluginManagerFactory.php S*R qɜLvendor/zendframework/zend-mvc/Zend/Mvc/Service/RoutePluginManagerFactory.phpS*R,ֶLvendor/zendframework/zend-mvc/Zend/Mvc/View/Http/CreateViewModelListener.php|S*R|`ԶFvendor/zendframework/zend-mvc/Zend/Mvc/View/Http/ExceptionStrategy.php S*R tVHSvendor/zendframework/zend-mvc/Zend/Mvc/View/Http/InjectRoutematchParamsListener.phpcS*Rc_TLvendor/zendframework/zend-mvc/Zend/Mvc/View/Http/InjectViewModelListener.phpS*R@Jvendor/zendframework/zend-mvc/Zend/Mvc/View/Http/RouteNotFoundStrategy.phpS*R~@vendor/zendframework/zend-mvc/Zend/Mvc/View/Http/ViewManager.php@#S*R@#D>ͯKvendor/zendframework/zend-mvc/Zend/Mvc/View/Http/InjectTemplateListener.php S*R Ȗ>Mvendor/zendframework/zend-mvc/Zend/Mvc/View/Http/DefaultRenderingStrategy.phpVS*RV"RoDvendor/zendframework/zend-mvc/Zend/Mvc/View/SendResponseListener.phpS*R?5ĎOvendor/zendframework/zend-mvc/Zend/Mvc/View/Console/CreateViewModelListener.phpS*RJIvendor/zendframework/zend-mvc/Zend/Mvc/View/Console/ExceptionStrategy.php S*R ?COvendor/zendframework/zend-mvc/Zend/Mvc/View/Console/InjectViewModelListener.phpS*RNMvendor/zendframework/zend-mvc/Zend/Mvc/View/Console/RouteNotFoundStrategy.phpS*R_|Cvendor/zendframework/zend-mvc/Zend/Mvc/View/Console/ViewManager.phpVS*RVFYXvendor/zendframework/zend-mvc/Zend/Mvc/View/Console/InjectNamedConsoleParamsListener.phpS*R?%Pvendor/zendframework/zend-mvc/Zend/Mvc/View/Console/DefaultRenderingStrategy.php:S*R:1+ԶCvendor/zendframework/zend-mvc/Zend/Mvc/Controller/PluginManager.phpS*R7Gvendor/zendframework/zend-mvc/Zend/Mvc/Controller/ControllerManager.phpNS*RNi9Dvendor/zendframework/zend-mvc/Zend/Mvc/Controller/Plugin/Forward.phppS*RpuXvendor/zendframework/zend-mvc/Zend/Mvc/Controller/Plugin/AcceptableViewModelSelector.phpS*ROtKvendor/zendframework/zend-mvc/Zend/Mvc/Controller/Plugin/AbstractPlugin.phpSS*RSvDjCvendor/zendframework/zend-mvc/Zend/Mvc/Controller/Plugin/Layout.phpS*R~{Svendor/zendframework/zend-mvc/Zend/Mvc/Controller/Plugin/Service/ForwardFactory.phpS*RbtTvendor/zendframework/zend-mvc/Zend/Mvc/Controller/Plugin/Service/IdentityFactory.php;S*R;O@vendor/zendframework/zend-mvc/Zend/Mvc/Controller/Plugin/Url.phpS*R-M/`Evendor/zendframework/zend-mvc/Zend/Mvc/Controller/Plugin/Redirect.phplS*Rl0Cvendor/zendframework/zend-mvc/Zend/Mvc/Controller/Plugin/Params.phpS*RoٶEvendor/zendframework/zend-mvc/Zend/Mvc/Controller/Plugin/Identity.phpS*RUjKvendor/zendframework/zend-mvc/Zend/Mvc/Controller/Plugin/FlashMessenger.phpS*RuPvendor/zendframework/zend-mvc/Zend/Mvc/Controller/Plugin/FilePostRedirectGet.phpS*RȭLvendor/zendframework/zend-mvc/Zend/Mvc/Controller/Plugin/PostRedirectGet.phpS*R=2Lvendor/zendframework/zend-mvc/Zend/Mvc/Controller/Plugin/PluginInterface.phpS*RՂiIOvendor/zendframework/zend-mvc/Zend/Mvc/Controller/AbstractRestfulController.phpS*R7OvHvendor/zendframework/zend-mvc/Zend/Mvc/Controller/AbstractController.phpDS*RDPNvendor/zendframework/zend-mvc/Zend/Mvc/Controller/AbstractActionController.phpS*Rt'Jvendor/zendframework/zend-mvc/Zend/Mvc/InjectApplicationEventInterface.phpS*R3#8vendor/zendframework/zend-mvc/Zend/Mvc/RouteListener.php(S*R( C?vendor/zendframework/zend-mvc/Zend/Mvc/SendResponseListener.php^ S*R^ Za;vendor/zendframework/zend-mvc/Zend/Mvc/DispatchListener.phpwS*Rw#Q?vendor/zendframework/zend-mvc/Zend/Mvc/ApplicationInterface.php3S*R3&2(۶3vendor/zendframework/zend-mvc/Zend/Mvc/MvcEvent.phpf S*Rf yrOvendor/zendframework/zend-mvc/Zend/Mvc/ResponseSender/ConsoleResponseSender.phplS*Rl֬Pvendor/zendframework/zend-mvc/Zend/Mvc/ResponseSender/AbstractResponseSender.phpSS*RS Qvendor/zendframework/zend-mvc/Zend/Mvc/ResponseSender/ResponseSenderInterface.phpS*R7>Kvendor/zendframework/zend-mvc/Zend/Mvc/ResponseSender/SendResponseEvent.phpS*RhLLvendor/zendframework/zend-mvc/Zend/Mvc/ResponseSender/HttpResponseSender.phplS*RlVTvendor/zendframework/zend-mvc/Zend/Mvc/ResponseSender/SimpleStreamResponseSender.phpS*RVvendor/zendframework/zend-mvc/Zend/Mvc/ResponseSender/PhpEnvironmentResponseSender.phpS*RPjMvendor/zendframework/zend-serializer/Zend/Serializer/AdapterPluginManager.phpCS*RCu[vendor/zendframework/zend-serializer/Zend/Serializer/Exception/InvalidArgumentException.phpS*R=30Uvendor/zendframework/zend-serializer/Zend/Serializer/Exception/ExceptionInterface.phpLS*RL'Ԯ)Svendor/zendframework/zend-serializer/Zend/Serializer/Exception/RuntimeException.php~S*R~HZn^vendor/zendframework/zend-serializer/Zend/Serializer/Exception/ExtensionNotLoadedException.phpjS*Rj2ʶHvendor/zendframework/zend-serializer/Zend/Serializer/Adapter/PhpCode.php>S*R>Ovendor/zendframework/zend-serializer/Zend/Serializer/Adapter/AdapterOptions.php{S*R{OIvendor/zendframework/zend-serializer/Zend/Serializer/Adapter/IgBinary.phpS*R`嚶Lvendor/zendframework/zend-serializer/Zend/Serializer/Adapter/WddxOptions.phpS*R"X{Qvendor/zendframework/zend-serializer/Zend/Serializer/Adapter/AdapterInterface.phpS*RzDEvendor/zendframework/zend-serializer/Zend/Serializer/Adapter/Json.phpS*RRSEvendor/zendframework/zend-serializer/Zend/Serializer/Adapter/Wddx.phpOS*RODMvendor/zendframework/zend-serializer/Zend/Serializer/Adapter/PhpSerialize.phpS*R0Tvendor/zendframework/zend-serializer/Zend/Serializer/Adapter/PythonPickleOptions.phpS*Rk5/Hvendor/zendframework/zend-serializer/Zend/Serializer/Adapter/MsgPack.phpS*RN3Pvendor/zendframework/zend-serializer/Zend/Serializer/Adapter/AbstractAdapter.phpS*RTCLvendor/zendframework/zend-serializer/Zend/Serializer/Adapter/JsonOptions.phpS*RMvendor/zendframework/zend-serializer/Zend/Serializer/Adapter/PythonPickle.phpKS*RKCvendor/zendframework/zend-serializer/Zend/Serializer/Serializer.phpS*RI|Ovendor/zendframework/zend-inputfilter/Zend/InputFilter/InputFilterInterface.phpnS*RnPvendor/zendframework/zend-inputfilter/Zend/InputFilter/InputFilterAwareTrait.phpDS*RD@ ڶ]vendor/zendframework/zend-inputfilter/Zend/InputFilter/Exception/InvalidArgumentException.phpS*RଶWvendor/zendframework/zend-inputfilter/Zend/InputFilter/Exception/ExceptionInterface.phpMS*RMYCUvendor/zendframework/zend-inputfilter/Zend/InputFilter/Exception/RuntimeException.phpS*RUKPvendor/zendframework/zend-inputfilter/Zend/InputFilter/CollectionInputFilter.php S*R Ń@vendor/zendframework/zend-inputfilter/Zend/InputFilter/Input.php S*R v;Tvendor/zendframework/zend-inputfilter/Zend/InputFilter/InputFilterAwareInterface.phpS*RƜsWvendor/zendframework/zend-inputfilter/Zend/InputFilter/InputFilterProviderInterface.php}S*R}0MĶFvendor/zendframework/zend-inputfilter/Zend/InputFilter/InputFilter.phpMS*RMkXvendor/zendframework/zend-inputfilter/Zend/InputFilter/UnknownInputsCapableInterface.phpS*RLxEvendor/zendframework/zend-inputfilter/Zend/InputFilter/ArrayInput.phpqS*Rq^NPvendor/zendframework/zend-inputfilter/Zend/InputFilter/EmptyContextInterface.phpS*R) ҡSvendor/zendframework/zend-inputfilter/Zend/InputFilter/InputFilterPluginManager.phpS*RDvendor/zendframework/zend-inputfilter/Zend/InputFilter/FileInput.phpS*R2IJvendor/zendframework/zend-inputfilter/Zend/InputFilter/BaseInputFilter.php S*R 5Qvendor/zendframework/zend-inputfilter/Zend/InputFilter/InputProviderInterface.phpqS*Rq$0FBvendor/zendframework/zend-inputfilter/Zend/InputFilter/Factory.phpS*R+Ivendor/zendframework/zend-inputfilter/Zend/InputFilter/InputInterface.php}S*R}4#Cvendor/zendframework/zend-loader/Zend/Loader/StandardAutoloader.php9S*R9ͦhWPvendor/zendframework/zend-loader/Zend/Loader/Exception/PluginLoaderException.phpS*Rm Ovendor/zendframework/zend-loader/Zend/Loader/Exception/InvalidPathException.phpS*RҶ\vendor/zendframework/zend-loader/Zend/Loader/Exception/MissingResourceNamespaceException.phpS*RUJvendor/zendframework/zend-loader/Zend/Loader/Exception/DomainException.phpS*RЃ:Svendor/zendframework/zend-loader/Zend/Loader/Exception/InvalidArgumentException.phpS*Rת(Lvendor/zendframework/zend-loader/Zend/Loader/Exception/SecurityException.phpS*R=NTMvendor/zendframework/zend-loader/Zend/Loader/Exception/ExceptionInterface.phpHS*RHMaKvendor/zendframework/zend-loader/Zend/Loader/Exception/RuntimeException.phpS*RwQvendor/zendframework/zend-loader/Zend/Loader/Exception/BadMethodCallException.phpS*Ri4Cvendor/zendframework/zend-loader/Zend/Loader/ClassMapAutoloader.phpo S*Ro 8^w>vendor/zendframework/zend-loader/Zend/Loader/SplAutoloader.phpS*RcAvendor/zendframework/zend-loader/Zend/Loader/ModuleAutoloader.phpS*R7CʶCvendor/zendframework/zend-loader/Zend/Loader/PluginClassLocator.php!S*R!-:KBvendor/zendframework/zend-loader/Zend/Loader/PluginClassLoader.phpS*RnAvendor/zendframework/zend-loader/Zend/Loader/ShortNameLocator.phpS*R"Bvendor/zendframework/zend-loader/Zend/Loader/AutoloaderFactory.php S*R h"Mvendor/zendframework/zend-view/Zend/View/Exception/InvalidHelperException.phpxS*Rx6 Fvendor/zendframework/zend-view/Zend/View/Exception/DomainException.phpwS*Rw %Ovendor/zendframework/zend-view/Zend/View/Exception/InvalidArgumentException.phpS*R{)P#Ivendor/zendframework/zend-view/Zend/View/Exception/ExceptionInterface.phpFS*RFGvendor/zendframework/zend-view/Zend/View/Exception/RuntimeException.phpyS*RySMvendor/zendframework/zend-view/Zend/View/Exception/BadMethodCallException.phpS*RxϩEvendor/zendframework/zend-view/Zend/View/Helper/PaginationControl.phpnS*RnAc<vendor/zendframework/zend-view/Zend/View/Helper/BasePath.phpS*R;vendor/zendframework/zend-view/Zend/View/Helper/Partial.phpS*RRc =vendor/zendframework/zend-view/Zend/View/Helper/HeadTitle.php S*R "͢:vendor/zendframework/zend-view/Zend/View/Helper/Layout.phpS*RǙ>vendor/zendframework/zend-view/Zend/View/Helper/HeadScript.phpS*R N>vendor/zendframework/zend-view/Zend/View/Helper/EscapeHtml.phpS*R=vendor/zendframework/zend-view/Zend/View/Helper/ViewModel.php<S*R<V8Qvendor/zendframework/zend-view/Zend/View/Helper/Service/FlashMessengerFactory.phpS*R߶Kvendor/zendframework/zend-view/Zend/View/Helper/Service/IdentityFactory.php'S*R'|aǯ<vendor/zendframework/zend-view/Zend/View/Helper/HtmlList.phpuS*RuvbZ;vendor/zendframework/zend-view/Zend/View/Helper/Doctype.phpS*RX骶=vendor/zendframework/zend-view/Zend/View/Helper/EscapeUrl.phpS*R27vendor/zendframework/zend-view/Zend/View/Helper/Url.phpS*Rd*=vendor/zendframework/zend-view/Zend/View/Helper/EscapeCss.phpS*R=vendor/zendframework/zend-view/Zend/View/Helper/ServerUrl.php5S*R5V| ?vendor/zendframework/zend-view/Zend/View/Helper/PartialLoop.phpCS*RC[Ft_Gvendor/zendframework/zend-view/Zend/View/Helper/AbstractHtmlElement.php'S*R'clp8vendor/zendframework/zend-view/Zend/View/Helper/Json.phpS*R_IGvendor/zendframework/zend-view/Zend/View/Helper/RenderToPlaceholder.phpnS*Rn4Bi<vendor/zendframework/zend-view/Zend/View/Helper/HeadMeta.phpkS*Rk<vendor/zendframework/zend-view/Zend/View/Helper/Identity.phpS*R <vendor/zendframework/zend-view/Zend/View/Helper/HtmlPage.php<S*R<ѧNbBvendor/zendframework/zend-view/Zend/View/Helper/FlashMessenger.phpS*Rr=vendor/zendframework/zend-view/Zend/View/Helper/HtmlFlash.phpS*Ri99vendor/zendframework/zend-view/Zend/View/Helper/Cycle.phpS*R5fCvendor/zendframework/zend-view/Zend/View/Helper/Navigation/Menu.php$S*R$'Jvendor/zendframework/zend-view/Zend/View/Helper/Navigation/Breadcrumbs.phpX S*RX <Lvendor/zendframework/zend-view/Zend/View/Helper/Navigation/PluginManager.phpS*RUӶSvendor/zendframework/zend-view/Zend/View/Helper/Navigation/Listener/AclListener.php S*R DoFvendor/zendframework/zend-view/Zend/View/Helper/Navigation/Sitemap.phpS*RX`cDvendor/zendframework/zend-view/Zend/View/Helper/Navigation/Links.php!S*R!ENvendor/zendframework/zend-view/Zend/View/Helper/Navigation/HelperInterface.phpS*Rz=:8Mvendor/zendframework/zend-view/Zend/View/Helper/Navigation/AbstractHelper.phpA%S*RA%wKn<vendor/zendframework/zend-view/Zend/View/Helper/EscapeJs.phpS*R4 g?vendor/zendframework/zend-view/Zend/View/Helper/Placeholder.phpS*RC0?vendor/zendframework/zend-view/Zend/View/Helper/DeclareVars.phpS*Rl`>vendor/zendframework/zend-view/Zend/View/Helper/HtmlObject.phpnS*RnEV>vendor/zendframework/zend-view/Zend/View/Helper/Navigation.php S*R }2bCvendor/zendframework/zend-view/Zend/View/Helper/HelperInterface.phpS*RAvendor/zendframework/zend-view/Zend/View/Helper/HtmlQuicktime.phpS*RC0Bvendor/zendframework/zend-view/Zend/View/Helper/AbstractHelper.phpUS*RU[ @vendor/zendframework/zend-view/Zend/View/Helper/InlineScript.phpMS*RMD2۶Dvendor/zendframework/zend-view/Zend/View/Helper/RenderChildModel.phpS*RL<vendor/zendframework/zend-view/Zend/View/Helper/HeadLink.phpS*R:aM=vendor/zendframework/zend-view/Zend/View/Helper/HeadStyle.php>S*R>d@<vendor/zendframework/zend-view/Zend/View/Helper/Gravatar.php S*R u~q\Bvendor/zendframework/zend-view/Zend/View/Helper/EscapeHtmlAttr.phpS*R4[vendor/zendframework/zend-view/Zend/View/Helper/Placeholder/Container/AbstractContainer.php S*R )8nն\vendor/zendframework/zend-view/Zend/View/Helper/Placeholder/Container/AbstractStandalone.phpS*R)ӶIvendor/zendframework/zend-view/Zend/View/Helper/Placeholder/Container.phpgS*Rg7lȪHvendor/zendframework/zend-view/Zend/View/Helper/Placeholder/Registry.php~S*R~B"KJvendor/zendframework/zend-view/Zend/View/Helper/Escaper/AbstractHelper.phpzS*Rz6vendor/zendframework/zend-view/Zend/View/ViewEvent.php S*R T@vendor/zendframework/zend-view/Zend/View/HelperPluginManager.php( S*R( <vendor/zendframework/zend-view/Zend/View/Model/JsonModel.phppS*Rp$]3Avendor/zendframework/zend-view/Zend/View/Model/ModelInterface.phpHS*RHv*<vendor/zendframework/zend-view/Zend/View/Model/FeedModel.php2S*R2Z7<vendor/zendframework/zend-view/Zend/View/Model/ViewModel.phpJS*RJ::ԶJvendor/zendframework/zend-view/Zend/View/Model/ClearableModelInterface.phpS*RxvӶ?vendor/zendframework/zend-view/Zend/View/Model/ConsoleModel.phpS*RiBvendor/zendframework/zend-view/Zend/View/Strategy/JsonStrategy.phpS*RI<Bvendor/zendframework/zend-view/Zend/View/Strategy/FeedStrategy.phpaS*RaIvendor/zendframework/zend-view/Zend/View/Strategy/PhpRendererStrategy.phpS*Rtĥ6vendor/zendframework/zend-view/Zend/View/Variables.phpS*Rl $!Gvendor/zendframework/zend-view/Zend/View/Renderer/RendererInterface.php S*R +1UKvendor/zendframework/zend-view/Zend/View/Renderer/TreeRendererInterface.phpkS*Rk6Bvendor/zendframework/zend-view/Zend/View/Renderer/FeedRenderer.phpS*RIҶBvendor/zendframework/zend-view/Zend/View/Renderer/JsonRenderer.php S*R OC6Evendor/zendframework/zend-view/Zend/View/Renderer/ConsoleRenderer.phpYS*RYHTBAvendor/zendframework/zend-view/Zend/View/Renderer/PhpRenderer.php=S*R=bLGvendor/zendframework/zend-view/Zend/View/Resolver/AggregateResolver.phpS*RCYGGvendor/zendframework/zend-view/Zend/View/Resolver/TemplatePathStack.phpS*RhGvendor/zendframework/zend-view/Zend/View/Resolver/ResolverInterface.phpS*RmtIvendor/zendframework/zend-view/Zend/View/Resolver/TemplateMapResolver.phpDS*RD1vendor/zendframework/zend-view/Zend/View/View.php S*R 3vendor/zendframework/zend-view/Zend/View/Stream.phpFS*RFރĶ9vendor/zendframework/zend-filter/Zend/Filter/BaseName.phpS*RDԶDvendor/zendframework/zend-filter/Zend/Filter/FilterPluginManager.php S*R /=vendor/zendframework/zend-filter/Zend/Filter/HtmlEntities.php S*R x@vendor/zendframework/zend-filter/Zend/Filter/FilterInterface.php\S*R\WUJvendor/zendframework/zend-filter/Zend/Filter/Exception/DomainException.phpyS*RyqSvendor/zendframework/zend-filter/Zend/Filter/Exception/InvalidArgumentException.phpS*RZMvendor/zendframework/zend-filter/Zend/Filter/Exception/ExceptionInterface.phpIS*RIGKvendor/zendframework/zend-filter/Zend/Filter/Exception/RuntimeException.php{S*R{:lFQvendor/zendframework/zend-filter/Zend/Filter/Exception/BadMethodCallException.phpS*R^,gVvendor/zendframework/zend-filter/Zend/Filter/Exception/ExtensionNotLoadedException.phpgS*Rgmeƶ5vendor/zendframework/zend-filter/Zend/Filter/Null.php S*R Sf9vendor/zendframework/zend-filter/Zend/Filter/Callback.phpMS*RMط;vendor/zendframework/zend-filter/Zend/Filter/StringTrim.phpqS*Rq[?>vendor/zendframework/zend-filter/Zend/Filter/StringToUpper.php4S*R4 :ٶ=vendor/zendframework/zend-filter/Zend/Filter/UriNormalize.phpS*Rܶ4vendor/zendframework/zend-filter/Zend/Filter/Dir.phpS*R0%?vendor/zendframework/zend-filter/Zend/Filter/AbstractFilter.phpS*R$"Bvendor/zendframework/zend-filter/Zend/Filter/DateTimeFormatter.php/S*R/6Ȟ@vendor/zendframework/zend-filter/Zend/Filter/Encrypt/Openssl.phpS*R8s^Dvendor/zendframework/zend-filter/Zend/Filter/Encrypt/BlockCipher.php{S*R{gSUvendor/zendframework/zend-filter/Zend/Filter/Encrypt/EncryptionAlgorithmInterface.phpS*R۴r >vendor/zendframework/zend-filter/Zend/Filter/StripNewlines.phpS*R439vendor/zendframework/zend-filter/Zend/Filter/Compress.php; S*R; IT:vendor/zendframework/zend-filter/Zend/Filter/StripTags.phpS*Rʽ<vendor/zendframework/zend-filter/Zend/Filter/PregReplace.phpS*RĶ@vendor/zendframework/zend-filter/Zend/Filter/AbstractUnicode.php^S*R^4<?vendor/zendframework/zend-filter/Zend/Filter/File/LowerCase.phptS*RtH:vendor/zendframework/zend-filter/Zend/Filter/Inflector.phpS*RT8vendor/zendframework/zend-filter/Zend/Filter/Boolean.phpS*R`4vendor/zendframework/zend-filter/Zend/Filter/Int.phpS*RE`;vendor/zendframework/zend-filter/Zend/Filter/Decompress.phpS*RѴ7vendor/zendframework/zend-filter/Zend/Filter/Digits.phplS*Rl Jvendor/zendframework/zend-filter/Zend/Filter/Word/SeparatorToSeparator.php=S*R=XKvendor/zendframework/zend-filter/Zend/Filter/Word/UnderscoreToCamelCase.phpS*R 5Q7Gvendor/zendframework/zend-filter/Zend/Filter/Word/AbstractSeparator.phpS*RLJvendor/zendframework/zend-filter/Zend/Filter/Word/SeparatorToCamelCase.phpKS*RKٶEvendor/zendframework/zend-filter/Zend/Filter/Word/CamelCaseToDash.phpS*R\Evendor/zendframework/zend-filter/Zend/Filter/Word/SeparatorToDash.phpS*R\Kvendor/zendframework/zend-filter/Zend/Filter/Word/CamelCaseToUnderscore.phpS*R>fgKvendor/zendframework/zend-filter/Zend/Filter/Word/UnderscoreToSeparator.phpS*RzdFvendor/zendframework/zend-filter/Zend/Filter/Word/DashToUnderscore.phpS*R1|Evendor/zendframework/zend-filter/Zend/Filter/Word/DashToSeparator.phpS*R{CFvendor/zendframework/zend-filter/Zend/Filter/Word/UnderscoreToDash.phpS*R .0Evendor/zendframework/zend-filter/Zend/Filter/Word/DashToCamelCase.phpS*R,.Jvendor/zendframework/zend-filter/Zend/Filter/Word/CamelCaseToSeparator.phpPS*RP5 8vendor/zendframework/zend-filter/Zend/Filter/Encrypt.phpfS*RfA>vendor/zendframework/zend-filter/Zend/Filter/StringToLower.php4S*R4R9vendor/zendframework/zend-filter/Zend/Filter/RealPath.phpS*RAcr=vendor/zendframework/zend-filter/Zend/Filter/StaticFilter.php{S*R{ qAܶ=vendor/zendframework/zend-filter/Zend/Filter/Compress/Lzf.phpS*RwK=vendor/zendframework/zend-filter/Zend/Filter/Compress/Tar.php S*R žuVvendor/zendframework/zend-filter/Zend/Filter/Compress/AbstractCompressionAlgorithm.phpS*RY)o=vendor/zendframework/zend-filter/Zend/Filter/Compress/Zip.phpS*RԶWvendor/zendframework/zend-filter/Zend/Filter/Compress/CompressionAlgorithmInterface.phpS*R$=vendor/zendframework/zend-filter/Zend/Filter/Compress/Bz2.phpYS*RYv$=vendor/zendframework/zend-filter/Zend/Filter/Compress/Rar.php S*R 3ٶ@vendor/zendframework/zend-filter/Zend/Filter/Compress/Snappy.phpS*R^+<vendor/zendframework/zend-filter/Zend/Filter/Compress/Gz.php S*R P;>vendor/zendframework/zend-stdlib/Zend/Stdlib/PriorityQueue.php2 S*R2 NZ"<vendor/zendframework/zend-stdlib/Zend/Stdlib/StringUtils.phps S*Rs vZSvendor/zendframework/zend-stdlib/Zend/Stdlib/Exception/InvalidCallbackException.phpS*Rn[Jvendor/zendframework/zend-stdlib/Zend/Stdlib/Exception/DomainException.phpyS*Ry {;Svendor/zendframework/zend-stdlib/Zend/Stdlib/Exception/InvalidArgumentException.phpS*R5BIvendor/zendframework/zend-stdlib/Zend/Stdlib/Exception/LogicException.phpwS*Rw*߶Mvendor/zendframework/zend-stdlib/Zend/Stdlib/Exception/ExceptionInterface.phpIS*RI>wKvendor/zendframework/zend-stdlib/Zend/Stdlib/Exception/RuntimeException.php{S*R{/=Qvendor/zendframework/zend-stdlib/Zend/Stdlib/Exception/BadMethodCallException.phpS*R9d~Vvendor/zendframework/zend-stdlib/Zend/Stdlib/Exception/ExtensionNotLoadedException.phpgS*Rg?<ж9vendor/zendframework/zend-stdlib/Zend/Stdlib/DateTime.php+S*R+';vendor/zendframework/zend-stdlib/Zend/Stdlib/ArrayStack.phpS*Rm9vendor/zendframework/zend-stdlib/Zend/Stdlib/SplQueue.phpS*RY ҶAvendor/zendframework/zend-stdlib/Zend/Stdlib/RequestInterface.phpVS*RVtAvendor/zendframework/zend-stdlib/Zend/Stdlib/SplPriorityQueue.phpS*R?D9vendor/zendframework/zend-stdlib/Zend/Stdlib/Response.php^S*R^⹠Gvendor/zendframework/zend-stdlib/Zend/Stdlib/InitializableInterface.php[S*R[g>8vendor/zendframework/zend-stdlib/Zend/Stdlib/Message.phpS*R¨Ivendor/zendframework/zend-stdlib/Zend/Stdlib/ParameterObjectInterface.phpS*RBN@vendor/zendframework/zend-stdlib/Zend/Stdlib/CallbackHandler.phpR S*RR ];5vendor/zendframework/zend-stdlib/Zend/Stdlib/Glob.php S*R F֕@vendor/zendframework/zend-stdlib/Zend/Stdlib/AbstractOptions.phptS*RtH<vendor/zendframework/zend-stdlib/Zend/Stdlib/ArrayObject.phpUS*RUSo~RVvendor/zendframework/zend-stdlib/Zend/Stdlib/ArrayObject/PhpReferenceCompatibility.php=S*R=SpSvendor/zendframework/zend-stdlib/Zend/Stdlib/ArrayObject/PhpLegacyCompatibility.php5S*R59CGvendor/zendframework/zend-stdlib/Zend/Stdlib/compatibility/autoload.phpS*R`VDvendor/zendframework/zend-stdlib/Zend/Stdlib/StringWrapper/Iconv.phpS S*RS VTvendor/zendframework/zend-stdlib/Zend/Stdlib/StringWrapper/AbstractStringWrapper.phpS*RCvendor/zendframework/zend-stdlib/Zend/Stdlib/StringWrapper/Intl.phpS*R|Evendor/zendframework/zend-stdlib/Zend/Stdlib/StringWrapper/Native.phpwS*RwUvendor/zendframework/zend-stdlib/Zend/Stdlib/StringWrapper/StringWrapperInterface.phpS*RGvendor/zendframework/zend-stdlib/Zend/Stdlib/StringWrapper/MbString.phpS*R Uvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Aggregate/AggregateHydrator.phpS*RôPvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Aggregate/HydrateEvent.phpS*RQyPvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Aggregate/ExtractEvent.php_S*R_b{ٶTvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Aggregate/HydratorListener.phpS*R|3mJvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/AbstractHydrator.phpS*R|Pvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Filter/FilterInterface.phpoS*Ro;Rvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Filter/MethodMatchFilter.phpS*R* Ivendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Filter/IsFilter.php S*R tN Jvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Filter/GetFilter.php"S*R"4HXvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Filter/NumberOfParameterFilter.phpS*RPvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Filter/FilterComposite.php S*R Jvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Filter/HasFilter.php"S*R"豉kYvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Filter/OptionalParametersFilter.php S*R Xvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Filter/FilterProviderInterface.phpqS*Rq,!Ovendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/HydratorPluginManager.phpS*RF>1Rvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/HydratorOptionsInterface.phptS*RtYFvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/ClassMethods.phpS*Ry |Pvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/HydratorAwareInterface.phpS*RPRvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Strategy/DefaultStrategy.phpS*R(Tvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Strategy/StrategyInterface.phpS*RHWvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Strategy/SerializableStrategy.phpS*R~7߶Rvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Strategy/ClosureStrategy.phpWS*RW?> Dvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/Reflection.phpS*Rb61Hvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/ObjectProperty.php`S*R`Kvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/ArraySerializable.php S*R GRvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/StrategyEnabledInterface.php3S*R3Kvendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/HydratorInterface.phpS*RWy$9vendor/zendframework/zend-stdlib/Zend/Stdlib/SplStack.phpS*RK8vendor/zendframework/zend-stdlib/Zend/Stdlib/Request.php\S*R\J=vendor/zendframework/zend-stdlib/Zend/Stdlib/ErrorHandler.phpS*RuBvendor/zendframework/zend-stdlib/Zend/Stdlib/ResponseInterface.phpWS*RW^;vendor/zendframework/zend-stdlib/Zend/Stdlib/ArrayUtils.php S*R $pFvendor/zendframework/zend-stdlib/Zend/Stdlib/DispatchableInterface.phpS*RWDvendor/zendframework/zend-stdlib/Zend/Stdlib/ParametersInterface.phpS*RoS7;vendor/zendframework/zend-stdlib/Zend/Stdlib/Parameters.phpS*RPAvendor/zendframework/zend-stdlib/Zend/Stdlib/MessageInterface.phpS*R JKvendor/zendframework/zend-stdlib/Zend/Stdlib/ArraySerializableInterface.phpS*R(w Gvendor/zendframework/zend-servicemanager/Zend/ServiceManager/Config.phpU S*RU LVvendor/zendframework/zend-servicemanager/Zend/ServiceManager/AbstractPluginManager.phpv S*Rv mfvendor/zendframework/zend-servicemanager/Zend/ServiceManager/Exception/InvalidServiceNameException.phpoS*Roz-tevendor/zendframework/zend-servicemanager/Zend/ServiceManager/Exception/ServiceNotCreatedException.phpnS*Rn0cvendor/zendframework/zend-servicemanager/Zend/ServiceManager/Exception/InvalidArgumentException.phpS*RY;cvendor/zendframework/zend-servicemanager/Zend/ServiceManager/Exception/ServiceNotFoundException.phptS*Rt&^kvendor/zendframework/zend-servicemanager/Zend/ServiceManager/Exception/CircularDependencyFoundException.phptS*Rtd^]vendor/zendframework/zend-servicemanager/Zend/ServiceManager/Exception/ExceptionInterface.phpQS*RQ[vendor/zendframework/zend-servicemanager/Zend/ServiceManager/Exception/RuntimeException.phpS*R,"Xvendor/zendframework/zend-servicemanager/Zend/ServiceManager/ServiceLocatorInterface.phpS*RlYvendor/zendframework/zend-servicemanager/Zend/ServiceManager/ServiceLocatorAwareTrait.phphS*Rhx]vendor/zendframework/zend-servicemanager/Zend/ServiceManager/ServiceLocatorAwareInterface.phpS*Re޶Ovendor/zendframework/zend-servicemanager/Zend/ServiceManager/ServiceManager.phpKHS*RKHK]vendor/zendframework/zend-servicemanager/Zend/ServiceManager/ServiceManagerAwareInterface.phpS*RhdUvendor/zendframework/zend-servicemanager/Zend/ServiceManager/InitializerInterface.phpS*RoٶPvendor/zendframework/zend-servicemanager/Zend/ServiceManager/ConfigInterface.phpS*RK(Qvendor/zendframework/zend-servicemanager/Zend/ServiceManager/FactoryInterface.phpS*R"YfYvendor/zendframework/zend-servicemanager/Zend/ServiceManager/AbstractFactoryInterface.phpS*R!'`vendor/zendframework/zend-servicemanager/Zend/ServiceManager/MutableCreationOptionsInterface.phpS*R XHXvendor/zendframework/zend-servicemanager/Zend/ServiceManager/Di/DiServiceInitializer.phpS*Rx\vendor/zendframework/zend-servicemanager/Zend/ServiceManager/Di/DiAbstractServiceFactory.phpS*RbP"Tvendor/zendframework/zend-servicemanager/Zend/ServiceManager/Di/DiServiceFactory.phpS*RĥӶZvendor/zendframework/zend-servicemanager/Zend/ServiceManager/Di/DiInstanceManagerProxy.phpS*R.DضYvendor/zendframework/zend-servicemanager/Zend/ServiceManager/Proxy/LazyServiceFactory.php S*R ]ȶ`vendor/zendframework/zend-servicemanager/Zend/ServiceManager/Proxy/LazyServiceFactoryFactory.phpS*R邶Zvendor/zendframework/zend-servicemanager/Zend/ServiceManager/DelegatorFactoryInterface.phpS*R"M>vendor/zendframework/zend-form/Zend/Form/FieldsetInterface.phpS*R/0M5vendor/zendframework/zend-form/Zend/Form/Fieldset.phpA!S*RA!ǠR<Fvendor/zendframework/zend-form/Zend/Form/FormFactoryAwareInterface.phpvS*RvNvendor/zendframework/zend-form/Zend/Form/Exception/InvalidElementException.phphS*RhXCLFvendor/zendframework/zend-form/Zend/Form/Exception/DomainException.phpvS*Rv+ -Ovendor/zendframework/zend-form/Zend/Form/Exception/InvalidArgumentException.phpS*RAnkOvendor/zendframework/zend-form/Zend/Form/Exception/UnexpectedValueException.phpS*RIvendor/zendframework/zend-form/Zend/Form/Exception/ExceptionInterface.phpFS*RFꡧMvendor/zendframework/zend-form/Zend/Form/Exception/BadMethodCallException.phpS*RERvendor/zendframework/zend-form/Zend/Form/Exception/ExtensionNotLoadedException.phpcS*RcqRxGvendor/zendframework/zend-form/Zend/Form/FormAbstractServiceFactory.php[ S*R[ XN:vendor/zendframework/zend-form/Zend/Form/FormInterface.phpS*R` "Jvendor/zendframework/zend-form/Zend/Form/FieldsetPrepareAwareInterface.phpkS*RkwSF1vendor/zendframework/zend-form/Zend/Form/Form.php0S*R0 YBvendor/zendframework/zend-form/Zend/Form/FormFactoryAwareTrait.phpS*RNMvendor/zendframework/zend-form/Zend/Form/ElementAttributeRemovalInterface.phpS*Rd'˦Bvendor/zendframework/zend-form/Zend/Form/View/Helper/FormMonth.phpS*RrԶDvendor/zendframework/zend-form/Zend/Form/View/Helper/FormElement.php S*R EZAvendor/zendframework/zend-form/Zend/Form/View/Helper/FormTime.phpS*RlJvendor/zendframework/zend-form/Zend/Form/View/Helper/FormDateTimeLocal.phpS*R?Bvendor/zendframework/zend-form/Zend/Form/View/Helper/FormInput.php.S*R.7KCvendor/zendframework/zend-form/Zend/Form/View/Helper/FormSelect.phpS*Rc)Avendor/zendframework/zend-form/Zend/Form/View/Helper/FormText.phpS*RM(ǶCvendor/zendframework/zend-form/Zend/Form/View/Helper/FormSearch.phpS*RtDvendor/zendframework/zend-form/Zend/Form/View/Helper/FormCaptcha.phpS*RU!Bvendor/zendframework/zend-form/Zend/Form/View/Helper/FormRange.phpS*RaU=vendor/zendframework/zend-form/Zend/Form/View/Helper/Form.phpfS*RfBvendor/zendframework/zend-form/Zend/Form/View/Helper/FormReset.phpS*R#SCvendor/zendframework/zend-form/Zend/Form/View/Helper/FormButton.phpQ S*RQ IBvendor/zendframework/zend-form/Zend/Form/View/Helper/FormEmail.phpS*RmD ֶ@vendor/zendframework/zend-form/Zend/Form/View/Helper/FormRow.phpYS*RYֶCvendor/zendframework/zend-form/Zend/Form/View/Helper/FormSubmit.phpS*R9^Evendor/zendframework/zend-form/Zend/Form/View/Helper/FormDateTime.phpS*R0bKvendor/zendframework/zend-form/Zend/Form/View/Helper/FormDateTimeSelect.php>S*R>iHvendor/zendframework/zend-form/Zend/Form/View/Helper/FormMonthSelect.phpS*R$Bvendor/zendframework/zend-form/Zend/Form/View/Helper/FormColor.phptS*RtcJJvendor/zendframework/zend-form/Zend/Form/View/Helper/FormElementErrors.php S*R U1}Cvendor/zendframework/zend-form/Zend/Form/View/Helper/FormNumber.phpS*RBvendor/zendframework/zend-form/Zend/Form/View/Helper/FormImage.phpS*RZGvendor/zendframework/zend-form/Zend/Form/View/Helper/Captcha/Figlet.phpS*RgOJvendor/zendframework/zend-form/Zend/Form/View/Helper/Captcha/ReCaptcha.php S*R qMvendor/zendframework/zend-form/Zend/Form/View/Helper/Captcha/AbstractWord.php S*R u<Fvendor/zendframework/zend-form/Zend/Form/View/Helper/Captcha/Image.phpS*R(OEvendor/zendframework/zend-form/Zend/Form/View/Helper/Captcha/Dumb.phpS*R/]Cvendor/zendframework/zend-form/Zend/Form/View/Helper/FormHidden.php9S*R9Zc#?Gvendor/zendframework/zend-form/Zend/Form/View/Helper/FormCollection.php S*R G׶Evendor/zendframework/zend-form/Zend/Form/View/Helper/FormCheckbox.phpLS*RLbCֶUvendor/zendframework/zend-form/Zend/Form/View/Helper/File/FormFileSessionProgress.phpS*R*~Y<Qvendor/zendframework/zend-form/Zend/Form/View/Helper/File/FormFileApcProgress.phpS*RqgTvendor/zendframework/zend-form/Zend/Form/View/Helper/File/FormFileUploadProgress.phpS*RצMJvendor/zendframework/zend-form/Zend/Form/View/Helper/FormMultiCheckbox.phpS*RUZEvendor/zendframework/zend-form/Zend/Form/View/Helper/FormPassword.phpS*RGvendor/zendframework/zend-form/Zend/Form/View/Helper/FormDateSelect.phpS*RݿAvendor/zendframework/zend-form/Zend/Form/View/Helper/FormWeek.phpS*R{R߶Gvendor/zendframework/zend-form/Zend/Form/View/Helper/AbstractHelper.phpS*R/* Evendor/zendframework/zend-form/Zend/Form/View/Helper/FormTextarea.php"S*R"S{]gBvendor/zendframework/zend-form/Zend/Form/View/Helper/FormLabel.php S*R g̶Avendor/zendframework/zend-form/Zend/Form/View/Helper/FormDate.phpS*R6RBvendor/zendframework/zend-form/Zend/Form/View/Helper/FormRadio.php S*R @vendor/zendframework/zend-form/Zend/Form/View/Helper/FormTel.phpS*Rg4Avendor/zendframework/zend-form/Zend/Form/View/Helper/FormFile.phpS*RN@vendor/zendframework/zend-form/Zend/Form/View/Helper/FormUrl.phpS*Rg>vendor/zendframework/zend-form/Zend/Form/View/HelperConfig.php] S*R] ?vendor/zendframework/zend-form/Zend/Form/FormElementManager.php] S*R] 4vendor/zendframework/zend-form/Zend/Form/Element.php S*R Dޏ;vendor/zendframework/zend-form/Zend/Form/Element/Hidden.phpS*R*?C9vendor/zendframework/zend-form/Zend/Form/Element/Week.phpS*RwCb@vendor/zendframework/zend-form/Zend/Form/Element/MonthSelect.phpS*Rbz=vendor/zendframework/zend-form/Zend/Form/Element/DateTime.php S*R J9vendor/zendframework/zend-form/Zend/Form/Element/Csrf.php$S*R$g2xBvendor/zendframework/zend-form/Zend/Form/Element/MultiCheckbox.phpS*R7`8Cvendor/zendframework/zend-form/Zend/Form/Element/DateTimeSelect.phpS*RHI9vendor/zendframework/zend-form/Zend/Form/Element/Text.phpS*Rݶ9vendor/zendframework/zend-form/Zend/Form/Element/Date.phpS*R(+%8vendor/zendframework/zend-form/Zend/Form/Element/Url.phpS*R==vendor/zendframework/zend-form/Zend/Form/Element/Checkbox.phpnS*Rn\Ŷ;vendor/zendframework/zend-form/Zend/Form/Element/Button.phpS*R޶9vendor/zendframework/zend-form/Zend/Form/Element/Time.phpS*R}9vendor/zendframework/zend-form/Zend/Form/Element/File.phpIS*RI2!(Q:vendor/zendframework/zend-form/Zend/Form/Element/Image.phpS*R'=vendor/zendframework/zend-form/Zend/Form/Element/Password.phpTS*RTּ|:vendor/zendframework/zend-form/Zend/Form/Element/Range.php S*R :ֶ;vendor/zendframework/zend-form/Zend/Form/Element/Submit.phpS*R_Bvendor/zendframework/zend-form/Zend/Form/Element/DateTimeLocal.phpS*R5H<vendor/zendframework/zend-form/Zend/Form/Element/Captcha.php-S*R-:vendor/zendframework/zend-form/Zend/Form/Element/Email.phpS*R>C:vendor/zendframework/zend-form/Zend/Form/Element/Radio.phpS*REp!?vendor/zendframework/zend-form/Zend/Form/Element/Collection.php1S*R1 Lm:vendor/zendframework/zend-form/Zend/Form/Element/Month.phpS*RA ;vendor/zendframework/zend-form/Zend/Form/Element/Select.phpw S*Rw ⴹ?vendor/zendframework/zend-form/Zend/Form/Element/DateSelect.phpS*R@:vendor/zendframework/zend-form/Zend/Form/Element/Color.phpS*RY=vendor/zendframework/zend-form/Zend/Form/Element/Textarea.phpS*Ra{;vendor/zendframework/zend-form/Zend/Form/Element/Number.phpFS*RFvendor/zendframework/zend-form/Zend/Form/Annotation/Object.phpS*Rr϶Pvendor/zendframework/zend-form/Zend/Form/Annotation/AbstractStringAnnotation.phpS*RGWIvendor/zendframework/zend-form/Zend/Form/Annotation/AnnotationBuilder.phpS*RtsDvendor/zendframework/zend-form/Zend/Form/Annotation/ErrorMessage.phpS*RPWvendor/zendframework/zend-form/Zend/Form/Annotation/AbstractArrayOrStringAnnotation.phpS*RQ=Fvendor/zendframework/zend-form/Zend/Form/Annotation/ComposedObject.phpS*R:ÉAvendor/zendframework/zend-form/Zend/Form/Annotation/Validator.phpS*R徛Ŷ@vendor/zendframework/zend-form/Zend/Form/Annotation/Required.phpS*Ry@vendor/zendframework/zend-form/Zend/Form/Annotation/Hydrator.phpS*RQ*cRvendor/zendframework/zend-form/Zend/Form/Annotation/ElementAnnotationsListener.phpYS*RYʶ>vendor/zendframework/zend-form/Zend/Form/Annotation/Filter.phpS*Ri6=vendor/zendframework/zend-form/Zend/Form/Annotation/Flags.phpS*RcT4vendor/zendframework/zend-form/Zend/Form/Factory.php'S*R'Ŏ#[=vendor/zendframework/zend-form/Zend/Form/ElementInterface.phpjS*Rj%>Ivendor/zendframework/zend-form/Zend/Form/ElementPrepareAwareInterface.php|S*R|0ZOVQ:vendor/zendframework/zend-text/Zend/Text/Figlet/Figlet.phpAS*RAɥWVvendor/zendframework/zend-text/Zend/Text/Figlet/Exception/InvalidArgumentException.phpS*RRVvendor/zendframework/zend-text/Zend/Text/Figlet/Exception/UnexpectedValueException.phpS*R Pvendor/zendframework/zend-text/Zend/Text/Figlet/Exception/ExceptionInterface.phpS*RyfNvendor/zendframework/zend-text/Zend/Text/Figlet/Exception/RuntimeException.phpS*R\Kvendor/zendframework/zend-text/Zend/Text/Exception/OutOfBoundsException.phpS*R1lɶOvendor/zendframework/zend-text/Zend/Text/Exception/InvalidArgumentException.phpS*R Hvendor/zendframework/zend-text/Zend/Text/Exception/OverflowException.phpS*RbOvendor/zendframework/zend-text/Zend/Text/Exception/UnexpectedValueException.phpS*Rj=Ivendor/zendframework/zend-text/Zend/Text/Exception/ExceptionInterface.phpFS*RFgGvendor/zendframework/zend-text/Zend/Text/Exception/RuntimeException.phpxS*Rxa͕Qvendor/zendframework/zend-text/Zend/Text/Table/Exception/OutOfBoundsException.phpS*RpEUvendor/zendframework/zend-text/Zend/Text/Table/Exception/InvalidArgumentException.phpS*RbgNvendor/zendframework/zend-text/Zend/Text/Table/Exception/OverflowException.phpS*RA̶Vvendor/zendframework/zend-text/Zend/Text/Table/Exception/InvalidDecoratorException.phpS*RDڶUvendor/zendframework/zend-text/Zend/Text/Table/Exception/UnexpectedValueException.phpS*ROvendor/zendframework/zend-text/Zend/Text/Table/Exception/ExceptionInterface.phpS*Rʡ9vendor/zendframework/zend-text/Zend/Text/Table/Column.phpy S*Ry Zb[Cvendor/zendframework/zend-text/Zend/Text/Table/DecoratorManager.phpS*RY#aDvendor/zendframework/zend-text/Zend/Text/Table/Decorator/Unicode.phpaS*Ra24DOvendor/zendframework/zend-text/Zend/Text/Table/Decorator/DecoratorInterface.phpS*RBvendor/zendframework/zend-text/Zend/Text/Table/Decorator/Ascii.phpS*RuBvendor/zendframework/zend-text/Zend/Text/Table/Decorator/Blank.phpS*RI\^8vendor/zendframework/zend-text/Zend/Text/Table/Table.php#S*R#5q϶6vendor/zendframework/zend-text/Zend/Text/Table/Row.php S*R pJHvendor/zendframework/zend-console/Zend/Console/Charset/AsciiExtended.php~S*R~6цDvendor/zendframework/zend-console/Zend/Console/Charset/Utf8Heavy.phpS*R&@vendor/zendframework/zend-console/Zend/Console/Charset/DECSG.phpS*R8yKvendor/zendframework/zend-console/Zend/Console/Charset/CharsetInterface.phpFS*RFIu?vendor/zendframework/zend-console/Zend/Console/Charset/Utf8.php\S*R\n#.@vendor/zendframework/zend-console/Zend/Console/Charset/Ascii.php+S*R+-7Uvendor/zendframework/zend-console/Zend/Console/Exception/InvalidArgumentException.phpS*RiSOvendor/zendframework/zend-console/Zend/Console/Exception/ExceptionInterface.phpJS*RJYYMvendor/zendframework/zend-console/Zend/Console/Exception/RuntimeException.php;S*R;]ڶSvendor/zendframework/zend-console/Zend/Console/Exception/BadMethodCallException.phpS*RHvendor/zendframework/zend-console/Zend/Console/Prompt/AbstractPrompt.phpS*RSI>vendor/zendframework/zend-console/Zend/Console/Prompt/Char.phpGS*RGqAvendor/zendframework/zend-console/Zend/Console/Prompt/Confirm.php2S*R2pڶIvendor/zendframework/zend-console/Zend/Console/Prompt/PromptInterface.phpS*R2;O>vendor/zendframework/zend-console/Zend/Console/Prompt/Line.php^S*R^6l[@vendor/zendframework/zend-console/Zend/Console/Prompt/Select.phpS*Rӑ6@vendor/zendframework/zend-console/Zend/Console/Prompt/Number.php S*R t ;vendor/zendframework/zend-console/Zend/Console/Response.phpS*Rt0Ivendor/zendframework/zend-console/Zend/Console/Adapter/WindowsAnsicon.php S*R KgKvendor/zendframework/zend-console/Zend/Console/Adapter/AdapterInterface.php1S*R1?iBvendor/zendframework/zend-console/Zend/Console/Adapter/Virtual.phpS*R@vendor/zendframework/zend-console/Zend/Console/Adapter/Posix.phpS*R߅Jvendor/zendframework/zend-console/Zend/Console/Adapter/AbstractAdapter.phpS*RSHBvendor/zendframework/zend-console/Zend/Console/Adapter/Windows.phpS*R;۞۶Avendor/zendframework/zend-console/Zend/Console/ColorInterface.phpS*R|:9vendor/zendframework/zend-console/Zend/Console/Getopt.phpp5S*Rp5>UAvendor/zendframework/zend-console/Zend/Console/Color/Xterm256.phpS*RB :vendor/zendframework/zend-console/Zend/Console/Console.php S*R ɾ:vendor/zendframework/zend-console/Zend/Console/Request.phphS*RhZͣOvendor/zendframework/zend-eventmanager/Zend/EventManager/ResponseCollection.phpS*R~ T_vendor/zendframework/zend-eventmanager/Zend/EventManager/Exception/InvalidCallbackException.phpS*R@֏¶Vvendor/zendframework/zend-eventmanager/Zend/EventManager/Exception/DomainException.phpS*Rų1_vendor/zendframework/zend-eventmanager/Zend/EventManager/Exception/InvalidArgumentException.phpS*RxhYvendor/zendframework/zend-eventmanager/Zend/EventManager/Exception/ExceptionInterface.phpOS*ROq!Vvendor/zendframework/zend-eventmanager/Zend/EventManager/AbstractListenerAggregate.phpLS*RLG!!Svendor/zendframework/zend-eventmanager/Zend/EventManager/Filter/FilterInterface.php~S*R~8ERvendor/zendframework/zend-eventmanager/Zend/EventManager/Filter/FilterIterator.phpS*RGӓoSvendor/zendframework/zend-eventmanager/Zend/EventManager/ListenerAggregateTrait.phpS*RR]vendor/zendframework/zend-eventmanager/Zend/EventManager/SharedEventManagerAwareInterface.phpS*RWԦWvendor/zendframework/zend-eventmanager/Zend/EventManager/EventManagerAwareInterface.phpS*Rw϶Bvendor/zendframework/zend-eventmanager/Zend/EventManager/Event.phpS*RMRHSvendor/zendframework/zend-eventmanager/Zend/EventManager/EventsCapableInterface.phplS*RlXvendor/zendframework/zend-eventmanager/Zend/EventManager/SharedEventManagerInterface.phpS*RpܢOvendor/zendframework/zend-eventmanager/Zend/EventManager/StaticEventManager.phpdS*RdTjOvendor/zendframework/zend-eventmanager/Zend/EventManager/SharedEventManager.phpS*R_R Svendor/zendframework/zend-eventmanager/Zend/EventManager/EventManagerAwareTrait.phpS*RIvendor/zendframework/zend-eventmanager/Zend/EventManager/EventManager.phpS*Rn,Rvendor/zendframework/zend-eventmanager/Zend/EventManager/EventManagerInterface.phpYS*RY϶_vendor/zendframework/zend-eventmanager/Zend/EventManager/SharedEventAggregateAwareInterface.phpS*R Hvendor/zendframework/zend-eventmanager/Zend/EventManager/FilterChain.php%S*R%|HKvendor/zendframework/zend-eventmanager/Zend/EventManager/ProvidesEvents.php$S*R$oSOvendor/zendframework/zend-eventmanager/Zend/EventManager/GlobalEventManager.phpS*RpfKvendor/zendframework/zend-eventmanager/Zend/EventManager/EventInterface.phpS*RFF2]vendor/zendframework/zend-eventmanager/Zend/EventManager/SharedListenerAggregateInterface.phpS*RpG0ɶWvendor/zendframework/zend-eventmanager/Zend/EventManager/ListenerAggregateInterface.phpS*RP7vendor/zendframework/zend-config/Zend/Config/Config.phpQ S*RQ s? Svendor/zendframework/zend-config/Zend/Config/Exception/InvalidArgumentException.phpS*R7c`Mvendor/zendframework/zend-config/Zend/Config/Exception/ExceptionInterface.phpHS*RH Kvendor/zendframework/zend-config/Zend/Config/Exception/RuntimeException.phpzS*RzBFvendor/zendframework/zend-config/Zend/Config/Writer/AbstractWriter.phpcS*Rc0<vendor/zendframework/zend-config/Zend/Config/Writer/Yaml.phpS*R,DF<vendor/zendframework/zend-config/Zend/Config/Writer/Json.phpS*R`;vendor/zendframework/zend-config/Zend/Config/Writer/Xml.phpS*R AGvendor/zendframework/zend-config/Zend/Config/Writer/WriterInterface.phpS*R>@vendor/zendframework/zend-config/Zend/Config/Writer/PhpArray.phpS*R94;vendor/zendframework/zend-config/Zend/Config/Writer/Ini.phpS*RXM#<vendor/zendframework/zend-config/Zend/Config/Reader/Yaml.php0S*R0y <vendor/zendframework/zend-config/Zend/Config/Reader/Json.phpS*Rꪶ;vendor/zendframework/zend-config/Zend/Config/Reader/Xml.php< S*R< QGvendor/zendframework/zend-config/Zend/Config/Reader/ReaderInterface.phpS*R򎮶;vendor/zendframework/zend-config/Zend/Config/Reader/Ini.php S*R JDvendor/zendframework/zend-config/Zend/Config/ReaderPluginManager.phpxS*Rx*66@vendor/zendframework/zend-config/Zend/Config/Processor/Token.php S*R ^'KCvendor/zendframework/zend-config/Zend/Config/Processor/Constant.php S*R ?Mض@vendor/zendframework/zend-config/Zend/Config/Processor/Queue.php!S*R!ZZȸMvendor/zendframework/zend-config/Zend/Config/Processor/ProcessorInterface.phpS*RJ,Evendor/zendframework/zend-config/Zend/Config/Processor/Translator.phpS*R4Avendor/zendframework/zend-config/Zend/Config/Processor/Filter.phpES*REN{8vendor/zendframework/zend-config/Zend/Config/Factory.phpS*R,ѶDvendor/zendframework/zend-config/Zend/Config/WriterPluginManager.phpS*RݫZFvendor/zendframework/zend-math/Zend/Math/Exception/DomainException.phpvS*Rv焜Ovendor/zendframework/zend-math/Zend/Math/Exception/InvalidArgumentException.phpS*Ro5TIvendor/zendframework/zend-math/Zend/Math/Exception/ExceptionInterface.phpFS*RF YGvendor/zendframework/zend-math/Zend/Math/Exception/RuntimeException.phpxS*Rxuh21vendor/zendframework/zend-math/Zend/Math/Rand.php S*R Lvendor/zendframework/zend-math/Zend/Math/BigInteger/AdapterPluginManager.phpNS*RNmʶYvendor/zendframework/zend-math/Zend/Math/BigInteger/Exception/DivisionByZeroException.phpS*RP!Zvendor/zendframework/zend-math/Zend/Math/BigInteger/Exception/InvalidArgumentException.phpS*R3Tvendor/zendframework/zend-math/Zend/Math/BigInteger/Exception/ExceptionInterface.phpS*Rb%Rvendor/zendframework/zend-math/Zend/Math/BigInteger/Exception/RuntimeException.phpS*R *ȶBvendor/zendframework/zend-math/Zend/Math/BigInteger/BigInteger.phpS*R Cvendor/zendframework/zend-math/Zend/Math/BigInteger/Adapter/Gmp.phpS*R5|Pvendor/zendframework/zend-math/Zend/Math/BigInteger/Adapter/AdapterInterface.phpAS*RAJ#50Fvendor/zendframework/zend-math/Zend/Math/BigInteger/Adapter/Bcmath.phpS*R>vendor/zendframework/zend-math/Zend/Math/Source/HashTiming.php-S*R-gUvendor/zendframework/zend-validator/Zend/Validator/Translator/TranslatorInterface.phpS*RʡZvendor/zendframework/zend-validator/Zend/Validator/Translator/TranslatorAwareInterface.phpS*RIPH;vendor/zendframework/zend-validator/Zend/Validator/Isbn.php= S*R= +?vendor/zendframework/zend-validator/Zend/Validator/NotEmpty.phpLS*RL^vendor/zendframework/zend-validator/Zend/Validator/Exception/InvalidMagicMimeFileException.phpsS*Rs?1Yvendor/zendframework/zend-validator/Zend/Validator/Exception/InvalidArgumentException.phpS*Rf+Svendor/zendframework/zend-validator/Zend/Validator/Exception/ExceptionInterface.phpKS*RKȎbQvendor/zendframework/zend-validator/Zend/Validator/Exception/RuntimeException.php}S*R}햶Wvendor/zendframework/zend-validator/Zend/Validator/Exception/BadMethodCallException.phpS*Rt \vendor/zendframework/zend-validator/Zend/Validator/Exception/ExtensionNotLoadedException.phpiS*Ri9vendor/zendframework/zend-validator/Zend/Validator/Ip.php S*R ɜ;vendor/zendframework/zend-validator/Zend/Validator/Csrf.php S*R v>vendor/zendframework/zend-validator/Zend/Validator/InArray.php S*R + ?vendor/zendframework/zend-validator/Zend/Validator/Callback.phpS*Rwt">vendor/zendframework/zend-validator/Zend/Validator/Between.phpdS*Rd4N#Gvendor/zendframework/zend-validator/Zend/Validator/Sitemap/Priority.phpS*RŸIvendor/zendframework/zend-validator/Zend/Validator/Sitemap/Changefreq.phpS*Rߋ>ֶBvendor/zendframework/zend-validator/Zend/Validator/Sitemap/Loc.phprS*Rrj^E;Fvendor/zendframework/zend-validator/Zend/Validator/Sitemap/Lastmod.phpiS*Ri@?Զ;vendor/zendframework/zend-validator/Zend/Validator/Step.phpeS*ReT=:vendor/zendframework/zend-validator/Zend/Validator/Uri.php S*R s\Evendor/zendframework/zend-validator/Zend/Validator/ValidatorChain.php\ S*R\ +H?vendor/zendframework/zend-validator/Zend/Validator/Hostname.php)QS*R)Qh;vendor/zendframework/zend-validator/Zend/Validator/Date.php,S*R, Ivendor/zendframework/zend-validator/Zend/Validator/ValidatorInterface.phpS*RCvendor/zendframework/zend-validator/Zend/Validator/StringLength.php S*R ߯[vendor/zendframework/zend-validator/Zend/Validator/ValidatorPluginManagerAwareInterface.phpS*R79 :vendor/zendframework/zend-validator/Zend/Validator/Hex.phpS*R(}@vendor/zendframework/zend-validator/Zend/Validator/Identical.phpS*R/@p>vendor/zendframework/zend-validator/Zend/Validator/Barcode.php S*R G-Fvendor/zendframework/zend-validator/Zend/Validator/StaticValidator.phpS*R 'W<vendor/zendframework/zend-validator/Zend/Validator/Regex.phpS*R̶;vendor/zendframework/zend-validator/Zend/Validator/Iban.phpS*RUN>vendor/zendframework/zend-validator/Zend/Validator/Explode.php S*R Qk?vendor/zendframework/zend-validator/Zend/Validator/DateStep.phptS*Rt ?vendor/zendframework/zend-validator/Zend/Validator/LessThan.phpRS*RRpAvendor/zendframework/zend-validator/Zend/Validator/File/Crc32.phpZS*RZtA&Kvendor/zendframework/zend-validator/Zend/Validator/File/ExcludeMimeType.phpgS*RgxҶEvendor/zendframework/zend-validator/Zend/Validator/File/Extension.php} S*R} Avendor/zendframework/zend-validator/Zend/Validator/File/Count.php S*R Q>Bvendor/zendframework/zend-validator/Zend/Validator/File/Upload.phpS*RDvendor/zendframework/zend-validator/Zend/Validator/File/MimeType.phpS*R?vendor/zendframework/zend-validator/Zend/Validator/File/Md5.phpES*REsr*Cvendor/zendframework/zend-validator/Zend/Validator/File/IsImage.phpES*REc[,Bvendor/zendframework/zend-validator/Zend/Validator/File/Exists.php S*R GMLvendor/zendframework/zend-validator/Zend/Validator/File/ExcludeExtension.phpJS*RJ@vendor/zendframework/zend-validator/Zend/Validator/File/Size.phpS*R8vSCvendor/zendframework/zend-validator/Zend/Validator/Hostname/Com.phpG0S*RG0KDBvendor/zendframework/zend-validator/Zend/Validator/Hostname/Jp.php/S*R/RƏSBvendor/zendframework/zend-validator/Zend/Validator/Hostname/Cn.phpS*RKICvendor/zendframework/zend-validator/Zend/Validator/Hostname/Biz.phpcS*RcqR|Avendor/zendframework/zend-validator/Zend/Validator/CreditCard.phpS*Ra?Bvendor/zendframework/zend-validator/Zend/Validator/GreaterThan.phpsS*RsDvendor/zendframework/zend-validator/Zend/Validator/Db/AbstractDb.phpS*RuLNHvendor/zendframework/zend-validator/Zend/Validator/Db/NoRecordExists.phpS*RFvendor/zendframework/zend-validator/Zend/Validator/Db/RecordExists.phpS*ReϝCvendor/zendframework/zend-validator/Zend/Validator/IsInstanceOf.php6S*R6DlCvendor/zendframework/zend-validator/Zend/Validator/EmailAddress.phpbS*Rb%=vendor/zendframework/zend-validator/Zend/Validator/Digits.phpS*RFkMvendor/zendframework/zend-validator/Zend/Validator/ValidatorPluginManager.phpZS*RZfEvendor/zendframework/zend-validator/Zend/Validator/Barcode/Gtin14.phpS*RCHCvendor/zendframework/zend-validator/Zend/Validator/Barcode/Upce.phpS*RIEvendor/zendframework/zend-validator/Zend/Validator/Barcode/Code25.phpS*RZ Hvendor/zendframework/zend-validator/Zend/Validator/Barcode/Code39ext.phpS*R4FEvendor/zendframework/zend-validator/Zend/Validator/Barcode/Code39.php S*R [Evendor/zendframework/zend-validator/Zend/Validator/Barcode/Planet.phpS*R KOvendor/zendframework/zend-validator/Zend/Validator/Barcode/AdapterInterface.phpOS*ROT4Cvendor/zendframework/zend-validator/Zend/Validator/Barcode/Ean2.phpS*R΍Fvendor/zendframework/zend-validator/Zend/Validator/Barcode/Postnet.phpS*Rh2xCvendor/zendframework/zend-validator/Zend/Validator/Barcode/Issn.phpS*RpDvendor/zendframework/zend-validator/Zend/Validator/Barcode/Itf14.phpS*R6\Cvendor/zendframework/zend-validator/Zend/Validator/Barcode/Upca.phpS*Rg/Fvendor/zendframework/zend-validator/Zend/Validator/Barcode/Code128.php!S*R!-猶Cvendor/zendframework/zend-validator/Zend/Validator/Barcode/Sscc.phpS*RHvendor/zendframework/zend-validator/Zend/Validator/Barcode/Royalmail.phpS*RPvendor/zendframework/zend-validator/Zend/Validator/Barcode/Code25interleaved.phpS*R4Cvendor/zendframework/zend-validator/Zend/Validator/Barcode/Ean5.phpS*R؀aDvendor/zendframework/zend-validator/Zend/Validator/Barcode/Ean13.phpS*R;Dvendor/zendframework/zend-validator/Zend/Validator/Barcode/Ean18.phpS*R&Nvendor/zendframework/zend-validator/Zend/Validator/Barcode/Intelligentmail.phpS*RW!Dvendor/zendframework/zend-validator/Zend/Validator/Barcode/Ean14.phpS*RFEvendor/zendframework/zend-validator/Zend/Validator/Barcode/Gtin13.phpS*RP VHvendor/zendframework/zend-validator/Zend/Validator/Barcode/Identcode.php3S*R3]]Evendor/zendframework/zend-validator/Zend/Validator/Barcode/Gtin12.phpS*R,Evendor/zendframework/zend-validator/Zend/Validator/Barcode/Code93.phpS*R`Dvendor/zendframework/zend-validator/Zend/Validator/Barcode/Ean12.phpS*RFNvendor/zendframework/zend-validator/Zend/Validator/Barcode/AbstractAdapter.php S*R ;¶Gvendor/zendframework/zend-validator/Zend/Validator/Barcode/Leitcode.phpS*RZQEHvendor/zendframework/zend-validator/Zend/Validator/Barcode/Code93ext.phpS*R[Cvendor/zendframework/zend-validator/Zend/Validator/Barcode/Ean8.php~S*R~50[<Fvendor/zendframework/zend-validator/Zend/Validator/Barcode/Codabar.phpXS*RXZAOHvendor/zendframework/zend-validator/Zend/Validator/AbstractValidator.phpS*R<vendor/zendframework/zend-code/Zend/Code/NameInformation.phpS*RslOvendor/zendframework/zend-code/Zend/Code/Exception/InvalidArgumentException.phpS*RpUIvendor/zendframework/zend-code/Zend/Code/Exception/ExceptionInterface.phpFS*RF :Gvendor/zendframework/zend-code/Zend/Code/Exception/RuntimeException.phpxS*RxĩMvendor/zendframework/zend-code/Zend/Code/Exception/BadMethodCallException.phpS*RY϶Kvendor/zendframework/zend-code/Zend/Code/Annotation/AnnotationInterface.phpoS*RoNvendor/zendframework/zend-code/Zend/Code/Annotation/Parser/ParserInterface.php S*R Τ=Vvendor/zendframework/zend-code/Zend/Code/Annotation/Parser/GenericAnnotationParser.php S*R 2TWvendor/zendframework/zend-code/Zend/Code/Annotation/Parser/DoctrineAnnotationParser.phpZS*RZ̪`Ivendor/zendframework/zend-code/Zend/Code/Annotation/AnnotationManager.phpJS*RJ2勶Lvendor/zendframework/zend-code/Zend/Code/Annotation/AnnotationCollection.phpS*R辛Hvendor/zendframework/zend-code/Zend/Code/Generator/DocBlockGenerator.php S*R &ԯxMvendor/zendframework/zend-code/Zend/Code/Generator/DocBlock/Tag/ReturnTag.phpS*RߡLvendor/zendframework/zend-code/Zend/Code/Generator/DocBlock/Tag/ParamTag.php_S*R_)Nvendor/zendframework/zend-code/Zend/Code/Generator/DocBlock/Tag/LicenseTag.phpS*RoMvendor/zendframework/zend-code/Zend/Code/Generator/DocBlock/Tag/AuthorTag.phpxS*RxWNXCvendor/zendframework/zend-code/Zend/Code/Generator/DocBlock/Tag.phpKS*RKzDvendor/zendframework/zend-code/Zend/Code/Generator/FileGenerator.phpb"S*Rb"Yvendor/zendframework/zend-code/Zend/Code/Generator/Exception/InvalidArgumentException.phpS*RSvendor/zendframework/zend-code/Zend/Code/Generator/Exception/ExceptionInterface.phpS*R>!)Qvendor/zendframework/zend-code/Zend/Code/Generator/Exception/RuntimeException.phpS*R~Evendor/zendframework/zend-code/Zend/Code/Generator/ValueGenerator.php+S*R+#ǶFvendor/zendframework/zend-code/Zend/Code/Generator/MethodGenerator.phpES*REh0xyHvendor/zendframework/zend-code/Zend/Code/Generator/AbstractGenerator.phpSS*RSaDvendor/zendframework/zend-code/Zend/Code/Generator/BodyGenerator.phpAS*RAj撂Nvendor/zendframework/zend-code/Zend/Code/Generator/AbstractMemberGenerator.php" S*R" lضIvendor/zendframework/zend-code/Zend/Code/Generator/ParameterGenerator.phpLS*RL.Ivendor/zendframework/zend-code/Zend/Code/Generator/GeneratorInterface.phpcS*Rc-H,ǶMvendor/zendframework/zend-code/Zend/Code/Generator/PropertyValueGenerator.phpS*RHvendor/zendframework/zend-code/Zend/Code/Generator/PropertyGenerator.phpS*R(w࠶Evendor/zendframework/zend-code/Zend/Code/Generator/ClassGenerator.php)S*R)o RLvendor/zendframework/zend-code/Zend/Code/Generator/FileGeneratorRegistry.php4S*R4Hvendor/zendframework/zend-code/Zend/Code/Scanner/DerivedClassScanner.phpS*RvDvendor/zendframework/zend-code/Zend/Code/Scanner/PropertyScanner.php S*R p Evendor/zendframework/zend-code/Zend/Code/Scanner/DirectoryScanner.phpPS*RPʼ|EAvendor/zendframework/zend-code/Zend/Code/Scanner/ClassScanner.php}4S*R}4SDvendor/zendframework/zend-code/Zend/Code/Scanner/DocBlockScanner.php3S*R3[VyXFvendor/zendframework/zend-code/Zend/Code/Scanner/AnnotationScanner.phpS*RZTöAvendor/zendframework/zend-code/Zend/Code/Scanner/ValueScanner.php;S*R;SDvendor/zendframework/zend-code/Zend/Code/Scanner/FunctionScanner.php>S*R>6Evendor/zendframework/zend-code/Zend/Code/Scanner/ParameterScanner.phpU S*RU x<Gvendor/zendframework/zend-code/Zend/Code/Scanner/CachingFileScanner.phpaS*RaIGѶDvendor/zendframework/zend-code/Zend/Code/Scanner/ConstantScanner.php S*R nNvendor/zendframework/zend-code/Zend/Code/Scanner/AggregateDirectoryScanner.phpS*RBX1Fvendor/zendframework/zend-code/Zend/Code/Scanner/TokenArrayScanner.php*(S*R*(+/Γ9vendor/zendframework/zend-code/Zend/Code/Scanner/Util.phpZS*RZ˴̶@vendor/zendframework/zend-code/Zend/Code/Scanner/FileScanner.php.S*R.Bvendor/zendframework/zend-code/Zend/Code/Scanner/MethodScanner.phpS*R[4 aEvendor/zendframework/zend-code/Zend/Code/Scanner/ScannerInterface.phpCS*RC84INvendor/zendframework/zend-code/Zend/Code/Reflection/DocBlock/Tag/ReturnTag.phpS*R$Pvendor/zendframework/zend-code/Zend/Code/Reflection/DocBlock/Tag/PropertyTag.phpS*R+Mvendor/zendframework/zend-code/Zend/Code/Reflection/DocBlock/Tag/ParamTag.phpS*ReQvendor/zendframework/zend-code/Zend/Code/Reflection/DocBlock/Tag/TagInterface.phpS*RkeOvendor/zendframework/zend-code/Zend/Code/Reflection/DocBlock/Tag/LicenseTag.phpS*RWNvendor/zendframework/zend-code/Zend/Code/Reflection/DocBlock/Tag/ThrowsTag.phpnS*RnOvendor/zendframework/zend-code/Zend/Code/Reflection/DocBlock/Tag/GenericTag.phpS*R+_\vendor/zendframework/zend-code/Zend/Code/Reflection/DocBlock/Tag/PhpDocTypedTagInterface.phpvS*Rv];ܶNvendor/zendframework/zend-code/Zend/Code/Reflection/DocBlock/Tag/MethodTag.phpOS*RO8Nvendor/zendframework/zend-code/Zend/Code/Reflection/DocBlock/Tag/AuthorTag.phpS*Re Kvendor/zendframework/zend-code/Zend/Code/Reflection/DocBlock/TagManager.phpS*R Kvendor/zendframework/zend-code/Zend/Code/Reflection/ParameterReflection.php_S*R_~6Zvendor/zendframework/zend-code/Zend/Code/Reflection/Exception/InvalidArgumentException.phpS*R:,Tvendor/zendframework/zend-code/Zend/Code/Reflection/Exception/ExceptionInterface.phpS*R 5Rvendor/zendframework/zend-code/Zend/Code/Reflection/Exception/RuntimeException.phpS*R:<\Xvendor/zendframework/zend-code/Zend/Code/Reflection/Exception/BadMethodCallException.phpS*R4ѶKvendor/zendframework/zend-code/Zend/Code/Reflection/ReflectionInterface.phpS*R=Jvendor/zendframework/zend-code/Zend/Code/Reflection/FunctionReflection.phpS*R@>Jvendor/zendframework/zend-code/Zend/Code/Reflection/DocBlockReflection.phpS*R!F5Fvendor/zendframework/zend-code/Zend/Code/Reflection/FileReflection.php S*R aJvendor/zendframework/zend-code/Zend/Code/Reflection/PropertyReflection.phpLS*RL'><׶Hvendor/zendframework/zend-code/Zend/Code/Reflection/MethodReflection.phpn S*Rn NzGvendor/zendframework/zend-code/Zend/Code/Reflection/ClassReflection.phpX S*RX +"Ovendor/zendframework/zend-file/Zend/File/Exception/InvalidArgumentException.phpS*RC'Ivendor/zendframework/zend-file/Zend/File/Exception/ExceptionInterface.phpGS*RGDͶGvendor/zendframework/zend-file/Zend/File/Exception/RuntimeException.phpxS*Rx>Mvendor/zendframework/zend-file/Zend/File/Exception/BadMethodCallException.phpS*R9vendor/zendframework/zend-file/Zend/File/PhpClassFile.phpS*RnBV=vendor/zendframework/zend-file/Zend/File/ClassFileLocator.phpt S*Rt hԶ>vendor/zendframework/zend-file/Zend/File/Transfer/Transfer.phpbS*Rb3}iWvendor/zendframework/zend-file/Zend/File/Transfer/Exception/PhpEnvironmentException.phpiS*RiX?Xvendor/zendframework/zend-file/Zend/File/Transfer/Exception/InvalidArgumentException.phpS*R@|Rvendor/zendframework/zend-file/Zend/File/Transfer/Exception/ExceptionInterface.phpS*R-?GPvendor/zendframework/zend-file/Zend/File/Transfer/Exception/RuntimeException.phpS*RKVvendor/zendframework/zend-file/Zend/File/Transfer/Exception/BadMethodCallException.phpS*R)P_Qvendor/zendframework/zend-file/Zend/File/Transfer/Adapter/FilterPluginManager.phpDS*RD72Bvendor/zendframework/zend-file/Zend/File/Transfer/Adapter/Http.phpS*RC3Tvendor/zendframework/zend-file/Zend/File/Transfer/Adapter/ValidatorPluginManager.phpS*ROƨMvendor/zendframework/zend-file/Zend/File/Transfer/Adapter/AbstractAdapter.phpeRS*ReRivendor/zendframework/zend-modulemanager/Zend/ModuleManager/Exception/MissingDependencyModuleException.phpS*R.avendor/zendframework/zend-modulemanager/Zend/ModuleManager/Exception/InvalidArgumentException.phpS*Rך0[vendor/zendframework/zend-modulemanager/Zend/ModuleManager/Exception/ExceptionInterface.phpPS*RPyxYvendor/zendframework/zend-modulemanager/Zend/ModuleManager/Exception/RuntimeException.phpS*RZy]vendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/RouteProviderInterface.phptS*Rt%;bvendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/ControllerProviderInterface.php~S*R~"cvendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/FormElementProviderInterface.phpS*R`K^vendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/ConfigProviderInterface.phppS*Rp _vendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/ServiceProviderInterface.phpxS*RxWcvendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/DependencyIndicatorInterface.phpS*Rs1жcvendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/InputFilterProviderInterface.phpS*R\N\vendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/InitProviderInterface.phpS*Rbvendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/SerializerProviderInterface.php~S*R~8Vdvendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/ConsoleUsageProviderInterface.phpS*R`oavendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/BootstrapListenerInterface.phpS*RGbvendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/ViewHelperProviderInterface.php~S*R~=rhvendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/ControllerPluginProviderInterface.phpS*REavendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/ValidatorProviderInterface.php|S*R|}avendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/LocatorRegisteredInterface.phpVS*RVN evendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/ConsoleBannerProviderInterface.phpS*R`vendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/HydratorProviderInterface.phpzS*Rz,涶bvendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/AutoloaderProviderInterface.php~S*R~k^vendor/zendframework/zend-modulemanager/Zend/ModuleManager/Feature/FilterProviderInterface.phpvS*Rv5Q̶Svendor/zendframework/zend-modulemanager/Zend/ModuleManager/Listener/InitTrigger.php~S*R~[vendor/zendframework/zend-modulemanager/Zend/ModuleManager/Listener/OnBootstrapListener.phpsS*Rs^jvendor/zendframework/zend-modulemanager/Zend/ModuleManager/Listener/Exception/InvalidArgumentException.phpS*RֽǶdvendor/zendframework/zend-modulemanager/Zend/ModuleManager/Listener/Exception/ExceptionInterface.phpS*R-4ֶ7vendor/zendframework/zend-json/Zend/Json/Server/Smd.phpTS*RT:^<vendor/zendframework/zend-json/Zend/Json/Server/Response.phpVS*RVX 9vendor/zendframework/zend-json/Zend/Json/Server/Error.phpS*R7H?vendor/zendframework/zend-json/Zend/Json/Server/Smd/Service.php[S*R[.:vendor/zendframework/zend-json/Zend/Json/Server/Server.php: S*R: @!:Avendor/zendframework/zend-json/Zend/Json/Server/Response/Http.phpYS*RYII;vendor/zendframework/zend-json/Zend/Json/Server/Request.php S*R 9vendor/zendframework/zend-json/Zend/Json/Server/Cache.phpS*REFx4vendor/zendframework/zend-json/Zend/Json/Encoder.php<S*R</config/module.config.php S*R "q*src/ZFTool/Controller/ConfigController.php S*R *src/ZFTool/Controller/ModuleController.phpS*R(nж,src/ZFTool/Controller/ClassmapController.phpeS*Ref,/src/ZFTool/Controller/DiagnosticsController.phpS*R ;@*src/ZFTool/Controller/CreateController.php;$S*R;$֝S+src/ZFTool/Controller/InstallController.phpS*R'ʶ(src/ZFTool/Controller/InfoController.phpS*Rsrc/ZFTool/Model/Config.phpS*R;src/ZFTool/Model/Zf.phpS*R@src/ZFTool/Model/Utility.phpS*Rhsrc/ZFTool/Model/Skeleton.php S*R I!!src/ZFTool/Diagnostics/Config.phpS*R=src/ZFTool/Diagnostics/Exception/InvalidArgumentException.phpS*R 7src/ZFTool/Diagnostics/Exception/ExceptionInterface.phpOS*RO<5src/ZFTool/Diagnostics/Exception/RuntimeException.phpS*R9C^0src/ZFTool/Diagnostics/Reporter/BasicConsole.phpES*RE4src/ZFTool/Diagnostics/Reporter/AbstractReporter.php<S*R<:2src/ZFTool/Diagnostics/Reporter/VerboseConsole.phpS*RuyC!src/ZFTool/Diagnostics/Runner.phpS*R*!src/ZFTool/Diagnostics/Result.phpRS*RR)src/ZFTool/Diagnostics/Result/Warning.phpWS*RWYz k)src/ZFTool/Diagnostics/Result/Success.phpWS*RWD^)src/ZFTool/Diagnostics/Result/Unknown.phpS*RE1src/ZFTool/Diagnostics/Result/ResultInterface.phpS*R 8gƶ,src/ZFTool/Diagnostics/Result/Collection.php\ S*R\ +)src/ZFTool/Diagnostics/Result/Failure.phpWS*RWqT&src/ZFTool/Diagnostics/RunListener.php^ S*R^ R*src/ZFTool/Diagnostics/ConfigInterface.phpS*Rɛ$+src/ZFTool/Diagnostics/Test/ClassExists.php1S*R1rx(src/ZFTool/Diagnostics/Test/Callback.phpS*Re,src/ZFTool/Diagnostics/Test/AbstractTest.phpS*R-A+src/ZFTool/Diagnostics/Test/DirWritable.phpS*R+src/ZFTool/Diagnostics/Test/DirReadable.phpS*R&/src/ZFTool/Diagnostics/Test/ExtensionLoaded.phprS*RrQ*src/ZFTool/Diagnostics/Test/PhpVersion.php S*R !K5.src/ZFTool/Diagnostics/Test/CpuPerformance.phpS*R! U-src/ZFTool/Diagnostics/Test/TestInterface.phpS*Rwc3src/ZFTool/Diagnostics/Test/StreamWrapperExists.phpS*R&i#src/ZFTool/Diagnostics/RunEvent.phpS*RP}Vsrc/ZFTool/Module.phpS*R V array( 'ZFTool', ), 'module_listener_options' => array( 'config_glob_paths' => array( 'config/autoload/{,*.}{global,local}.php', ), 'module_paths' => array( '.', './vendor', ), ), ); } Zend\Mvc\Application::init($appConfig)->run(); $path) { $loader->set($namespace, $path); } $classMap = require __DIR__ . '/autoload_classmap.php'; if ($classMap) { $loader->addClassMap($classMap); } $loader->register(true); return $loader; } } prefixes); } public function getFallbackDirs() { return $this->fallbackDirs; } public function getClassMap() { return $this->classMap; } public function addClassMap(array $classMap) { if ($this->classMap) { $this->classMap = array_merge($this->classMap, $classMap); } else { $this->classMap = $classMap; } } public function add($prefix, $paths, $prepend = false) { if (!$prefix) { if ($prepend) { $this->fallbackDirs = array_merge( (array) $paths, $this->fallbackDirs ); } else { $this->fallbackDirs = array_merge( $this->fallbackDirs, (array) $paths ); } return; } $first = $prefix[0]; if (!isset($this->prefixes[$first][$prefix])) { $this->prefixes[$first][$prefix] = (array) $paths; return; } if ($prepend) { $this->prefixes[$first][$prefix] = array_merge( (array) $paths, $this->prefixes[$first][$prefix] ); } else { $this->prefixes[$first][$prefix] = array_merge( $this->prefixes[$first][$prefix], (array) $paths ); } } public function set($prefix, $paths) { if (!$prefix) { $this->fallbackDirs = (array) $paths; return; } $this->prefixes[substr($prefix, 0, 1)][$prefix] = (array) $paths; } public function setUseIncludePath($useIncludePath) { $this->useIncludePath = $useIncludePath; } public function getUseIncludePath() { return $this->useIncludePath; } public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); } public function unregister() { spl_autoload_unregister(array($this, 'loadClass')); } public function loadClass($class) { if ($file = $this->findFile($class)) { include $file; return true; } } public function findFile($class) { if ('\\' == $class[0]) { $class = substr($class, 1); } if (isset($this->classMap[$class])) { return $this->classMap[$class]; } if (false !== $pos = strrpos($class, '\\')) { $classPath = strtr(substr($class, 0, $pos), '\\', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; $className = substr($class, $pos + 1); } else { $classPath = null; $className = $class; } $classPath .= strtr($className, '_', DIRECTORY_SEPARATOR) . '.php'; $first = $class[0]; if (isset($this->prefixes[$first])) { foreach ($this->prefixes[$first] as $prefix => $dirs) { if (0 === strpos($class, $prefix)) { foreach ($dirs as $dir) { if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) { return $dir . DIRECTORY_SEPARATOR . $classPath; } } } } } foreach ($this->fallbackDirs as $dir) { if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) { return $dir . DIRECTORY_SEPARATOR . $classPath; } } if ($this->useIncludePath && $file = stream_resolve_include_path($classPath)) { return $file; } return $this->classMap[$class] = false; } } array($vendorDir . '/zendframework/zend-view'), 'Zend\\Version\\' => array($vendorDir . '/zendframework/zend-version'), 'Zend\\Validator\\' => array($vendorDir . '/zendframework/zend-validator'), 'Zend\\Text\\' => array($vendorDir . '/zendframework/zend-text'), 'Zend\\Stdlib\\' => array($vendorDir . '/zendframework/zend-stdlib'), 'Zend\\ServiceManager\\' => array($vendorDir . '/zendframework/zend-servicemanager'), 'Zend\\Serializer\\' => array($vendorDir . '/zendframework/zend-serializer'), 'Zend\\Mvc\\' => array($vendorDir . '/zendframework/zend-mvc'), 'Zend\\ModuleManager\\' => array($vendorDir . '/zendframework/zend-modulemanager'), 'Zend\\Math\\' => array($vendorDir . '/zendframework/zend-math'), 'Zend\\Loader\\' => array($vendorDir . '/zendframework/zend-loader'), 'Zend\\Json\\' => array($vendorDir . '/zendframework/zend-json'), 'Zend\\InputFilter\\' => array($vendorDir . '/zendframework/zend-inputfilter'), 'Zend\\Form\\' => array($vendorDir . '/zendframework/zend-form'), 'Zend\\Filter\\' => array($vendorDir . '/zendframework/zend-filter'), 'Zend\\File\\' => array($vendorDir . '/zendframework/zend-file'), 'Zend\\EventManager\\' => array($vendorDir . '/zendframework/zend-eventmanager'), 'Zend\\Console\\' => array($vendorDir . '/zendframework/zend-console'), 'Zend\\Config\\' => array($vendorDir . '/zendframework/zend-config'), 'Zend\\Code\\' => array($vendorDir . '/zendframework/zend-code'), 'ZFTool\\' => array($baseDir . '/src'), ); configuration = $configuration; $this->serviceManager = $serviceManager; $this->setEventManager($serviceManager->get('EventManager')); $this->request = $serviceManager->get('Request'); $this->response = $serviceManager->get('Response'); } public function getConfig() { return $this->serviceManager->get('Config'); } public function bootstrap(array $listeners = array()) { $serviceManager = $this->serviceManager; $events = $this->events; $listeners = array_unique(array_merge($this->defaultListeners, $listeners)); foreach ($listeners as $listener) { $events->attach($serviceManager->get($listener)); } $this->event = $event = new MvcEvent(); $event->setTarget($this); $event->setApplication($this) ->setRequest($this->getRequest()) ->setResponse($this->getResponse()) ->setRouter($serviceManager->get('Router')); $events->trigger(MvcEvent::EVENT_BOOTSTRAP, $event); return $this; } public function getServiceManager() { return $this->serviceManager; } public function getRequest() { return $this->request; } public function getResponse() { return $this->response; } public function getMvcEvent() { return $this->event; } public function setEventManager(EventManagerInterface $eventManager) { $eventManager->setIdentifiers(array( __CLASS__, get_class($this), )); $this->events = $eventManager; return $this; } public function getEventManager() { return $this->events; } public static function init($configuration = array()) { $smConfig = isset($configuration['service_manager']) ? $configuration['service_manager'] : array(); $listeners = isset($configuration['listeners']) ? $configuration['listeners'] : array(); $serviceManager = new ServiceManager(new Service\ServiceManagerConfig($smConfig)); $serviceManager->setService('ApplicationConfig', $configuration); $serviceManager->get('ModuleManager')->loadModules(); return $serviceManager->get('Application')->bootstrap($listeners); } public function run() { $events = $this->getEventManager(); $event = $this->getMvcEvent(); $shortCircuit = function ($r) use ($event) { if ($r instanceof ResponseInterface) { return true; } if ($event->getError()) { return true; } return false; }; $result = $events->trigger(MvcEvent::EVENT_ROUTE, $event, $shortCircuit); if ($result->stopped()) { $response = $result->last(); if ($response instanceof ResponseInterface) { $event->setTarget($this); $event->setResponse($response); $events->trigger(MvcEvent::EVENT_FINISH, $event); return $response; } if ($event->getError()) { return $this->completeRequest($event); } return $event->getResponse(); } if ($event->getError()) { return $this->completeRequest($event); } $result = $events->trigger(MvcEvent::EVENT_DISPATCH, $event, $shortCircuit); $response = $result->last(); if ($response instanceof ResponseInterface) { $event->setTarget($this); $event->setResponse($response); $events->trigger(MvcEvent::EVENT_FINISH, $event); return $response; } $response = $this->getResponse(); $event->setResponse($response); $this->completeRequest($event); return $this; } public function send() { } protected function completeRequest(MvcEvent $event) { $events = $this->getEventManager(); $event->setTarget($this); $events->trigger(MvcEvent::EVENT_RENDER, $event); $events->trigger(MvcEvent::EVENT_FINISH, $event); return $this; } } chainRoutes = array_reverse($routes); $this->routePluginManager = $routePlugins; $this->routes = new PriorityList(); $this->prototypes = $prototypes; } public static function factory($options = array()) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (!is_array($options)) { throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options'); } if (!isset($options['routes'])) { throw new Exception\InvalidArgumentException('Missing "routes" in options array'); } if (!isset($options['prototypes'])) { $options['prototypes'] = null; } if ($options['routes'] instanceof Traversable) { $options['routes'] = ArrayUtils::iteratorToArray($options['child_routes']); } if (!isset($options['route_plugins'])) { throw new Exception\InvalidArgumentException('Missing "route_plugins" in options array'); } return new static( $options['routes'], $options['route_plugins'], $options['prototypes'] ); } public function match(Request $request, $pathOffset = null, array $options = array()) { if (!method_exists($request, 'getUri')) { return null; } if ($pathOffset === null) { $mustTerminate = true; $pathOffset = 0; } else { $mustTerminate = false; } if ($this->chainRoutes !== null) { $this->addRoutes($this->chainRoutes); $this->chainRoutes = null; } $match = new RouteMatch(array()); $uri = $request->getUri(); $pathLength = strlen($uri->getPath()); foreach ($this->routes as $route) { $subMatch = $route->match($request, $pathOffset, $options); if ($subMatch === null) { return null; } $match->merge($subMatch); $pathOffset += $subMatch->getLength(); } if ($mustTerminate && $pathOffset !== $pathLength) { return null; } return $match; } public function assemble(array $params = array(), array $options = array()) { if ($this->chainRoutes !== null) { $this->addRoutes($this->chainRoutes); $this->chainRoutes = null; } $this->assembledParams = array(); end($this->routes); $lastRouteKey = key($this->routes); $path = ''; foreach ($this->routes as $key => $route) { $chainOptions = $options; $hasChild = isset($options['has_child']) ? $options['has_child'] : false; $chainOptions['has_child'] = ($hasChild || $key !== $lastRouteKey); $path .= $route->assemble($params, $chainOptions); $params = array_diff_key($params, array_flip($route->getAssembledParams())); $this->assembledParams += $route->getAssembledParams(); } return $path; } public function getAssembledParams() { return $this->assembledParams; } } scheme = $scheme; $this->defaults = $defaults; } public static function factory($options = array()) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (!is_array($options)) { throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options'); } if (!isset($options['scheme'])) { throw new Exception\InvalidArgumentException('Missing "scheme" in options array'); } if (!isset($options['defaults'])) { $options['defaults'] = array(); } return new static($options['scheme'], $options['defaults']); } public function match(Request $request) { if (!method_exists($request, 'getUri')) { return null; } $uri = $request->getUri(); $scheme = $uri->getScheme(); if ($scheme !== $this->scheme) { return null; } return new RouteMatch($this->defaults); } public function assemble(array $params = array(), array $options = array()) { if (isset($options['uri'])) { $options['uri']->setScheme($this->scheme); } return ''; } public function getAssembledParams() { return array(); } } defaults = $defaults; $this->parts = $this->parseRouteDefinition($route); $this->regex = $this->buildRegex($this->parts, $constraints); } public static function factory($options = array()) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (!is_array($options)) { throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options'); } if (!isset($options['route'])) { throw new Exception\InvalidArgumentException('Missing "route" in options array'); } if (!isset($options['constraints'])) { $options['constraints'] = array(); } if (!isset($options['defaults'])) { $options['defaults'] = array(); } return new static($options['route'], $options['constraints'], $options['defaults']); } protected function parseRouteDefinition($def) { $currentPos = 0; $length = strlen($def); $parts = array(); $levelParts = array(&$parts); $level = 0; while ($currentPos < $length) { preg_match('(\G(?P[a-z0-9-.]*)(?P[:{\[\]]|$))', $def, $matches, 0, $currentPos); $currentPos += strlen($matches[0]); if (!empty($matches['literal'])) { $levelParts[$level][] = array('literal', $matches['literal']); } if ($matches['token'] === ':') { if (!preg_match('(\G(?P[^:.{\[\]]+)(?:{(?P[^}]+)})?:?)', $def, $matches, 0, $currentPos)) { throw new Exception\RuntimeException('Found empty parameter name'); } $levelParts[$level][] = array('parameter', $matches['name'], isset($matches['delimiters']) ? $matches['delimiters'] : null); $currentPos += strlen($matches[0]); } elseif ($matches['token'] === '[') { $levelParts[$level][] = array('optional', array()); $levelParts[$level + 1] = &$levelParts[$level][count($levelParts[$level]) - 1][1]; $level++; } elseif ($matches['token'] === ']') { unset($levelParts[$level]); $level--; if ($level < 0) { throw new Exception\RuntimeException('Found closing bracket without matching opening bracket'); } } else { break; } } if ($level > 0) { throw new Exception\RuntimeException('Found unbalanced brackets'); } return $parts; } protected function buildRegex(array $parts, array $constraints, &$groupIndex = 1) { $regex = ''; foreach ($parts as $part) { switch ($part[0]) { case 'literal': $regex .= preg_quote($part[1]); break; case 'parameter': $groupName = '?P'; if (isset($constraints[$part[1]])) { $regex .= '(' . $groupName . $constraints[$part[1]] . ')'; } elseif ($part[2] === null) { $regex .= '(' . $groupName . '[^.]+)'; } else { $regex .= '(' . $groupName . '[^' . $part[2] . ']+)'; } $this->paramMap['param' . $groupIndex++] = $part[1]; break; case 'optional': $regex .= '(?:' . $this->buildRegex($part[1], $constraints, $groupIndex) . ')?'; break; } } return $regex; } protected function buildHost(array $parts, array $mergedParams, $isOptional) { $host = ''; $skip = true; $skippable = false; foreach ($parts as $part) { switch ($part[0]) { case 'literal': $host .= $part[1]; break; case 'parameter': $skippable = true; if (!isset($mergedParams[$part[1]])) { if (!$isOptional) { throw new Exception\InvalidArgumentException(sprintf('Missing parameter "%s"', $part[1])); } return ''; } elseif (!$isOptional || !isset($this->defaults[$part[1]]) || $this->defaults[$part[1]] !== $mergedParams[$part[1]]) { $skip = false; } $host .= $mergedParams[$part[1]]; $this->assembledParams[] = $part[1]; break; case 'optional': $skippable = true; $optionalPart = $this->buildHost($part[1], $mergedParams, true); if ($optionalPart !== '') { $host .= $optionalPart; $skip = false; } break; } } if ($isOptional && $skippable && $skip) { return ''; } return $host; } public function match(Request $request) { if (!method_exists($request, 'getUri')) { return null; } $uri = $request->getUri(); $host = $uri->getHost(); $result = preg_match('(^' . $this->regex . '$)', $host, $matches); if (!$result) { return null; } $params = array(); foreach ($this->paramMap as $index => $name) { if (isset($matches[$index]) && $matches[$index] !== '') { $params[$name] = $matches[$index]; } } return new RouteMatch(array_merge($this->defaults, $params)); } public function assemble(array $params = array(), array $options = array()) { $this->assembledParams = array(); if (isset($options['uri'])) { $host = $this->buildHost( $this->parts, array_merge($this->defaults, $params), false ); $options['uri']->setHost($host); } return ''; } public function getAssembledParams() { return $this->assembledParams; } } addPrototypes($options['prototypes']); } return $instance; } protected function init() { $this->prototypes = new ArrayObject; $routes = $this->routePluginManager; foreach (array( 'chain' => __NAMESPACE__ . '\Chain', 'hostname' => __NAMESPACE__ . '\Hostname', 'literal' => __NAMESPACE__ . '\Literal', 'method' => __NAMESPACE__ . '\Method', 'part' => __NAMESPACE__ . '\Part', 'query' => __NAMESPACE__ . '\Query', 'regex' => __NAMESPACE__ . '\Regex', 'scheme' => __NAMESPACE__ . '\Scheme', 'segment' => __NAMESPACE__ . '\Segment', 'wildcard' => __NAMESPACE__ . '\Wildcard', ) as $name => $class ) { $routes->setInvokableClass($name, $class); }; } public function addRoute($name, $route, $priority = null) { if (!$route instanceof RouteInterface) { $route = $this->routeFromArray($route); } return parent::addRoute($name, $route, $priority); } protected function routeFromArray($specs) { if (is_string($specs)) { if (null === ($route = $this->getPrototype($specs))) { throw new Exception\RuntimeException(sprintf('Could not find prototype with name %s', $specs)); } return $route; } elseif ($specs instanceof Traversable) { $specs = ArrayUtils::iteratorToArray($specs); } elseif (!is_array($specs)) { throw new Exception\InvalidArgumentException('Route definition must be an array or Traversable object'); } if (isset($specs['chain_routes'])) { if (!is_array($specs['chain_routes'])) { throw new Exception\InvalidArgumentException('Chain routes must be an array or Traversable object'); } $chainRoutes = array_merge(array($specs), $specs['chain_routes']); unset($chainRoutes[0]['chain_routes']); $options = array( 'routes' => $chainRoutes, 'route_plugins' => $this->routePluginManager, 'prototypes' => $this->prototypes, ); $route = $this->routePluginManager->get('chain', $options); } else { $route = parent::routeFromArray($specs); } if (!$route instanceof RouteInterface) { throw new Exception\RuntimeException('Given route does not implement HTTP route interface'); } if (isset($specs['child_routes'])) { $options = array( 'route' => $route, 'may_terminate' => (isset($specs['may_terminate']) && $specs['may_terminate']), 'child_routes' => $specs['child_routes'], 'route_plugins' => $this->routePluginManager, 'prototypes' => $this->prototypes, ); $priority = (isset($route->priority) ? $route->priority : null); $route = $this->routePluginManager->get('part', $options); $route->priority = $priority; } return $route; } public function addPrototypes($routes) { if (!is_array($routes) && !$routes instanceof Traversable) { throw new Exception\InvalidArgumentException('addPrototypes expects an array or Traversable set of routes'); } foreach ($routes as $name => $route) { $this->addPrototype($name, $route); } return $this; } public function addPrototype($name, $route) { if (!$route instanceof RouteInterface) { $route = $this->routeFromArray($route); } $this->prototypes[$name] = $route; return $this; } public function getPrototype($name) { if (isset($this->prototypes[$name])) { return $this->prototypes[$name]; } return null; } public function match(Request $request, $pathOffset = null, array $options = array()) { if (!method_exists($request, 'getUri')) { return null; } if ($this->baseUrl === null && method_exists($request, 'getBaseUrl')) { $this->setBaseUrl($request->getBaseUrl()); } $uri = $request->getUri(); $baseUrlLength = strlen($this->baseUrl) ?: null; if ($pathOffset !== null) { $baseUrlLength += $pathOffset; } if ($this->requestUri === null) { $this->setRequestUri($uri); } if ($baseUrlLength !== null) { $pathLength = strlen($uri->getPath()) - $baseUrlLength; } else { $pathLength = null; } foreach ($this->routes as $name => $route) { if ( ($match = $route->match($request, $baseUrlLength, $options)) instanceof RouteMatch && ($pathLength === null || $match->getLength() === $pathLength) ) { $match->setMatchedRouteName($name); foreach ($this->defaultParams as $paramName => $value) { if ($match->getParam($paramName) === null) { $match->setParam($paramName, $value); } } return $match; } } return null; } public function assemble(array $params = array(), array $options = array()) { if (!isset($options['name'])) { throw new Exception\InvalidArgumentException('Missing "name" option'); } $names = explode('/', $options['name'], 2); $route = $this->routes->get($names[0]); if (!$route) { throw new Exception\RuntimeException(sprintf('Route with name "%s" not found', $names[0])); } if (isset($names[1])) { if (!$route instanceof TreeRouteStack) { throw new Exception\RuntimeException(sprintf('Route with name "%s" does not have child routes', $names[0])); } $options['name'] = $names[1]; } else { unset($options['name']); } if (isset($options['only_return_path']) && $options['only_return_path']) { return $this->baseUrl . $route->assemble(array_merge($this->defaultParams, $params), $options); } if (!isset($options['uri'])) { $uri = new HttpUri(); if (isset($options['force_canonical']) && $options['force_canonical']) { if ($this->requestUri === null) { throw new Exception\RuntimeException('Request URI has not been set'); } $uri->setScheme($this->requestUri->getScheme()) ->setHost($this->requestUri->getHost()) ->setPort($this->requestUri->getPort()); } $options['uri'] = $uri; } else { $uri = $options['uri']; } $path = $this->baseUrl . $route->assemble(array_merge($this->defaultParams, $params), $options); if (isset($options['query'])) { $uri->setQuery($options['query']); } if (isset($options['fragment'])) { $uri->setFragment($options['fragment']); } if ((isset($options['force_canonical']) && $options['force_canonical']) || $uri->getHost() !== null || $uri->getScheme() !== null) { if (($uri->getHost() === null || $uri->getScheme() === null) && $this->requestUri === null) { throw new Exception\RuntimeException('Request URI has not been set'); } if ($uri->getHost() === null) { $uri->setHost($this->requestUri->getHost()); } if ($uri->getScheme() === null) { $uri->setScheme($this->requestUri->getScheme()); } return $uri->setPath($path)->normalize()->toString(); } elseif (!$uri->isAbsolute() && $uri->isValidRelative()) { return $uri->setPath($path)->normalize()->toString(); } return $path; } public function setBaseUrl($baseUrl) { $this->baseUrl = rtrim($baseUrl, '/'); return $this; } public function getBaseUrl() { return $this->baseUrl; } public function setRequestUri(HttpUri $uri) { $this->requestUri = $uri; return $this; } public function getRequestUri() { return $this->requestUri; } } hasTranslator() && $this->isTranslatorEnabled() && !isset($options['translator'])) { $options['translator'] = $this->getTranslator(); } if (!isset($options['text_domain'])) { $options['text_domain'] = $this->getTranslatorTextDomain(); } return parent::match($request, $pathOffset, $options); } public function assemble(array $params = array(), array $options = array()) { if ($this->hasTranslator() && $this->isTranslatorEnabled() && !isset($options['translator'])) { $options['translator'] = $this->getTranslator(); } if (!isset($options['text_domain'])) { $options['text_domain'] = $this->getTranslatorTextDomain(); } return parent::assemble($params, $options); } public function setTranslator(Translator $translator = null, $textDomain = null) { $this->translator = $translator; if ($textDomain !== null) { $this->setTranslatorTextDomain($textDomain); } return $this; } public function getTranslator() { return $this->translator; } public function hasTranslator() { return $this->translator !== null; } public function setTranslatorEnabled($enabled = true) { $this->translatorEnabled = $enabled; return $this; } public function isTranslatorEnabled() { return $this->translatorEnabled; } public function setTranslatorTextDomain($textDomain = 'default') { $this->translatorTextDomain = $textDomain; return $this; } public function getTranslatorTextDomain() { return $this->translatorTextDomain; } } defaults = $defaults; } public static function factory($options = array()) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (!is_array($options)) { throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options'); } if (!isset($options['defaults'])) { $options['defaults'] = array(); } return new static($options['defaults']); } public function match(Request $request) { return new RouteMatch($this->defaults); } protected function recursiveUrldecode(array $array) { $matches = array(); foreach ($array as $key => $value) { if (is_array($value)) { $matches[urldecode($key)] = $this->recursiveUrldecode($value); } else { $matches[urldecode($key)] = urldecode($value); } } return $matches; } public function assemble(array $params = array(), array $options = array()) { $mergedParams = array_merge($this->defaults, $params); $this->assembledParams = array(); if (isset($options['uri']) && count($mergedParams)) { foreach ($mergedParams as $key => $value) { $this->assembledParams[] = $key; } $options['uri']->setQuery($mergedParams); } return ''; } public function getAssembledParams() { return $this->assembledParams; } } regex = $regex; $this->spec = $spec; $this->defaults = $defaults; } public static function factory($options = array()) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (!is_array($options)) { throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options'); } if (!isset($options['regex'])) { throw new Exception\InvalidArgumentException('Missing "regex" in options array'); } if (!isset($options['spec'])) { throw new Exception\InvalidArgumentException('Missing "spec" in options array'); } if (!isset($options['defaults'])) { $options['defaults'] = array(); } return new static($options['regex'], $options['spec'], $options['defaults']); } public function match(Request $request, $pathOffset = null) { if (!method_exists($request, 'getUri')) { return null; } $uri = $request->getUri(); $path = $uri->getPath(); if ($pathOffset !== null) { $result = preg_match('(\G' . $this->regex . ')', $path, $matches, null, $pathOffset); } else { $result = preg_match('(^' . $this->regex . '$)', $path, $matches); } if (!$result) { return null; } $matchedLength = strlen($matches[0]); foreach ($matches as $key => $value) { if (is_numeric($key) || is_int($key) || $value === '') { unset($matches[$key]); } else { $matches[$key] = rawurldecode($value); } } return new RouteMatch(array_merge($this->defaults, $matches), $matchedLength); } public function assemble(array $params = array(), array $options = array()) { $url = $this->spec; $mergedParams = array_merge($this->defaults, $params); $this->assembledParams = array(); foreach ($mergedParams as $key => $value) { $spec = '%' . $key . '%'; if (strpos($url, $spec) !== false) { $url = str_replace($spec, rawurlencode($value), $url); $this->assembledParams[] = $key; } } return $url; } public function getAssembledParams() { return $this->assembledParams; } } "!", '%24' => "$", '%26' => "&", '%27' => "'", '%28' => "(", '%29' => ")", '%2A' => "*", '%2B' => "+", '%2C' => ",", '%3A' => ":", '%3B' => ";", '%3D' => "=", '%40' => "@", ); protected $parts; protected $regex; protected $paramMap = array(); protected $defaults; protected $assembledParams = array(); protected $translationKeys = array(); public function __construct($route, array $constraints = array(), array $defaults = array()) { $this->defaults = $defaults; $this->parts = $this->parseRouteDefinition($route); $this->regex = $this->buildRegex($this->parts, $constraints); } public static function factory($options = array()) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (!is_array($options)) { throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options'); } if (!isset($options['route'])) { throw new Exception\InvalidArgumentException('Missing "route" in options array'); } if (!isset($options['constraints'])) { $options['constraints'] = array(); } if (!isset($options['defaults'])) { $options['defaults'] = array(); } return new static($options['route'], $options['constraints'], $options['defaults']); } protected function parseRouteDefinition($def) { $currentPos = 0; $length = strlen($def); $parts = array(); $levelParts = array(&$parts); $level = 0; while ($currentPos < $length) { preg_match('(\G(?P[^:{\[\]]*)(?P[:{\[\]]|$))', $def, $matches, 0, $currentPos); $currentPos += strlen($matches[0]); if (!empty($matches['literal'])) { $levelParts[$level][] = array('literal', $matches['literal']); } if ($matches['token'] === ':') { if (!preg_match('(\G(?P[^:/{\[\]]+)(?:{(?P[^}]+)})?:?)', $def, $matches, 0, $currentPos)) { throw new Exception\RuntimeException('Found empty parameter name'); } $levelParts[$level][] = array('parameter', $matches['name'], isset($matches['delimiters']) ? $matches['delimiters'] : null); $currentPos += strlen($matches[0]); } elseif ($matches['token'] === '{') { if (!preg_match('(\G(?P[^}]+)\})', $def, $matches, 0, $currentPos)) { throw new Exception\RuntimeException('Translated literal missing closing bracket'); } $currentPos += strlen($matches[0]); $levelParts[$level][] = array('translated-literal', $matches['literal']); } elseif ($matches['token'] === '[') { $levelParts[$level][] = array('optional', array()); $levelParts[$level + 1] = &$levelParts[$level][count($levelParts[$level]) - 1][1]; $level++; } elseif ($matches['token'] === ']') { unset($levelParts[$level]); $level--; if ($level < 0) { throw new Exception\RuntimeException('Found closing bracket without matching opening bracket'); } } else { break; } } if ($level > 0) { throw new Exception\RuntimeException('Found unbalanced brackets'); } return $parts; } protected function buildRegex(array $parts, array $constraints, &$groupIndex = 1) { $regex = ''; foreach ($parts as $part) { switch ($part[0]) { case 'literal': $regex .= preg_quote($part[1]); break; case 'parameter': $groupName = '?P'; if (isset($constraints[$part[1]])) { $regex .= '(' . $groupName . $constraints[$part[1]] . ')'; } elseif ($part[2] === null) { $regex .= '(' . $groupName . '[^/]+)'; } else { $regex .= '(' . $groupName . '[^' . $part[2] . ']+)'; } $this->paramMap['param' . $groupIndex++] = $part[1]; break; case 'optional': $regex .= '(?:' . $this->buildRegex($part[1], $constraints, $groupIndex) . ')?'; break; case 'translated-literal': $regex .= '#' . $part[1] . '#'; $this->translationKeys[] = $part[1]; break; } } return $regex; } protected function buildPath(array $parts, array $mergedParams, $isOptional, $hasChild, array $options) { if ($this->translationKeys) { if (!isset($options['translator']) || !$options['translator'] instanceof Translator) { throw new Exception\RuntimeException('No translator provided'); } $translator = $options['translator']; $textDomain = (isset($options['text_domain']) ? $options['text_domain'] : 'default'); $locale = (isset($options['locale']) ? $options['locale'] : null); } $path = ''; $skip = true; $skippable = false; foreach ($parts as $part) { switch ($part[0]) { case 'literal': $path .= $part[1]; break; case 'parameter': $skippable = true; if (!isset($mergedParams[$part[1]])) { if (!$isOptional || $hasChild) { throw new Exception\InvalidArgumentException(sprintf('Missing parameter "%s"', $part[1])); } return ''; } elseif (!$isOptional || $hasChild || !isset($this->defaults[$part[1]]) || $this->defaults[$part[1]] !== $mergedParams[$part[1]]) { $skip = false; } $path .= $this->encode($mergedParams[$part[1]]); $this->assembledParams[] = $part[1]; break; case 'optional': $skippable = true; $optionalPart = $this->buildPath($part[1], $mergedParams, true, $hasChild, $options); if ($optionalPart !== '') { $path .= $optionalPart; $skip = false; } break; case 'translated-literal': $path .= $translator->translate($part[1], $textDomain, $locale); break; } } if ($isOptional && $skippable && $skip) { return ''; } return $path; } public function match(Request $request, $pathOffset = null, array $options = array()) { if (!method_exists($request, 'getUri')) { return null; } $uri = $request->getUri(); $path = $uri->getPath(); $regex = $this->regex; if ($this->translationKeys) { if (!isset($options['translator']) || !$options['translator'] instanceof Translator) { throw new Exception\RuntimeException('No translator provided'); } $translator = $options['translator']; $textDomain = (isset($options['text_domain']) ? $options['text_domain'] : 'default'); $locale = (isset($options['locale']) ? $options['locale'] : null); foreach ($this->translationKeys as $key) { $regex = str_replace('#' . $key . '#', $translator->translate($key, $textDomain, $locale), $regex); } } if ($pathOffset !== null) { $result = preg_match('(\G' . $regex . ')', $path, $matches, null, $pathOffset); } else { $result = preg_match('(^' . $regex . '$)', $path, $matches); } if (!$result) { return null; } $matchedLength = strlen($matches[0]); $params = array(); foreach ($this->paramMap as $index => $name) { if (isset($matches[$index]) && $matches[$index] !== '') { $params[$name] = $this->decode($matches[$index]); } } return new RouteMatch(array_merge($this->defaults, $params), $matchedLength); } public function assemble(array $params = array(), array $options = array()) { $this->assembledParams = array(); return $this->buildPath( $this->parts, array_merge($this->defaults, $params), false, (isset($options['has_child']) ? $options['has_child'] : false), $options ); } public function getAssembledParams() { return $this->assembledParams; } protected function encode($value) { if (!isset(static::$cacheEncode[$value])) { static::$cacheEncode[$value] = rawurlencode($value); static::$cacheEncode[$value] = strtr(static::$cacheEncode[$value], static::$urlencodeCorrectionMap); } return static::$cacheEncode[$value]; } protected function decode($value) { return rawurldecode($value); } } routePluginManager = $routePlugins; if (!$route instanceof RouteInterface) { $route = $this->routeFromArray($route); } if ($route instanceof self) { throw new Exception\InvalidArgumentException('Base route may not be a part route'); } $this->route = $route; $this->mayTerminate = $mayTerminate; $this->childRoutes = $childRoutes; $this->prototypes = $prototypes; $this->routes = new PriorityList(); } public static function factory($options = array()) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (!is_array($options)) { throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options'); } if (!isset($options['route'])) { throw new Exception\InvalidArgumentException('Missing "route" in options array'); } if (!isset($options['route_plugins'])) { throw new Exception\InvalidArgumentException('Missing "route_plugins" in options array'); } if (!isset($options['prototypes'])) { $options['prototypes'] = null; } if (!isset($options['may_terminate'])) { $options['may_terminate'] = false; } if (!isset($options['child_routes']) || !$options['child_routes']) { $options['child_routes'] = null; } if ($options['child_routes'] instanceof Traversable) { $options['child_routes'] = ArrayUtils::iteratorToArray($options['child_routes']); } return new static( $options['route'], $options['may_terminate'], $options['route_plugins'], $options['child_routes'], $options['prototypes'] ); } public function match(Request $request, $pathOffset = null, array $options = array()) { if ($pathOffset === null) { $pathOffset = 0; } $match = $this->route->match($request, $pathOffset, $options); if ($match !== null && method_exists($request, 'getUri')) { if ($this->childRoutes !== null) { $this->addRoutes($this->childRoutes); $this->childRoutes = null; } $nextOffset = $pathOffset + $match->getLength(); $uri = $request->getUri(); $pathLength = strlen($uri->getPath()); if ($this->mayTerminate && $nextOffset === $pathLength) { $query = $uri->getQuery(); if ('' == trim($query) || !$this->hasQueryChild()) { return $match; } } foreach ($this->routes as $name => $route) { if (($subMatch = $route->match($request, $nextOffset, $options)) instanceof RouteMatch) { if ($match->getLength() + $subMatch->getLength() + $pathOffset === $pathLength) { return $match->merge($subMatch)->setMatchedRouteName($name); } } } } return null; } public function assemble(array $params = array(), array $options = array()) { if ($this->childRoutes !== null) { $this->addRoutes($this->childRoutes); $this->childRoutes = null; } $options['has_child'] = (isset($options['name'])); $path = $this->route->assemble($params, $options); $params = array_diff_key($params, array_flip($this->route->getAssembledParams())); if (!isset($options['name'])) { if (!$this->mayTerminate) { throw new Exception\RuntimeException('Part route may not terminate'); } else { return $path; } } unset($options['has_child']); $options['only_return_path'] = true; $path .= parent::assemble($params, $options); return $path; } public function getAssembledParams() { return array(); } protected function hasQueryChild() { foreach ($this->routes as $route) { if ($route instanceof Query) { return true; } } return false; } } keyValueDelimiter = $keyValueDelimiter; $this->paramDelimiter = $paramDelimiter; $this->defaults = $defaults; } public static function factory($options = array()) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (!is_array($options)) { throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options'); } if (!isset($options['key_value_delimiter'])) { $options['key_value_delimiter'] = '/'; } if (!isset($options['param_delimiter'])) { $options['param_delimiter'] = '/'; } if (!isset($options['defaults'])) { $options['defaults'] = array(); } return new static($options['key_value_delimiter'], $options['param_delimiter'], $options['defaults']); } public function match(Request $request, $pathOffset = null) { if (!method_exists($request, 'getUri')) { return null; } $uri = $request->getUri(); $path = $uri->getPath(); if ($path === '/') { $path = ''; } if ($pathOffset !== null) { $path = substr($path, $pathOffset); } $matches = array(); $params = explode($this->paramDelimiter, $path); if (count($params) > 1 && ($params[0] !== '' || end($params) === '')) { return null; } if ($this->keyValueDelimiter === $this->paramDelimiter) { $count = count($params); for ($i = 1; $i < $count; $i += 2) { if (isset($params[$i + 1])) { $matches[rawurldecode($params[$i])] = rawurldecode($params[$i + 1]); } } } else { array_shift($params); foreach ($params as $param) { $param = explode($this->keyValueDelimiter, $param, 2); if (isset($param[1])) { $matches[rawurldecode($param[0])] = rawurldecode($param[1]); } } } return new RouteMatch(array_merge($this->defaults, $matches), strlen($path)); } public function assemble(array $params = array(), array $options = array()) { $elements = array(); $mergedParams = array_merge($this->defaults, $params); $this->assembledParams = array(); if ($mergedParams) { foreach ($mergedParams as $key => $value) { $elements[] = rawurlencode($key) . $this->keyValueDelimiter . rawurlencode($value); $this->assembledParams[] = $key; } return $this->paramDelimiter . implode($this->paramDelimiter, $elements); } return ''; } public function getAssembledParams() { return $this->assembledParams; } } verb = $verb; $this->defaults = $defaults; } public static function factory($options = array()) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (!is_array($options)) { throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options'); } if (!isset($options['verb'])) { throw new Exception\InvalidArgumentException('Missing "verb" in options array'); } if (!isset($options['defaults'])) { $options['defaults'] = array(); } return new static($options['verb'], $options['defaults']); } public function match(Request $request) { if (!method_exists($request, 'getMethod')) { return null; } $requestVerb = strtoupper($request->getMethod()); $matchVerbs = explode(',', strtoupper($this->verb)); $matchVerbs = array_map('trim', $matchVerbs); if (in_array($requestVerb, $matchVerbs)) { return new RouteMatch($this->defaults); } return null; } public function assemble(array $params = array(), array $options = array()) { return ''; } public function getAssembledParams() { return array(); } } length = $length; } public function setMatchedRouteName($name) { if ($this->matchedRouteName === null) { $this->matchedRouteName = $name; } else { $this->matchedRouteName = $name . '/' . $this->matchedRouteName; } return $this; } public function merge(RouteMatch $match) { $this->params = array_merge($this->params, $match->getParams()); $this->length += $match->getLength(); $this->matchedRouteName = $match->getMatchedRouteName(); return $this; } public function getLength() { return $this->length; } } route = $route; $this->defaults = $defaults; } public static function factory($options = array()) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (!is_array($options)) { throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options'); } if (!isset($options['route'])) { throw new Exception\InvalidArgumentException('Missing "route" in options array'); } if (!isset($options['defaults'])) { $options['defaults'] = array(); } return new static($options['route'], $options['defaults']); } public function match(Request $request, $pathOffset = null) { if (!method_exists($request, 'getUri')) { return null; } $uri = $request->getUri(); $path = $uri->getPath(); if ($pathOffset !== null) { if ($pathOffset >= 0 && strlen($path) >= $pathOffset && !empty($this->route)) { if (strpos($path, $this->route, $pathOffset) === $pathOffset) { return new RouteMatch($this->defaults, strlen($this->route)); } } return null; } if ($path === $this->route) { return new RouteMatch($this->defaults, strlen($this->route)); } return null; } public function assemble(array $params = array(), array $options = array()) { return $this->route; } public function getAssembledParams() { return array(); } } sorted = false; $this->count++; $this->routes[$name] = array( 'route' => $route, 'priority' => (int) $priority, 'serial' => $this->serial++, ); } public function remove($name) { if (!isset($this->routes[$name])) { return; } $this->count--; unset($this->routes[$name]); } public function clear() { $this->routes = array(); $this->serial = 0; $this->count = 0; $this->sorted = false; } public function get($name) { if (!isset($this->routes[$name])) { return null; } return $this->routes[$name]['route']; } protected function sort() { uasort($this->routes, array($this, 'compare')); $this->sorted = true; } protected function compare(array $route1, array $route2) { if ($route1['priority'] === $route2['priority']) { return ($route1['serial'] > $route2['serial'] ? -1 : 1); } return ($route1['priority'] > $route2['priority'] ? -1 : 1); } public function rewind() { if (!$this->sorted) { $this->sort(); } reset($this->routes); } public function current() { $node = current($this->routes); return ($node !== false ? $node['route'] : false); } public function key() { return key($this->routes); } public function next() { $node = next($this->routes); return ($node !== false ? $node['route'] : false); } public function valid() { return ($this->current() !== false); } public function count() { return $this->count; } } setAlias($invokableClass, $name); } return $this; } public function validatePlugin($plugin) { if ($plugin instanceof RouteInterface) { return; } throw new Exception\RuntimeException(sprintf( 'Plugin of type %s is invalid; must implement %s\RouteInterface', (is_object($plugin) ? get_class($plugin) : gettype($plugin)), __NAMESPACE__ )); } protected function createFromInvokable($canonicalName, $requestedName) { $invokable = $this->invokableClasses[$canonicalName]; if (!class_exists($invokable)) { throw new Exception\RuntimeException(sprintf( '%s: failed retrieving "%s%s" via invokable class "%s"; class does not exist', __METHOD__, $canonicalName, ($requestedName ? '(alias: ' . $requestedName . ')' : ''), $invokable )); } if (!static::isSubclassOf($invokable, __NAMESPACE__ . '\RouteInterface')) { throw new Exception\RuntimeException(sprintf( '%s: failed retrieving "%s%s" via invokable class "%s"; class does not implement %s\RouteInterface', __METHOD__, $canonicalName, ($requestedName ? '(alias: ' . $requestedName . ')' : ''), $invokable, __NAMESPACE__ )); } return $invokable::factory($this->creationOptions); } } params = $params; } public function setMatchedRouteName($name) { $this->matchedRouteName = $name; return $this; } public function getMatchedRouteName() { return $this->matchedRouteName; } public function setParam($name, $value) { $this->params[$name] = $value; return $this; } public function getParams() { return $this->params; } public function getParam($name, $default = null) { if (array_key_exists($name, $this->params)) { return $this->params[$name]; } return $default; } } routes = new PriorityList(); if (null === $routePluginManager) { $routePluginManager = new RoutePluginManager(); } $this->routePluginManager = $routePluginManager; $this->init(); } public static function factory($options = array()) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (!is_array($options)) { throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options'); } $routePluginManager = null; if (isset($options['route_plugins'])) { $routePluginManager = $options['route_plugins']; } $instance = new static($routePluginManager); if (isset($options['routes'])) { $instance->addRoutes($options['routes']); } if (isset($options['default_params'])) { $instance->setDefaultParams($options['default_params']); } return $instance; } protected function init() { } public function setRoutePluginManager(RoutePluginManager $routePlugins) { $this->routePluginManager = $routePlugins; return $this; } public function getRoutePluginManager() { return $this->routePluginManager; } public function addRoutes($routes) { if (!is_array($routes) && !$routes instanceof Traversable) { throw new Exception\InvalidArgumentException('addRoutes expects an array or Traversable set of routes'); } foreach ($routes as $name => $route) { $this->addRoute($name, $route); } return $this; } public function addRoute($name, $route, $priority = null) { if (!$route instanceof RouteInterface) { $route = $this->routeFromArray($route); } if ($priority === null && isset($route->priority)) { $priority = $route->priority; } $this->routes->insert($name, $route, $priority); return $this; } public function removeRoute($name) { $this->routes->remove($name); return $this; } public function setRoutes($routes) { $this->routes->clear(); $this->addRoutes($routes); return $this; } public function getRoutes() { return $this->routes; } public function hasRoute($name) { return $this->routes->get($name) !== null; } public function getRoute($name) { return $this->routes->get($name); } public function setDefaultParams(array $params) { $this->defaultParams = $params; return $this; } public function setDefaultParam($name, $value) { $this->defaultParams[$name] = $value; return $this; } protected function routeFromArray($specs) { if ($specs instanceof Traversable) { $specs = ArrayUtils::iteratorToArray($specs); } elseif (!is_array($specs)) { throw new Exception\InvalidArgumentException('Route definition must be an array or Traversable object'); } if (!isset($specs['type'])) { throw new Exception\InvalidArgumentException('Missing "type" option'); } elseif (!isset($specs['options'])) { $specs['options'] = array(); } $route = $this->getRoutePluginManager()->get($specs['type'], $specs['options']); if (isset($specs['priority'])) { $route->priority = $specs['priority']; } return $route; } public function match(Request $request) { foreach ($this->routes as $name => $route) { if (($match = $route->match($request)) instanceof RouteMatch) { $match->setMatchedRouteName($name); foreach ($this->defaultParams as $paramName => $value) { if ($match->getParam($paramName) === null) { $match->setParam($paramName, $value); } } return $match; } } return null; } public function assemble(array $params = array(), array $options = array()) { if (!isset($options['name'])) { throw new Exception\InvalidArgumentException('Missing "name" option'); } $route = $this->routes->get($options['name']); if (!$route) { throw new Exception\RuntimeException(sprintf('Route with name "%s" not found', $options['name'])); } unset($options['name']); return $route->assemble(array_merge($this->defaultParams, $params), $options); } } defaults = $defaults; } public static function factory($options = array()) { return new static($options['defaults']); } public function match(Request $request) { if (!$request instanceof ConsoleRequest) { return null; } return new RouteMatch($this->defaults); } public function assemble(array $params = array(), array $options = array()) { $this->assembledParams = array(); } public function getAssembledParams() { return $this->assembledParams; } } length = $length; } public function setMatchedRouteName($name) { if ($this->matchedRouteName === null) { $this->matchedRouteName = $name; } else { $this->matchedRouteName = $name . '/' . $this->matchedRouteName; } return $this; } public function merge(RouteMatch $match) { $this->params = array_merge($this->params, $match->getParams()); $this->length += $match->getLength(); $this->matchedRouteName = $match->getMatchedRouteName(); return $this; } public function getLength() { return $this->length; } } routePluginManager; foreach (array( 'catchall' => __NAMESPACE__ . '\Catchall', 'simple' => __NAMESPACE__ . '\Simple', ) as $name => $class ) { $routes->setInvokableClass($name, $class); }; } public function addRoute($name, $route, $priority = null) { if (!$route instanceof RouteInterface) { $route = $this->routeFromArray($route); } return parent::addRoute($name, $route, $priority); } protected function routeFromArray($specs) { if ($specs instanceof Traversable) { $specs = ArrayUtils::iteratorToArray($specs); } elseif (!is_array($specs)) { throw new Exception\InvalidArgumentException('Route definition must be an array or Traversable object'); } if (!isset($specs['type'])) $specs['type'] = 'simple'; $route = parent::routeFromArray($specs); if (!$route instanceof RouteInterface) { throw new Exception\RuntimeException('Given route does not implement Console route interface'); } return $route; } } defaults = $defaults; $this->constraints = $constraints; $this->aliases = $aliases; if ($filters !== null) { if ($filters instanceof FilterChain) { $this->filters = $filters; } elseif ($filters instanceof Traversable) { $this->filters = new FilterChain(array( 'filters' => ArrayUtils::iteratorToArray($filters, false) )); } elseif (is_array($filters)) { $this->filters = new FilterChain(array( 'filters' => $filters )); } else { throw new InvalidArgumentException('Cannot use ' . gettype($filters) . ' as filters for ' . __CLASS__); } } if ($validators !== null) { if ($validators instanceof ValidatorChain) { $this->validators = $validators; } elseif ($validators instanceof Traversable || is_array($validators)) { $this->validators = new ValidatorChain(); foreach ($validators as $v) { $this->validators->attach($v); } } else { throw new InvalidArgumentException('Cannot use ' . gettype($validators) . ' as validators for ' . __CLASS__); } } $this->parts = $this->parseRouteDefinition($route); } public static function factory($options = array()) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (!is_array($options)) { throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options'); } if (!isset($options['route'])) { throw new Exception\InvalidArgumentException('Missing "route" in options array'); } foreach (array( 'constraints', 'defaults', 'aliases', ) as $opt) { if (!isset($options[$opt])) { $options[$opt] = array(); } } if (!isset($options['validators'])) { $options['validators'] = null; } if (!isset($options['filters'])) { $options['filters'] = null; } return new static( $options['route'], $options['constraints'], $options['defaults'], $options['aliases'], $options['filters'], $options['validators'] ); } protected function parseRouteDefinition($def) { $def = trim($def); $pos = 0; $length = strlen($def); $parts = array(); $unnamedGroupCounter = 1; while ($pos < $length) { if (preg_match('/\G--(?P[a-zA-Z0-9][a-zA-Z0-9\_\-]+)(?P=\S*?)?(?: +|$)/s', $def, $m, 0, $pos)) { $item = array( 'name' => $m['name'], 'short' => false, 'literal' => false, 'required' => true, 'positional' => false, 'hasValue' => !empty($m['hasValue']), ); } elseif (preg_match( '/\G\[ *?--(?P[a-zA-Z0-9][a-zA-Z0-9\_\-]+) *?\](?: +|$)/s', $def, $m, 0, $pos )) { $item = array( 'name' => $m['name'], 'short' => false, 'literal' => false, 'required' => false, 'positional' => false, 'hasValue' => false, ); } elseif (preg_match( '/\G\[ *?--(?P[a-zA-Z0-9][a-zA-Z0-9\_\-]+)(?P=\S*?)? *?\](?: +|$)/s', $def, $m, 0, $pos )) { $item = array( 'name' => $m['name'], 'short' => false, 'literal' => false, 'required' => false, 'positional' => false, 'hasValue' => !empty($m['hasValue']), ); } elseif (preg_match('/\G-(?P[a-zA-Z0-9])(?:=(?P[ns]))?(?: +|$)/s', $def, $m, 0, $pos)) { $item = array( 'name' => $m['name'], 'short' => true, 'literal' => false, 'required' => true, 'positional' => false, 'hasValue' => !empty($m['type']) ? $m['type'] : null, ); } elseif (preg_match('/\G\[ *?-(?P[a-zA-Z0-9])(?:=(?P[ns]))? *?\](?: +|$)/s', $def, $m, 0, $pos)) { $item = array( 'name' => $m['name'], 'short' => true, 'literal' => false, 'required' => false, 'positional' => false, 'hasValue' => !empty($m['type']) ? $m['type'] : null, ); } elseif (preg_match('/ \G \[ (?P (?: \ *? (?P[a-z0-9][a-zA-Z0-9_\-]*?) \ *? (?:\||(?=\])) \ *? )+ ) \] (?:\:(?P[a-zA-Z0-9]+))? (?:\ +|$) /sx', $def, $m, 0, $pos ) ) { $options = preg_split('/ *\| */', trim($m['options']), 0, PREG_SPLIT_NO_EMPTY); array_unique($options); $item = array( 'name' => isset($m['groupName']) ? $m['groupName'] : 'unnamedGroup' . $unnamedGroupCounter++, 'literal' => true, 'required' => false, 'positional' => true, 'alternatives' => $options, 'hasValue' => false, ); } elseif (preg_match('/ \G \( (?P (?: \ *? (?P[a-z0-9][a-zA-Z0-9_\-]+) \ *? (?:\||(?=\))) \ *? )+ ) \) (?:\:(?P[a-zA-Z0-9]+))? (?:\ +|$) /sx', $def, $m, 0, $pos )) { $options = preg_split('/ *\| */', trim($m['options']), 0, PREG_SPLIT_NO_EMPTY); array_unique($options); $item = array( 'name' => isset($m['groupName']) ? $m['groupName']:'unnamedGroupAt' . $unnamedGroupCounter++, 'literal' => true, 'required' => true, 'positional' => true, 'alternatives' => $options, 'hasValue' => false, ); } elseif (preg_match('/ \G \( (?P (?: \ *? \-+(?P[a-zA-Z0-9][a-zA-Z0-9_\-]*?) \ *? (?:\||(?=\))) \ *? )+ ) \) (?:\:(?P[a-zA-Z0-9]+))? (?:\ +|$) /sx', $def, $m, 0, $pos )) { $options = preg_split('/ *\| */', trim($m['options']), 0, PREG_SPLIT_NO_EMPTY); array_unique($options); array_walk($options, function (&$val, $key) { $val = ltrim($val, '-'); }); $item = array( 'name' => isset($m['groupName']) ? $m['groupName']:'unnamedGroupAt' . $unnamedGroupCounter++, 'literal' => false, 'required' => true, 'positional' => false, 'alternatives' => $options, 'hasValue' => false, ); } elseif (preg_match('/ \G \[ (?P (?: \ *? \-+(?P[a-zA-Z0-9][a-zA-Z0-9_\-]*?) \ *? (?:\||(?=\])) \ *? )+ ) \] (?:\:(?P[a-zA-Z0-9]+))? (?:\ +|$) /sx', $def, $m, 0, $pos )) { $options = preg_split('/ *\| */', trim($m['options']), 0, PREG_SPLIT_NO_EMPTY); array_unique($options); array_walk($options, function (&$val, $key) { $val = ltrim($val, '-'); }); $item = array( 'name' => isset($m['groupName']) ? $m['groupName']:'unnamedGroupAt' . $unnamedGroupCounter++, 'literal' => false, 'required' => false, 'positional' => false, 'alternatives' => $options, 'hasValue' => false, ); } elseif (preg_match('/\G\[ *?(?P[a-z0-9][a-zA-Z0-9\_\-]*?) *?\](?: +|$)/s', $def, $m, 0, $pos)) { $item = array( 'name' => $m['name'], 'literal' => true, 'required' => false, 'positional' => true, 'hasValue' => false, ); } elseif (preg_match('/\G\[(?P[a-z0-9][a-zA-Z0-9\_\-]*?)\](?: +|$)/s', $def, $m, 0, $pos)) { $item = array( 'name' => strtolower($m['name']), 'literal' => false, 'required' => false, 'positional' => true, 'hasValue' => true, ); } elseif (preg_match('/\G\[ *\<(?P[a-z0-9][a-zA-Z0-9\_\-]*?)\> *\](?: +|$)/s', $def, $m, 0, $pos)) { $item = array( 'name' => strtolower($m['name']), 'literal' => false, 'required' => false, 'positional' => true, 'hasValue' => true, ); } elseif (preg_match('/\G\< *(?P[a-z0-9][a-zA-Z0-9\_\-]*?) *\>(?: +|$)/s', $def, $m, 0, $pos)) { $item = array( 'name' => $m['name'], 'literal' => false, 'required' => true, 'positional' => true, 'hasValue' => true, ); } elseif (preg_match('/\G(?P[A-Z][a-zA-Z0-9\_\-]*?)(?: +|$)/s', $def, $m, 0, $pos)) { $item = array( 'name' => strtolower($m['name']), 'literal' => false, 'required' => true, 'positional' => true, 'hasValue' => true, ); } elseif (preg_match('/\G(?P[a-z0-9][a-zA-Z0-9\_\-]*?)(?: +|$)/s', $def, $m, 0, $pos)) { $item = array( 'name' => $m['name'], 'literal' => true, 'required' => true, 'positional' => true, 'hasValue' => false, ); } else { throw new Exception\InvalidArgumentException( 'Cannot understand Console route at "' . substr($def, $pos) . '"' ); } $pos += strlen($m[0]); $parts[] = $item; } return $parts; } public function match(Request $request, $pathOffset = null) { if (!$request instanceof ConsoleRequest) { return null; } $params = $request->getParams()->toArray(); $matches = array(); $positional = $named = array(); foreach ($this->parts as &$part) { if ($part['positional']) { $positional[] = &$part; } else { $named[] = &$part; } } foreach ($named as &$part) { if (isset($part['alternatives'])) { $regex = '/^\-+(?P'; $regex .= join('|', $part['alternatives']); if ($part['hasValue']) { $regex .= ')(?:\=(?P.*?)$)?$/'; } else { $regex .= ')$/i'; } } else { if ($part['short'] === true) { if ($part['hasValue']) { $regex = '/^\-' . $part['name'] . '(?:\=(?P.*?)$)?$/i'; } else { $regex = '/^\-' . $part['name'] . '$/i'; } } elseif ($part['short'] === false) { if ($part['hasValue']) { $regex = '/^\-{2,}' . $part['name'] . '(?:\=(?P.*?)$)?$/i'; } else { $regex = '/^\-{2,}' . $part['name'] . '$/i'; } } } $value = $param = null; for ($x = 0, $count = count($params); $x < $count; $x++) { if (preg_match($regex, $params[$x], $m)) { $param = $params[$x]; array_splice($params, $x, 1); if (isset($m['value'])) { $value = $m['value']; } if (isset($m['name'])) { $matchedName = $m['name']; } break; } } if (!$param) { if ($part['required']) { return null; } else { continue; } } if ($param && !$part['hasValue']) { $value = true; } if ((null === $value || "" === $value) && $part['hasValue']) { if ($x < count($params)+1 && isset($params[$x])) { $value = $params[$x]; array_splice($params, $x, 1); } else { return null; } } if ($part['hasValue'] && isset($this->constraints[$part['name']])) { if ( !preg_match($this->constraints[$part['name']], $value) ) { return null; } } if ($part['hasValue']) { $matches[$part['name']] = $value; } else { $matches[$part['name']] = true; } if (isset($part['alternatives'])) { if ($part['hasValue']) { foreach ($part['alternatives'] as $alt) { if ($alt === $matchedName && !isset($matches[$alt])) { $matches[$alt] = $value; } elseif (!isset($matches[$alt])) { $matches[$alt] = null; } } } else { foreach ($part['alternatives'] as $alt) { if ($alt === $matchedName && !isset($matches[$alt])) { $matches[$alt] = isset($this->defaults[$alt])? $this->defaults[$alt] : true; } elseif (!isset($matches[$alt])) { $matches[$alt] = false; } } } } } foreach ($params as $param) { if (preg_match('#^\-+#', $param)) { return null; } } $argPos = 0; foreach ($positional as &$part) { if (!isset($params[$argPos])) { if ($part['required']) { return null; } else { break; } } $value = $params[$argPos]; if ($part['literal']) { if ( (isset($part['alternatives']) && !in_array($value, $part['alternatives'])) || (!isset($part['alternatives']) && $value != $part['name']) ) { return null; } } if ($part['hasValue'] && isset($this->constraints[$part['name']])) { if ( !preg_match($this->constraints[$part['name']], $value) ) { return null; } } if ($part['hasValue']) { $matches[$part['name']] = $value; } elseif (isset($part['alternatives'])) { foreach ($part['alternatives'] as $alt) { if ($alt == $value) { $matches[$alt] = isset($this->defaults[$alt])? $this->defaults[$alt] : true; } else { $matches[$alt] = false; } } $matches[$part['name']] = $value; } elseif (!$part['required']) { $name = $part['name']; $matches[$name] = isset($this->defaults[$name])? $this->defaults[$name] : true; } $argPos++; } if ($argPos < count($params)) { return null; } foreach ($this->parts as &$part) { if (!$part['required'] && !$part['hasValue']) { if (!isset($matches[$part['name']])) { $matches[$part['name']] = false; } if (isset($part['alternatives'])) { foreach ($part['alternatives'] as $alt) { if (!isset($matches[$alt])) { $matches[$alt] = false; } } } } } return new RouteMatch(array_replace($this->defaults, $matches)); } public function assemble(array $params = array(), array $options = array()) { $this->assembledParams = array(); } public function getAssembledParams() { return $this->assembledParams; } } listeners[] = $events->attach(MvcEvent::EVENT_ROUTE, array($this, 'onRoute'), $priority); } public function detach(EventManagerInterface $events) { foreach ($this->listeners as $index => $listener) { if ($events->detach($listener)) { unset($this->listeners[$index]); } } } public function onRoute(MvcEvent $e) { $matches = $e->getRouteMatch(); if (!$matches instanceof Router\RouteMatch) { return; } $module = $matches->getParam(self::MODULE_NAMESPACE, false); if (!$module) { return; } $controller = $matches->getParam('controller', false); if (!$controller) { return; } if (0 === strpos($controller, $module)) { return; } $matches->setParam(self::ORIGINAL_CONTROLLER, $controller); $controller = $module . '\\' . str_replace(' ', '', ucwords(str_replace('-', ' ', $controller))); $matches->setParam('controller', $controller); } } get('Config'), $serviceLocator); } } get('Di'), DiStrictAbstractServiceFactory::USE_SL_BEFORE_DI ); $config = $serviceLocator->get('Config'); if (isset($config['di']['allowed_controllers'])) { $diAbstractFactory->setAllowedServiceNames($config['di']['allowed_controllers']); } return $diAbstractFactory; } } get('Config'); $map = array(); if (is_array($config) && isset($config['view_manager'])) { $config = $config['view_manager']; if (is_array($config) && isset($config['template_map'])) { $map = $config['template_map']; } } return new ViewResolver\TemplateMapResolver($map); } } get('Config'); $templatePathStack = new ViewResolver\TemplatePathStack(); if (is_array($config) && isset($config['view_manager'])) { $config = $config['view_manager']; if (is_array($config)) { if (isset($config['template_path_stack'])) { $templatePathStack->addPaths($config['template_path_stack']); } if (isset($config['default_template_suffix'])) { $templatePathStack->setDefaultSuffix($config['default_template_suffix']); } } } return $templatePathStack; } } get('Di'), $serviceLocator); } } defaultHelperMapClasses as $configClass) { if (is_string($configClass) && class_exists($configClass)) { $config = new $configClass; if (!$config instanceof ConfigInterface) { throw new Exception\RuntimeException(sprintf( 'Invalid service manager configuration class provided; received "%s", expected class implementing %s', $configClass, 'Zend\ServiceManager\ConfigInterface' )); } $config->configureServiceManager($plugins); } } $plugins->setFactory('url', function ($sm) use ($serviceLocator) { $helper = new ViewHelper\Url; $router = Console::isConsole() ? 'HttpRouter' : 'Router'; $helper->setRouter($serviceLocator->get($router)); $match = $serviceLocator->get('application') ->getMvcEvent() ->getRouteMatch() ; if ($match instanceof RouteMatch) { $helper->setRouteMatch($match); } return $helper; }); $plugins->setFactory('basepath', function ($sm) use ($serviceLocator) { $config = $serviceLocator->has('Config') ? $serviceLocator->get('Config') : array(); $basePathHelper = new ViewHelper\BasePath; if (isset($config['view_manager']) && isset($config['view_manager']['base_path'])) { $basePath = $config['view_manager']['base_path']; } else { $basePath = $serviceLocator->get('Request')->getBasePath(); } $basePathHelper->setBasePath($basePath); return $basePathHelper; }); $plugins->setFactory('doctype', function ($sm) use ($serviceLocator) { $config = $serviceLocator->has('Config') ? $serviceLocator->get('Config') : array(); $config = isset($config['view_manager']) ? $config['view_manager'] : array(); $doctypeHelper = new ViewHelper\Doctype; if (isset($config['doctype']) && $config['doctype']) { $doctypeHelper->setDoctype($config['doctype']); } return $doctypeHelper; }); return $plugins; } } has('Config') ? $serviceLocator->get('Config') : array(); $routerClass = 'Zend\Mvc\Router\Http\TreeRouteStack'; $routerConfig = isset($config['router']) ? $config['router'] : array(); if ($rName === 'ConsoleRouter' || ($cName === 'router' && Console::isConsole()) ) { $routerClass = 'Zend\Mvc\Router\Console\SimpleRouteStack'; $routerConfig = isset($config['console']['router']) ? $config['console']['router'] : array(); } if (isset($routerConfig['router_class']) && class_exists($routerConfig['router_class'])) { $routerClass = $routerConfig['router_class']; } if (!isset($routerConfig['route_plugins'])) { $routePluginManager = $serviceLocator->get('RoutePluginManager'); $routerConfig['route_plugins'] = $routePluginManager; } $factory = sprintf('%s::factory', $routerClass); return call_user_func($factory, $routerConfig); } } array( 'DispatchListener' => 'Zend\Mvc\DispatchListener', 'RouteListener' => 'Zend\Mvc\RouteListener', 'SendResponseListener' => 'Zend\Mvc\SendResponseListener' ), 'factories' => array( 'Application' => 'Zend\Mvc\Service\ApplicationFactory', 'Config' => 'Zend\Mvc\Service\ConfigFactory', 'ControllerLoader' => 'Zend\Mvc\Service\ControllerLoaderFactory', 'ControllerPluginManager' => 'Zend\Mvc\Service\ControllerPluginManagerFactory', 'ConsoleAdapter' => 'Zend\Mvc\Service\ConsoleAdapterFactory', 'ConsoleRouter' => 'Zend\Mvc\Service\RouterFactory', 'ConsoleViewManager' => 'Zend\Mvc\Service\ConsoleViewManagerFactory', 'DependencyInjector' => 'Zend\Mvc\Service\DiFactory', 'DiAbstractServiceFactory' => 'Zend\Mvc\Service\DiAbstractServiceFactoryFactory', 'DiServiceInitializer' => 'Zend\Mvc\Service\DiServiceInitializerFactory', 'DiStrictAbstractServiceFactory' => 'Zend\Mvc\Service\DiStrictAbstractServiceFactoryFactory', 'FilterManager' => 'Zend\Mvc\Service\FilterManagerFactory', 'FormElementManager' => 'Zend\Mvc\Service\FormElementManagerFactory', 'HttpRouter' => 'Zend\Mvc\Service\RouterFactory', 'HttpViewManager' => 'Zend\Mvc\Service\HttpViewManagerFactory', 'HydratorManager' => 'Zend\Mvc\Service\HydratorManagerFactory', 'InputFilterManager' => 'Zend\Mvc\Service\InputFilterManagerFactory', 'MvcTranslator' => 'Zend\Mvc\Service\TranslatorServiceFactory', 'PaginatorPluginManager' => 'Zend\Mvc\Service\PaginatorPluginManagerFactory', 'Request' => 'Zend\Mvc\Service\RequestFactory', 'Response' => 'Zend\Mvc\Service\ResponseFactory', 'Router' => 'Zend\Mvc\Service\RouterFactory', 'RoutePluginManager' => 'Zend\Mvc\Service\RoutePluginManagerFactory', 'SerializerAdapterManager' => 'Zend\Mvc\Service\SerializerAdapterPluginManagerFactory', 'ValidatorManager' => 'Zend\Mvc\Service\ValidatorManagerFactory', 'ViewHelperManager' => 'Zend\Mvc\Service\ViewHelperManagerFactory', 'ViewFeedRenderer' => 'Zend\Mvc\Service\ViewFeedRendererFactory', 'ViewFeedStrategy' => 'Zend\Mvc\Service\ViewFeedStrategyFactory', 'ViewJsonRenderer' => 'Zend\Mvc\Service\ViewJsonRendererFactory', 'ViewJsonStrategy' => 'Zend\Mvc\Service\ViewJsonStrategyFactory', 'ViewManager' => 'Zend\Mvc\Service\ViewManagerFactory', 'ViewResolver' => 'Zend\Mvc\Service\ViewResolverFactory', 'ViewTemplateMapResolver' => 'Zend\Mvc\Service\ViewTemplateMapResolverFactory', 'ViewTemplatePathStack' => 'Zend\Mvc\Service\ViewTemplatePathStackFactory', ), 'aliases' => array( 'Configuration' => 'Config', 'Console' => 'ConsoleAdapter', 'Di' => 'DependencyInjector', 'Zend\Di\LocatorInterface' => 'DependencyInjector', 'Zend\Mvc\Controller\PluginManager' => 'ControllerPluginManager', 'Zend\View\Resolver\TemplateMapResolver' => 'ViewTemplateMapResolver', 'Zend\View\Resolver\TemplatePathStack' => 'ViewTemplatePathStack', 'Zend\View\Resolver\AggregateResolver' => 'ViewResolver', 'Zend\View\Resolver\ResolverInterface' => 'ViewResolver', ), 'abstract_factories' => array( 'Zend\Form\FormAbstractServiceFactory', ), ); public function createService(ServiceLocatorInterface $serviceLocator) { $configuration = $serviceLocator->get('ApplicationConfig'); if ($serviceLocator->has('ServiceListenerInterface')) { $serviceListener = $serviceLocator->get('ServiceListenerInterface'); if (!$serviceListener instanceof ServiceListenerInterface) { throw new RuntimeException( 'The service named ServiceListenerInterface must implement ' . 'Zend\ModuleManager\Listener\ServiceListenerInterface' ); } $serviceListener->setDefaultServiceConfig($this->defaultServiceConfig); } else { $serviceListener = new ServiceListener($serviceLocator, $this->defaultServiceConfig); } if (isset($configuration['service_listener_options'])) { if (!is_array($configuration['service_listener_options'])) { throw new InvalidArgumentException(sprintf( 'The value of service_listener_options must be an array, %s given.', gettype($configuration['service_listener_options']) )); } foreach ($configuration['service_listener_options'] as $key => $newServiceManager) { if (!isset($newServiceManager['service_manager'])) { throw new InvalidArgumentException(sprintf(self::MISSING_KEY_ERROR, $key, 'service_manager')); } elseif (!is_string($newServiceManager['service_manager'])) { throw new InvalidArgumentException(sprintf( self::VALUE_TYPE_ERROR, 'service_manager', gettype($newServiceManager['service_manager']) )); } if (!isset($newServiceManager['config_key'])) { throw new InvalidArgumentException(sprintf(self::MISSING_KEY_ERROR, $key, 'config_key')); } elseif (!is_string($newServiceManager['config_key'])) { throw new InvalidArgumentException(sprintf( self::VALUE_TYPE_ERROR, 'config_key', gettype($newServiceManager['config_key']) )); } if (!isset($newServiceManager['interface'])) { throw new InvalidArgumentException(sprintf(self::MISSING_KEY_ERROR, $key, 'interface')); } elseif (!is_string($newServiceManager['interface'])) { throw new InvalidArgumentException(sprintf( self::VALUE_TYPE_ERROR, 'interface', gettype($newServiceManager['interface']) )); } if (!isset($newServiceManager['method'])) { throw new InvalidArgumentException(sprintf(self::MISSING_KEY_ERROR, $key, 'method')); } elseif (!is_string($newServiceManager['method'])) { throw new InvalidArgumentException(sprintf( self::VALUE_TYPE_ERROR, 'method', gettype($newServiceManager['method']) )); } $serviceListener->addServiceManager( $newServiceManager['service_manager'], $newServiceManager['config_key'], $newServiceManager['interface'], $newServiceManager['method'] ); } } return $serviceListener; } } setServiceLocator($serviceLocator); $controllerLoader->addPeeringServiceManager($serviceLocator); $config = $serviceLocator->get('Config'); if (isset($config['di']) && isset($config['di']['allowed_controllers']) && $serviceLocator->has('Di')) { $controllerLoader->addAbstractFactory($serviceLocator->get('DiStrictAbstractServiceFactory')); } return $controllerLoader; } } setSharedManager($serviceLocator->get('SharedEventManager')); return $em; } } attach($serviceLocator->get('ViewTemplateMapResolver')); $resolver->attach($serviceLocator->get('ViewTemplatePathStack')); return $resolver; } } useServiceLocator = $useServiceLocator; $this->di = $di; $this->definitions = $this->di->definitions; $this->instanceManager = $this->di->instanceManager; } public function setAllowedServiceNames(array $allowedServiceNames) { $this->allowedServiceNames = array_flip(array_values($allowedServiceNames)); } public function getAllowedServiceNames() { return array_keys($this->allowedServiceNames); } public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $serviceName, $requestedName) { if (!isset($this->allowedServiceNames[$requestedName])) { throw new Exception\InvalidServiceNameException('Service "' . $requestedName . '" is not whitelisted'); } if ($serviceLocator instanceof AbstractPluginManager) { $this->serviceLocator = $serviceLocator->getServiceLocator(); } else { $this->serviceLocator = $serviceLocator; } return parent::get($requestedName); } public function get($name, array $params = array()) { if (null === $this->serviceLocator) { throw new DomainException('No ServiceLocator defined, use `createServiceWithName` instead of `get`'); } if (self::USE_SL_BEFORE_DI === $this->useServiceLocator && $this->serviceLocator->has($name)) { return $this->serviceLocator->get($name); } try { return parent::get($name, $params); } catch (ClassNotFoundException $e) { if (self::USE_SL_AFTER_DI === $this->useServiceLocator && $this->serviceLocator->has($name)) { return $this->serviceLocator->get($name); } throw new Exception\ServiceNotFoundException( sprintf('Service %s was not found in this DI instance', $name), null, $e ); } } public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) { return isset($this->allowedServiceNames[$requestedName]); } } get('ConsoleViewManager'); } return $serviceLocator->get('HttpViewManager'); } } has('ServiceListener')) { $serviceLocator->setFactory('ServiceListener', 'Zend\Mvc\Service\ServiceListenerFactory'); } $configuration = $serviceLocator->get('ApplicationConfig'); $listenerOptions = new ListenerOptions($configuration['module_listener_options']); $defaultListeners = new DefaultListenerAggregate($listenerOptions); $serviceListener = $serviceLocator->get('ServiceListener'); $serviceListener->addServiceManager( $serviceLocator, 'service_manager', 'Zend\ModuleManager\Feature\ServiceProviderInterface', 'getServiceConfig' ); $serviceListener->addServiceManager( 'ControllerLoader', 'controllers', 'Zend\ModuleManager\Feature\ControllerProviderInterface', 'getControllerConfig' ); $serviceListener->addServiceManager( 'ControllerPluginManager', 'controller_plugins', 'Zend\ModuleManager\Feature\ControllerPluginProviderInterface', 'getControllerPluginConfig' ); $serviceListener->addServiceManager( 'ViewHelperManager', 'view_helpers', 'Zend\ModuleManager\Feature\ViewHelperProviderInterface', 'getViewHelperConfig' ); $serviceListener->addServiceManager( 'ValidatorManager', 'validators', 'Zend\ModuleManager\Feature\ValidatorProviderInterface', 'getValidatorConfig' ); $serviceListener->addServiceManager( 'FilterManager', 'filters', 'Zend\ModuleManager\Feature\FilterProviderInterface', 'getFilterConfig' ); $serviceListener->addServiceManager( 'FormElementManager', 'form_elements', 'Zend\ModuleManager\Feature\FormElementProviderInterface', 'getFormElementConfig' ); $serviceListener->addServiceManager( 'RoutePluginManager', 'route_manager', 'Zend\ModuleManager\Feature\RouteProviderInterface', 'getRouteConfig' ); $serviceListener->addServiceManager( 'SerializerAdapterManager', 'serializers', 'Zend\ModuleManager\Feature\SerializerProviderInterface', 'getSerializerConfig' ); $serviceListener->addServiceManager( 'HydratorManager', 'hydrators', 'Zend\ModuleManager\Feature\HydratorProviderInterface', 'getHydratorConfig' ); $serviceListener->addServiceManager( 'InputFilterManager', 'input_filters', 'Zend\ModuleManager\Feature\InputFilterProviderInterface', 'getInputFilterConfig' ); $events = $serviceLocator->get('EventManager'); $events->attach($defaultListeners); $events->attach($serviceListener); $moduleEvent = new ModuleEvent; $moduleEvent->setParam('ServiceManager', $serviceLocator); $moduleManager = new ModuleManager($configuration['modules'], $events); $moduleManager->setEvent($moduleEvent); return $moduleManager; } } get('Config'); if (isset($config['di'])) { $config = new Config($config['di']); $config->configure($di); } return $di; } } 'Zend\EventManager\SharedEventManager', ); protected $factories = array( 'EventManager' => 'Zend\Mvc\Service\EventManagerFactory', 'ModuleManager' => 'Zend\Mvc\Service\ModuleManagerFactory', ); protected $abstractFactories = array(); protected $aliases = array( 'Zend\EventManager\EventManagerInterface' => 'EventManager', ); protected $shared = array( 'EventManager' => false, ); public function __construct(array $configuration = array()) { if (isset($configuration['invokables'])) { $this->invokables = array_merge($this->invokables, $configuration['invokables']); } if (isset($configuration['factories'])) { $this->factories = array_merge($this->factories, $configuration['factories']); } if (isset($configuration['abstract_factories'])) { $this->abstractFactories = array_merge($this->abstractFactories, $configuration['abstract_factories']); } if (isset($configuration['aliases'])) { $this->aliases = array_merge($this->aliases, $configuration['aliases']); } if (isset($configuration['shared'])) { $this->shared = array_merge($this->shared, $configuration['shared']); } } public function configureServiceManager(ServiceManager $serviceManager) { foreach ($this->invokables as $name => $class) { $serviceManager->setInvokableClass($name, $class); } foreach ($this->factories as $name => $factoryClass) { $serviceManager->setFactory($name, $factoryClass); } foreach ($this->abstractFactories as $factoryClass) { $serviceManager->addAbstractFactory($factoryClass); } foreach ($this->aliases as $name => $service) { $serviceManager->setAlias($name, $service); } foreach ($this->shared as $name => $value) { $serviceManager->setShared($name, $value); } $serviceManager->addInitializer(function ($instance) use ($serviceManager) { if ($instance instanceof EventManagerAwareInterface) { if ($instance->getEventManager() instanceof EventManagerInterface) { $instance->getEventManager()->setSharedManager( $serviceManager->get('SharedEventManager') ); } else { $instance->setEventManager($serviceManager->get('EventManager')); } } }); $serviceManager->addInitializer(function ($instance) use ($serviceManager) { if ($instance instanceof ServiceManagerAwareInterface) { $instance->setServiceManager($serviceManager); } }); $serviceManager->addInitializer(function ($instance) use ($serviceManager) { if ($instance instanceof ServiceLocatorAwareInterface) { $instance->setServiceLocator($serviceManager); } }); $serviceManager->setService('ServiceManager', $serviceManager); $serviceManager->setAlias('Zend\ServiceManager\ServiceLocatorInterface', 'ServiceManager'); $serviceManager->setAlias('Zend\ServiceManager\ServiceManager', 'ServiceManager'); } } get('ViewJsonRenderer'); $jsonStrategy = new JsonStrategy($jsonRenderer); return $jsonStrategy; } } get('Di'), DiAbstractServiceFactory::USE_SL_BEFORE_DI); if ($serviceLocator instanceof ServiceManager) { $serviceLocator->addAbstractFactory($factory); } return $factory; } } addPeeringServiceManager($serviceLocator); $plugins->setRetrieveFromPeeringManagerFirst(true); return $plugins; } } get('Config'); if (!empty($config['console']) && !empty($config['console']['adapter'])) { $adapter = $serviceLocator->get($config['console']['adapter']); } else { $adapter = Console::detectBestAdapter(); $adapter = new $adapter(); } if (!$adapter instanceof AdapterInterface) { return new stdClass(); } if (!empty($config['console']) && !empty($config['console']['charset'])) { $charset = $serviceLocator->get($config['console']['charset']); $adapter->setCharset($charset); } return $adapter; } } get('Config'); $trConfig = isset($config['translator']) ? $config['translator'] : array(); $translator = Translator::factory($trConfig); return $translator; } } get('ViewFeedRenderer'); $feedStrategy = new FeedStrategy($feedRenderer); return $feedStrategy; } } get('ModuleManager'); $mm->loadModules(); $moduleParams = $mm->getEvent()->getParams(); $config = $moduleParams['configListener']->getMergedConfig(false); return $config; } } setServiceLocator($serviceLocator); $configuration = $serviceLocator->get('Config'); if (isset($configuration['di']) && $serviceLocator->has('Di')) { $plugins->addAbstractFactory($serviceLocator->get('DiAbstractServiceFactory')); } return $plugins; } } listeners[] = $events->attach('dispatch', array($this, 'createViewModelFromArray'), -80); $this->listeners[] = $events->attach('dispatch', array($this, 'createViewModelFromNull'), -80); } public function createViewModelFromArray(MvcEvent $e) { $result = $e->getResult(); if (!ArrayUtils::hasStringKeys($result, true)) { return; } $model = new ViewModel($result); $e->setResult($model); } public function createViewModelFromNull(MvcEvent $e) { $result = $e->getResult(); if (null !== $result) { return; } $model = new ViewModel; $e->setResult($model); } } listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'prepareExceptionViewModel')); $this->listeners[] = $events->attach(MvcEvent::EVENT_RENDER_ERROR, array($this, 'prepareExceptionViewModel')); } public function setDisplayExceptions($displayExceptions) { $this->displayExceptions = (bool) $displayExceptions; return $this; } public function displayExceptions() { return $this->displayExceptions; } public function setExceptionTemplate($exceptionTemplate) { $this->exceptionTemplate = (string) $exceptionTemplate; return $this; } public function getExceptionTemplate() { return $this->exceptionTemplate; } public function prepareExceptionViewModel(MvcEvent $e) { $error = $e->getError(); if (empty($error)) { return; } $result = $e->getResult(); if ($result instanceof Response) { return; } switch ($error) { case Application::ERROR_CONTROLLER_NOT_FOUND: case Application::ERROR_CONTROLLER_INVALID: case Application::ERROR_ROUTER_NO_MATCH: return; case Application::ERROR_EXCEPTION: default: $model = new ViewModel(array( 'message' => 'An error occurred during execution; please try again later.', 'exception' => $e->getParam('exception'), 'display_exceptions' => $this->displayExceptions(), )); $model->setTemplate($this->getExceptionTemplate()); $e->setResult($model); $response = $e->getResponse(); if (!$response) { $response = new HttpResponse(); $response->setStatusCode(500); $e->setResponse($response); } else { $statusCode = $response->getStatusCode(); if ($statusCode === 200) { $response->setStatusCode(500); } } break; } } } listeners[] = $events->attach('dispatch', array($this, 'injectParams'), 90); } public function injectParams(MvcEvent $e) { $routeMatchParams = $e->getRouteMatch()->getParams(); $request = $e->getRequest(); if ($request instanceof ConsoleRequest) { $params = $request->params(); } elseif ($request instanceof HttpRequest) { $params = $request->get(); } else { return; } if ($this->overwrite) { foreach ($routeMatchParams as $key => $val) { $params->$key = $val; } } else { foreach ($routeMatchParams as $key => $val) { if (!$params->offsetExists($key)) { $params->$key = $val; } } } } public function setOverwrite($overwrite) { $this->overwrite = $overwrite; } public function getOverwrite() { return $this->overwrite; } } listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'injectViewModel'), -100); $this->listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'injectViewModel'), -100); $this->listeners[] = $events->attach(MvcEvent::EVENT_RENDER_ERROR, array($this, 'injectViewModel'), -100); } public function injectViewModel(MvcEvent $e) { $result = $e->getResult(); if (!$result instanceof ViewModel) { return; } $model = $e->getViewModel(); if ($result->terminate()) { $e->setViewModel($result); return; } if ($e->getError() && $model instanceof ClearableModelInterface) { $model->clearChildren(); } $model->addChild($result); } } listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'prepareNotFoundViewModel'), -90); $this->listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'detectNotFoundError')); $this->listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'prepareNotFoundViewModel')); } public function setDisplayExceptions($displayExceptions) { $this->displayExceptions = (bool) $displayExceptions; return $this; } public function displayExceptions() { return $this->displayExceptions; } public function setDisplayNotFoundReason($displayNotFoundReason) { $this->displayNotFoundReason = (bool) $displayNotFoundReason; return $this; } public function displayNotFoundReason() { return $this->displayNotFoundReason; } public function setNotFoundTemplate($notFoundTemplate) { $this->notFoundTemplate = (string) $notFoundTemplate; return $this; } public function getNotFoundTemplate() { return $this->notFoundTemplate; } public function detectNotFoundError(MvcEvent $e) { $error = $e->getError(); if (empty($error)) { return; } switch ($error) { case Application::ERROR_CONTROLLER_NOT_FOUND: case Application::ERROR_CONTROLLER_INVALID: case Application::ERROR_ROUTER_NO_MATCH: $this->reason = $error; $response = $e->getResponse(); if (!$response) { $response = new HttpResponse(); $e->setResponse($response); } $response->setStatusCode(404); break; default: return; } } public function prepareNotFoundViewModel(MvcEvent $e) { $vars = $e->getResult(); if ($vars instanceof Response) { return; } $response = $e->getResponse(); if ($response->getStatusCode() != 404) { return; } if (!$vars instanceof ViewModel) { $model = new ViewModel(); if (is_string($vars)) { $model->setVariable('message', $vars); } else { $model->setVariable('message', 'Page not found.'); } } else { $model = $vars; if ($model->getVariable('message') === null) { $model->setVariable('message', 'Page not found.'); } } $model->setTemplate($this->getNotFoundTemplate()); $this->injectNotFoundReason($model); $this->injectException($model, $e); $this->injectController($model, $e); $e->setResult($model); } protected function injectNotFoundReason(ViewModel $model) { if (!$this->displayNotFoundReason()) { return; } if ($this->reason) { $model->setVariable('reason', $this->reason); return; } $model->setVariable('reason', Application::ERROR_CONTROLLER_CANNOT_DISPATCH); } protected function injectException($model, $e) { if (!$this->displayExceptions()) { return; } $model->setVariable('display_exceptions', true); $exception = $e->getParam('exception', false); if (!$exception instanceof \Exception) { return; } $model->setVariable('exception', $exception); } protected function injectController($model, $e) { if (!$this->displayExceptions() && !$this->displayNotFoundReason()) { return; } $controller = $e->getController(); if (empty($controller)) { $routeMatch = $e->getRouteMatch(); if (empty($routeMatch)) { return; } $controller = $routeMatch->getParam('controller', false); if (!$controller) { return; } } $controllerClass = $e->getControllerClass(); $model->setVariable('controller', $controller); $model->setVariable('controller_class', $controllerClass); } } listeners[] = $events->attach(MvcEvent::EVENT_BOOTSTRAP, array($this, 'onBootstrap'), 10000); } public function detach(EventManagerInterface $events) { foreach ($this->listeners as $index => $listener) { if ($events->detach($listener)) { unset($this->listeners[$index]); } } } public function onBootstrap($event) { $application = $event->getApplication(); $services = $application->getServiceManager(); $config = $services->get('Config'); $events = $application->getEventManager(); $sharedEvents = $events->getSharedManager(); $this->config = isset($config['view_manager']) && (is_array($config['view_manager']) || $config['view_manager'] instanceof ArrayAccess) ? $config['view_manager'] : array(); $this->services = $services; $this->event = $event; $routeNotFoundStrategy = $this->getRouteNotFoundStrategy(); $exceptionStrategy = $this->getExceptionStrategy(); $mvcRenderingStrategy = $this->getMvcRenderingStrategy(); $createViewModelListener = new CreateViewModelListener(); $injectTemplateListener = new InjectTemplateListener(); $injectViewModelListener = new InjectViewModelListener(); $this->registerMvcRenderingStrategies($events); $this->registerViewStrategies(); $events->attach($routeNotFoundStrategy); $events->attach($exceptionStrategy); $events->attach(MvcEvent::EVENT_DISPATCH_ERROR, array($injectViewModelListener, 'injectViewModel'), -100); $events->attach(MvcEvent::EVENT_RENDER_ERROR, array($injectViewModelListener, 'injectViewModel'), -100); $events->attach($mvcRenderingStrategy); $sharedEvents->attach('Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, array($createViewModelListener, 'createViewModelFromArray'), -80); $sharedEvents->attach('Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, array($routeNotFoundStrategy, 'prepareNotFoundViewModel'), -90); $sharedEvents->attach('Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, array($createViewModelListener, 'createViewModelFromNull'), -80); $sharedEvents->attach('Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, array($injectTemplateListener, 'injectTemplate'), -90); $sharedEvents->attach('Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, array($injectViewModelListener, 'injectViewModel'), -100); } public function getHelperManager() { if ($this->helperManager) { return $this->helperManager; } return $this->helperManager = $this->services->get('ViewHelperManager'); } public function getResolver() { if (null === $this->resolver) { $this->resolver = $this->services->get('ViewResolver'); } return $this->resolver; } public function getRenderer() { if ($this->renderer) { return $this->renderer; } $this->renderer = new ViewPhpRenderer; $this->renderer->setHelperPluginManager($this->getHelperManager()); $this->renderer->setResolver($this->getResolver()); $model = $this->getViewModel(); $modelHelper = $this->renderer->plugin('view_model'); $modelHelper->setRoot($model); $this->services->setService('ViewRenderer', $this->renderer); $this->services->setAlias('Zend\View\Renderer\PhpRenderer', 'ViewRenderer'); $this->services->setAlias('Zend\View\Renderer\RendererInterface', 'ViewRenderer'); return $this->renderer; } public function getRendererStrategy() { if ($this->rendererStrategy) { return $this->rendererStrategy; } $this->rendererStrategy = new PhpRendererStrategy( $this->getRenderer() ); $this->services->setService('ViewPhpRendererStrategy', $this->rendererStrategy); $this->services->setAlias('Zend\View\Strategy\PhpRendererStrategy', 'ViewPhpRendererStrategy'); return $this->rendererStrategy; } public function getView() { if ($this->view) { return $this->view; } $this->view = new View(); $this->view->setEventManager($this->services->get('EventManager')); $this->view->getEventManager()->attach($this->getRendererStrategy()); $this->services->setService('View', $this->view); $this->services->setAlias('Zend\View\View', 'View'); return $this->view; } public function getLayoutTemplate() { $layout = 'layout/layout'; if (isset($this->config['layout'])) { $layout = $this->config['layout']; } return $layout; } public function getMvcRenderingStrategy() { if ($this->mvcRenderingStrategy) { return $this->mvcRenderingStrategy; } $this->mvcRenderingStrategy = new DefaultRenderingStrategy($this->getView()); $this->mvcRenderingStrategy->setLayoutTemplate($this->getLayoutTemplate()); $this->services->setService('DefaultRenderingStrategy', $this->mvcRenderingStrategy); $this->services->setAlias('Zend\Mvc\View\DefaultRenderingStrategy', 'DefaultRenderingStrategy'); $this->services->setAlias('Zend\Mvc\View\Http\DefaultRenderingStrategy', 'DefaultRenderingStrategy'); return $this->mvcRenderingStrategy; } public function getExceptionStrategy() { if ($this->exceptionStrategy) { return $this->exceptionStrategy; } $this->exceptionStrategy = new ExceptionStrategy(); $displayExceptions = false; $exceptionTemplate = 'error'; if (isset($this->config['display_exceptions'])) { $displayExceptions = $this->config['display_exceptions']; } if (isset($this->config['exception_template'])) { $exceptionTemplate = $this->config['exception_template']; } $this->exceptionStrategy->setDisplayExceptions($displayExceptions); $this->exceptionStrategy->setExceptionTemplate($exceptionTemplate); $this->services->setService('ExceptionStrategy', $this->exceptionStrategy); $this->services->setAlias('Zend\Mvc\View\ExceptionStrategy', 'ExceptionStrategy'); $this->services->setAlias('Zend\Mvc\View\Http\ExceptionStrategy', 'ExceptionStrategy'); return $this->exceptionStrategy; } public function getRouteNotFoundStrategy() { if ($this->routeNotFoundStrategy) { return $this->routeNotFoundStrategy; } $this->routeNotFoundStrategy = new RouteNotFoundStrategy(); $displayExceptions = false; $displayNotFoundReason = false; $notFoundTemplate = '404'; if (isset($this->config['display_exceptions'])) { $displayExceptions = $this->config['display_exceptions']; } if (isset($this->config['display_not_found_reason'])) { $displayNotFoundReason = $this->config['display_not_found_reason']; } if (isset($this->config['not_found_template'])) { $notFoundTemplate = $this->config['not_found_template']; } $this->routeNotFoundStrategy->setDisplayExceptions($displayExceptions); $this->routeNotFoundStrategy->setDisplayNotFoundReason($displayNotFoundReason); $this->routeNotFoundStrategy->setNotFoundTemplate($notFoundTemplate); $this->services->setService('RouteNotFoundStrategy', $this->routeNotFoundStrategy); $this->services->setAlias('Zend\Mvc\View\RouteNotFoundStrategy', 'RouteNotFoundStrategy'); $this->services->setAlias('Zend\Mvc\View\Http\RouteNotFoundStrategy', 'RouteNotFoundStrategy'); $this->services->setAlias('404Strategy', 'RouteNotFoundStrategy'); return $this->routeNotFoundStrategy; } public function getViewModel() { if ($this->viewModel) { return $this->viewModel; } $this->viewModel = $model = $this->event->getViewModel(); $model->setTemplate($this->getLayoutTemplate()); return $this->viewModel; } protected function registerMvcRenderingStrategies(EventManagerInterface $events) { if (!isset($this->config['mvc_strategies'])) { return; } $mvcStrategies = $this->config['mvc_strategies']; if (is_string($mvcStrategies)) { $mvcStrategies = array($mvcStrategies); } if (!is_array($mvcStrategies) && !$mvcStrategies instanceof Traversable) { return; } foreach ($mvcStrategies as $mvcStrategy) { if (!is_string($mvcStrategy)) { continue; } $listener = $this->services->get($mvcStrategy); if ($listener instanceof ListenerAggregateInterface) { $events->attach($listener, 100); } } } protected function registerViewStrategies() { if (!isset($this->config['strategies'])) { return; } $strategies = $this->config['strategies']; if (is_string($strategies)) { $strategies = array($strategies); } if (!is_array($strategies) && !$strategies instanceof Traversable) { return; } $view = $this->getView(); foreach ($strategies as $strategy) { if (!is_string($strategy)) { continue; } $listener = $this->services->get($strategy); if ($listener instanceof ListenerAggregateInterface) { $view->getEventManager()->attach($listener, 100); } } } } listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'injectTemplate'), -90); } public function injectTemplate(MvcEvent $e) { $model = $e->getResult(); if (!$model instanceof ViewModel) { return; } $template = $model->getTemplate(); if (!empty($template)) { return; } $routeMatch = $e->getRouteMatch(); $controller = $e->getTarget(); if (is_object($controller)) { $controller = get_class($controller); } if (!$controller) { $controller = $routeMatch->getParam('controller', ''); } $module = $this->deriveModuleNamespace($controller); if ($namespace = $routeMatch->getParam(ModuleRouteListener::MODULE_NAMESPACE)) { $controllerSubNs = $this->deriveControllerSubNamespace($namespace); if (!empty($controllerSubNs)) { if (!empty($module)) { $module .= '/' . $controllerSubNs; } else { $module = $controllerSubNs; } } } $controller = $this->deriveControllerClass($controller); $template = $this->inflectName($module); if (!empty($template)) { $template .= '/'; } $template .= $this->inflectName($controller); $action = $routeMatch->getParam('action'); if (null !== $action) { $template .= '/' . $this->inflectName($action); } $model->setTemplate($template); } protected function inflectName($name) { if (!$this->inflector) { $this->inflector = new CamelCaseToDashFilter(); } $name = $this->inflector->filter($name); return strtolower($name); } protected function deriveModuleNamespace($controller) { if (!strstr($controller, '\\')) { return ''; } $module = substr($controller, 0, strpos($controller, '\\')); return $module; } protected function deriveControllerSubNamespace($namespace) { if (!strstr($namespace, '\\')) { return ''; } $nsArray = explode('\\', $namespace); $subNsArray = array_slice($nsArray, 2); if (empty($subNsArray)) { return ''; } return implode('/', $subNsArray); } protected function deriveControllerClass($controller) { if (strstr($controller, '\\')) { $controller = substr($controller, strrpos($controller, '\\') + 1); } if ((10 < strlen($controller)) && ('Controller' == substr($controller, -10)) ) { $controller = substr($controller, 0, -10); } return $controller; } } view = $view; } public function attach(EventManagerInterface $events) { $this->listeners[] = $events->attach(MvcEvent::EVENT_RENDER, array($this, 'render'), -10000); $this->listeners[] = $events->attach(MvcEvent::EVENT_RENDER_ERROR, array($this, 'render'), -10000); } public function setLayoutTemplate($layoutTemplate) { $this->layoutTemplate = (string) $layoutTemplate; return $this; } public function getLayoutTemplate() { return $this->layoutTemplate; } public function render(MvcEvent $e) { $result = $e->getResult(); if ($result instanceof Response) { return $result; } $request = $e->getRequest(); $response = $e->getResponse(); $viewModel = $e->getViewModel(); if (!$viewModel instanceof ViewModel) { return; } $view = $this->view; $view->setRequest($request); $view->setResponse($response); try { $view->render($viewModel); } catch (\Exception $ex) { if ($e->getName() === MvcEvent::EVENT_RENDER_ERROR) { throw $ex; } $application = $e->getApplication(); $events = $application->getEventManager(); $e->setError(Application::ERROR_EXCEPTION) ->setParam('exception', $ex); $events->trigger(MvcEvent::EVENT_RENDER_ERROR, $e); } return $response; } } listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'createViewModelFromString'), -80); $this->listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'createViewModelFromArray'), -80); $this->listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'createViewModelFromNull'), -80); } public function createViewModelFromString(MvcEvent $e) { $result = $e->getResult(); if (!is_string($result)) { return; } $model = new ConsoleModel; $model->setVariable(ConsoleModel::RESULT, $result); $e->setResult($model); } public function createViewModelFromArray(MvcEvent $e) { $result = $e->getResult(); if (!ArrayUtils::hasStringKeys($result, true)) { return; } $model = new ConsoleModel($result); $e->setResult($model); } public function createViewModelFromNull(MvcEvent $e) { $result = $e->getResult(); if (null !== $result) { return; } $model = new ConsoleModel; $e->setResult($model); } } listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'prepareExceptionViewModel')); $this->listeners[] = $events->attach(MvcEvent::EVENT_RENDER_ERROR, array($this, 'prepareExceptionViewModel')); } public function setDisplayExceptions($displayExceptions) { $this->displayExceptions = (bool) $displayExceptions; return $this; } public function displayExceptions() { return $this->displayExceptions; } public function getMessage() { return $this->message; } public function setMessage($message) { $this->message = $message; return $this; } public function setPreviousMessage($previousMessage) { $this->previousMessage = $previousMessage; return $this; } public function getPreviousMessage() { return $this->previousMessage; } public function prepareExceptionViewModel(MvcEvent $e) { $error = $e->getError(); if (empty($error)) { return; } $result = $e->getResult(); if ($result instanceof Response) { return; } switch ($error) { case Application::ERROR_CONTROLLER_NOT_FOUND: case Application::ERROR_CONTROLLER_INVALID: case Application::ERROR_ROUTER_NO_MATCH: return; case Application::ERROR_EXCEPTION: default: $exception = $e->getParam('exception'); if (is_callable($this->message)) { $callback = $this->message; $message = (string) $callback($exception, $this->displayExceptions); } elseif ($this->displayExceptions && $exception instanceof \Exception) { $previous = ''; $previousException = $exception->getPrevious(); while($previousException) { $previous .= str_replace( array( ':className', ':message', ':code', ':file', ':line', ':stack', ),array( get_class($previousException), $previousException->getMessage(), $previousException->getCode(), $previousException->getFile(), $previousException->getLine(), $exception->getTraceAsString(), ), $this->previousMessage ); $previousException = $previousException->getPrevious(); } $message = str_replace( array( ':className', ':message', ':code', ':file', ':line', ':stack', ':previous', ),array( get_class($exception), $exception->getMessage(), $exception->getCode(), $exception->getFile(), $exception->getLine(), $exception->getTraceAsString(), $previous ), $this->message ); } else { $message = str_replace( array( ':className', ':message', ':code', ':file', ':line', ':stack', ':previous', ),array( '', '', '', '', '', '', '', ), $this->message ); } $model = new ConsoleModel(); $model->setResult($message); $model->setErrorLevel(1); $e->setResult($model); break; } } } listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'handleRouteNotFoundError')); } public function setDisplayNotFoundReason($displayNotFoundReason) { $this->displayNotFoundReason = (bool) $displayNotFoundReason; return $this; } public function displayNotFoundReason() { return $this->displayNotFoundReason; } public function handleRouteNotFoundError(MvcEvent $e) { $error = $e->getError(); if (empty($error)) { return; } $response = $e->getResponse(); $request = $e->getRequest(); switch ($error) { case Application::ERROR_CONTROLLER_NOT_FOUND: case Application::ERROR_CONTROLLER_INVALID: case Application::ERROR_ROUTER_NO_MATCH: $this->reason = $error; if (!$response) { $response = new ConsoleResponse(); $e->setResponse($response); } $response->setMetadata('error', $error); break; default: return; } $result = $e->getResult(); if ($result instanceof Response) { return; } $model = new ConsoleModel(); $model->setErrorLevel(1); $sm = $e->getApplication()->getServiceManager(); $mm = null; try{ $mm = $sm->get('ModuleManager'); } catch (ServiceNotFoundException $e) { } try{ $console = $sm->get('console'); if (!$console instanceof ConsoleAdapter) { throw new ServiceNotFoundException(); } } catch (ServiceNotFoundException $e) { throw new RuntimeException('Cannot access Console adapter - is it defined in ServiceManager?'); } $router = null; try{ $router = $sm->get('Router'); } catch (ServiceNotFoundException $e) { } $scriptName = ''; if ($request instanceof ConsoleRequest) { $scriptName = basename($request->getScriptName()); } $banner = $this->getConsoleBanner($console, $mm); $usage = $this->getConsoleUsage($console, $scriptName, $mm); $result = $banner ? rtrim($banner, "\r\n") : ''; $result .= $usage ? "\n\n" . trim($usage, "\r\n") : ''; $result .= "\n"; $result .= $this->reportNotFoundReason($e); $model->setResult($result); $e->setResult($model); } protected function getConsoleBanner(ConsoleAdapter $console, ModuleManagerInterface $moduleManager = null) { $banners = array(); if ($moduleManager !== null) { foreach ($moduleManager->getLoadedModules(false) as $module) { if (!$module instanceof ConsoleBannerProviderInterface && !method_exists($module, 'getConsoleBanner') ) { continue; } $banner = $module->getConsoleBanner($console); if ($banner == '') { continue; } $banners[] = $console->colorize($banner, ColorInterface::BLUE); } } if (!count($banners)) { return sprintf("Zend Framework %s application\nUsage:\n", Version::VERSION); } return implode("\n", $banners); } protected function getConsoleUsage( ConsoleAdapter $console, $scriptName, ModuleManagerInterface $moduleManager = null ) { $usageInfo = array(); if ($moduleManager !== null) { foreach ($moduleManager->getLoadedModules(false) as $name => $module) { if (!$module instanceof ConsoleUsageProviderInterface && !method_exists($module, 'getConsoleUsage') ) { continue; } $moduleName = sprintf("%s\n%s\n%s\n", str_repeat('-', $console->getWidth()), $name, str_repeat('-', $console->getWidth()) ); $moduleName = $console->colorize($moduleName, ColorInterface::RED); $usage = $module->getConsoleUsage($console); if (is_array($usage) && !empty($usage)) { array_unshift($usage, $moduleName); $usageInfo[$name] = $usage; } elseif (is_string($usage) && ($usage != '')) { $usageInfo[$name] = array($moduleName, $usage); } } } if (!count($usageInfo)) { return ''; } $result = ''; $table = false; $tableCols = 0; $tableType = 0; foreach ($usageInfo as $moduleName => $usage) { if (!is_string($usage) && !is_array($usage)) { throw new RuntimeException(sprintf( 'Cannot understand usage info for module "%s"', $moduleName )); } if (is_string($usage)) { $result .= $usage . "\n"; continue; } foreach ($usage as $a => $b) { if (is_string($a) && is_string($b)) { if (($tableCols !== 2 || $tableType != 1) && $table !== false) { $result .= $this->renderTable($table, $tableCols, $console->getWidth()); $table = false; $result .= "\n"; } $a = $console->colorize($scriptName . ' ' . $a, ColorInterface::GREEN); $tableCols = 2; $tableType = 1; $table[] = array($a, $b); continue; } if (is_array($b)) { if ((count($b) != $tableCols || $tableType != 2) && $table !== false) { $result .= $this->renderTable($table, $tableCols, $console->getWidth()); $table = false; $result .= "\n"; } $tableCols = count($b); $tableType = 2; $table[] = $b; continue; } if ($table !== false) { $result .= $this->renderTable($table, $tableCols, $console->getWidth()); $table = false; $result .= "\n"; } $tableType = 0; $result .= $b . "\n"; } } if ($table !== false) { $result .= $this->renderTable($table, $tableCols, $console->getWidth()); } return $result; } protected function renderTable($data, $cols, $consoleWidth) { $result = ''; $padding = 2; if ($cols == 1) { foreach ($data as $row) { $result .= $row[0] . "\n"; } return $result; } $strWrapper = StringUtils::getWrapper('UTF-8'); $maxW = array(); for ($x = 1; $x <= $cols; $x += 1) { $maxW[$x] = 0; foreach ($data as $row) { $maxW[$x] = max($maxW[$x], $strWrapper->strlen($row[$x-1]) + $padding * 2); } } $width = 0; for ($x = 1; $x < $cols; $x += 1) { $width += $maxW[$x]; } if ($width >= $consoleWidth - 10) { foreach ($data as $row) { $result .= implode(" ", $row) . "\n"; } return $result; } $maxW[$cols] = $consoleWidth - $width -1; $table = new Table\Table(); $table->setColumnWidths($maxW); $table->setDecorator(new Table\Decorator\Blank()); $table->setPadding(2); foreach ($data as $row) { $table->appendRow($row); } return $table->render(); } protected function reportNotFoundReason($e) { if (!$this->displayNotFoundReason()) { return ''; } $exception = $e->getParam('exception', false); if (!$exception && !$this->reason) { return ''; } $reason = (isset($this->reason) && !empty($this->reason)) ? $this->reason : 'unknown'; $reasons = array( Application::ERROR_CONTROLLER_NOT_FOUND => 'Could not match to a controller', Application::ERROR_CONTROLLER_INVALID => 'Invalid controller specified', Application::ERROR_ROUTER_NO_MATCH => 'Invalid arguments or no arguments provided', 'unknown' => 'Unknown', ); $report = sprintf("\nReason for failure: %s\n", $reasons[$reason]); while ($exception instanceof \Exception) { $report .= sprintf("Exception: %s\nTrace:\n%s\n", $exception->getMessage(), $exception->getTraceAsString()); $exception = $exception->getPrevious(); } return $report; } } getApplication(); $services = $application->getServiceManager(); $config = $services->get('Config'); $events = $application->getEventManager(); $sharedEvents = $events->getSharedManager(); $this->config = isset($config['view_manager']) && (is_array($config['view_manager']) || $config['view_manager'] instanceof ArrayAccess) ? $config['view_manager'] : array(); $this->services = $services; $this->event = $event; $routeNotFoundStrategy = $this->getRouteNotFoundStrategy(); $exceptionStrategy = $this->getExceptionStrategy(); $mvcRenderingStrategy = $this->getMvcRenderingStrategy(); $createViewModelListener = new CreateViewModelListener(); $injectViewModelListener = new InjectViewModelListener(); $injectParamsListener = new InjectNamedConsoleParamsListener(); $this->registerMvcRenderingStrategies($events); $this->registerViewStrategies(); $events->attach($routeNotFoundStrategy); $events->attach($exceptionStrategy); $events->attach(MvcEvent::EVENT_DISPATCH_ERROR, array($injectViewModelListener, 'injectViewModel'), -100); $events->attach(MvcEvent::EVENT_RENDER_ERROR, array($injectViewModelListener, 'injectViewModel'), -100); $events->attach($mvcRenderingStrategy); $sharedEvents->attach('Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, array($injectParamsListener, 'injectNamedParams'), 1000); $sharedEvents->attach('Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, array($createViewModelListener, 'createViewModelFromArray'), -80); $sharedEvents->attach('Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, array($createViewModelListener, 'createViewModelFromString'), -80); $sharedEvents->attach('Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, array($createViewModelListener, 'createViewModelFromNull'), -80); $sharedEvents->attach('Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, array($injectViewModelListener, 'injectViewModel'), -100); } public function getMvcRenderingStrategy() { if ($this->mvcRenderingStrategy) { return $this->mvcRenderingStrategy; } $this->mvcRenderingStrategy = new DefaultRenderingStrategy(); $this->services->setService('DefaultRenderingStrategy', $this->mvcRenderingStrategy); $this->services->setAlias('Zend\Mvc\View\DefaultRenderingStrategy', 'DefaultRenderingStrategy'); $this->services->setAlias('Zend\Mvc\View\Console\DefaultRenderingStrategy', 'DefaultRenderingStrategy'); return $this->mvcRenderingStrategy; } public function getExceptionStrategy() { if ($this->exceptionStrategy) { return $this->exceptionStrategy; } $this->exceptionStrategy = new ExceptionStrategy(); if (isset($this->config['display_exceptions'])) { $this->exceptionStrategy->setDisplayExceptions($this->config['display_exceptions']); } if (isset($this->config['exception_message'])) { $this->exceptionStrategy->setMessage($this->config['exception_message']); } $this->services->setService('ExceptionStrategy', $this->exceptionStrategy); $this->services->setAlias('Zend\Mvc\View\ExceptionStrategy', 'ExceptionStrategy'); $this->services->setAlias('Zend\Mvc\View\Console\ExceptionStrategy', 'ExceptionStrategy'); return $this->exceptionStrategy; } public function getRouteNotFoundStrategy() { if ($this->routeNotFoundStrategy) { return $this->routeNotFoundStrategy; } $this->routeNotFoundStrategy = new RouteNotFoundStrategy(); $displayNotFoundReason = true; if (array_key_exists('display_not_found_reason', $this->config)) { $displayNotFoundReason = $this->config['display_not_found_reason']; } $this->routeNotFoundStrategy->setDisplayNotFoundReason($displayNotFoundReason); $this->services->setService('RouteNotFoundStrategy', $this->routeNotFoundStrategy); $this->services->setAlias('Zend\Mvc\View\RouteNotFoundStrategy', 'RouteNotFoundStrategy'); $this->services->setAlias('Zend\Mvc\View\Console\RouteNotFoundStrategy', 'RouteNotFoundStrategy'); $this->services->setAlias('404Strategy', 'RouteNotFoundStrategy'); return $this->routeNotFoundStrategy; } } listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'injectNamedParams'), -80); } public function injectNamedParams(MvcEvent $e) { if (!$routeMatch = $e->getRouteMatch()) { return; } $request = $e->getRequest(); if (!$request instanceof ConsoleRequest) { return; } $params = array_merge( $request->getParams()->toArray(), $routeMatch->getParams() ); $request->getParams()->fromArray($params); } } listeners[] = $events->attach(MvcEvent::EVENT_RENDER, array($this, 'render'), -10000); } public function render(MvcEvent $e) { $result = $e->getResult(); if ($result instanceof Response) { return $result; } $response = $e->getResponse(); if (empty($result)) { return $response; } $responseText = ''; if ($result->hasChildren()) { foreach ($result->getChildren() as $child) { $responseText .= $child->getVariable(ConsoleViewModel::RESULT); } } if ($result instanceof ConsoleViewModel) { $responseText .= $result->getResult(); } else { $responseText .= $result->getVariable(ConsoleViewModel::RESULT); } $response->setContent( $response->getContent() . $responseText ); if ($response instanceof ConsoleResponse && $result instanceof ConsoleViewModel ) { $errorLevel = $result->getErrorLevel(); $response->setErrorLevel($errorLevel); } return $response; } } 'Zend\Mvc\Controller\Plugin\Service\ForwardFactory', 'identity' => 'Zend\Mvc\Controller\Plugin\Service\IdentityFactory', ); protected $invokableClasses = array( 'acceptableviewmodelselector' => 'Zend\Mvc\Controller\Plugin\AcceptableViewModelSelector', 'filepostredirectget' => 'Zend\Mvc\Controller\Plugin\FilePostRedirectGet', 'flashmessenger' => 'Zend\Mvc\Controller\Plugin\FlashMessenger', 'layout' => 'Zend\Mvc\Controller\Plugin\Layout', 'params' => 'Zend\Mvc\Controller\Plugin\Params', 'postredirectget' => 'Zend\Mvc\Controller\Plugin\PostRedirectGet', 'redirect' => 'Zend\Mvc\Controller\Plugin\Redirect', 'url' => 'Zend\Mvc\Controller\Plugin\Url', ); protected $aliases = array( 'prg' => 'postredirectget', 'fileprg' => 'filepostredirectget', ); protected $controller; public function get($name, $options = array(), $usePeeringServiceManagers = true) { $plugin = parent::get($name, $options, $usePeeringServiceManagers); $this->injectController($plugin); return $plugin; } public function setController(DispatchableInterface $controller) { $this->controller = $controller; return $this; } public function getController() { return $this->controller; } public function injectController($plugin) { if (!is_object($plugin)) { return; } if (!method_exists($plugin, 'setController')) { return; } $controller = $this->getController(); if (!$controller instanceof DispatchableInterface) { return; } $plugin->setController($controller); } public function validatePlugin($plugin) { if ($plugin instanceof Plugin\PluginInterface) { return; } throw new Exception\InvalidPluginException(sprintf( 'Plugin of type %s is invalid; must implement %s\Plugin\PluginInterface', (is_object($plugin) ? get_class($plugin) : gettype($plugin)), __NAMESPACE__ )); } } addInitializer(array($this, 'injectControllerDependencies'), false); } public function injectControllerDependencies($controller, ServiceLocatorInterface $serviceLocator) { if (!$controller instanceof DispatchableInterface) { return; } $parentLocator = $serviceLocator->getServiceLocator(); if ($controller instanceof ServiceLocatorAwareInterface) { $controller->setServiceLocator($parentLocator->get('Zend\ServiceManager\ServiceLocatorInterface')); } if ($controller instanceof EventManagerAwareInterface) { $events = $controller->getEventManager(); if (!$events instanceof EventManagerInterface) { $controller->setEventManager($parentLocator->get('EventManager')); } else { $events->setSharedManager($parentLocator->get('SharedEventManager')); } } if (method_exists($controller, 'setPluginManager')) { $controller->setPluginManager($parentLocator->get('ControllerPluginManager')); } } public function validatePlugin($plugin) { if ($plugin instanceof DispatchableInterface) { return; } throw new Exception\InvalidControllerException(sprintf( 'Controller of type %s is invalid; must implement Zend\Stdlib\DispatchableInterface', (is_object($plugin) ? get_class($plugin) : gettype($plugin)) )); } public function has($name, $checkAbstractFactories = true, $usePeeringServiceManagers = false) { return parent::has($name, $checkAbstractFactories, $usePeeringServiceManagers); } public function get($name, $options = array(), $usePeeringServiceManagers = false) { return parent::get($name, $options, $usePeeringServiceManagers); } } controllers = $controllers; } public function setMaxNestedForwards($maxNestedForwards) { $this->maxNestedForwards = (int) $maxNestedForwards; return $this; } public function getListenersToDetach() { if (null === $this->listenersToDetach) { $this->listenersToDetach = array(array( 'id' => 'Zend\Stdlib\DispatchableInterface', 'event' => MvcEvent::EVENT_DISPATCH, 'class' => 'Zend\Mvc\View\Http\InjectViewModelListener', )); } return $this->listenersToDetach; } public function setListenersToDetach($listeners) { $this->listenersToDetach = $listeners; } public function dispatch($name, array $params = null) { $event = clone($this->getEvent()); $controller = $this->controllers->get($name); if ($controller instanceof InjectApplicationEventInterface) { $controller->setEvent($event); } if ($params !== null) { $routeMatch = new RouteMatch($params); $routeMatch->setMatchedRouteName($event->getRouteMatch()->getMatchedRouteName()); $event->setRouteMatch($routeMatch); } if ($this->numNestedForwards > $this->maxNestedForwards) { throw new Exception\DomainException("Circular forwarding detected: greater than $this->maxNestedForwards nested forwards"); } $this->numNestedForwards++; $sharedEvents = $event->getApplication()->getEventManager()->getSharedManager(); $listeners = $this->detachProblemListeners($sharedEvents); $return = $controller->dispatch($event->getRequest(), $event->getResponse()); $this->reattachProblemListeners($sharedEvents, $listeners); $this->numNestedForwards--; return $return; } protected function detachProblemListeners(SharedEvents $sharedEvents) { $formattedProblems = array(); foreach ($this->getListenersToDetach() as $current) { if (!isset($formattedProblems[$current['id']])) { $formattedProblems[$current['id']] = array(); } if (!isset($formattedProblems[$current['id']][$current['event']])) { $formattedProblems[$current['id']][$current['event']] = array(); } $formattedProblems[$current['id']][$current['event']][] = $current['class']; } $results = array(); foreach ($formattedProblems as $id => $eventArray) { $results[$id] = array(); foreach ($eventArray as $eventName => $classArray) { $results[$id][$eventName] = array(); $events = $sharedEvents->getListeners($id, $eventName); foreach ($events as $currentEvent) { $currentCallback = $currentEvent->getCallback(); if (!isset($currentCallback[0])) { continue; } foreach ($classArray as $class) { if (is_a($currentCallback[0], $class)) { $sharedEvents->detach($id, $currentEvent); $results[$id][$eventName][] = $currentEvent; } } } } } return $results; } protected function reattachProblemListeners(SharedEvents $sharedEvents, array $listeners) { foreach ($listeners as $id => $eventArray) { foreach ($eventArray as $eventName => $callbacks) { foreach ($callbacks as $current) { $sharedEvents->attach($id, $eventName, $current->getCallback(), $current->getMetadatum('priority')); } } } } protected function getEvent() { if ($this->event) { return $this->event; } $controller = $this->getController(); if (!$controller instanceof InjectApplicationEventInterface) { throw new Exception\DomainException('Forward plugin requires a controller that implements InjectApplicationEventInterface'); } $event = $controller->getEvent(); if (!$event instanceof MvcEvent) { $params = array(); if ($event) { $params = $event->getParams(); } $event = new MvcEvent(); $event->setParams($params); } $this->event = $event; return $this->event; } } getViewModel($matchAgainst, $returnDefault, $resultReference); } public function getViewModel( array $matchAgainst = null, $returnDefault = true, & $resultReference = null ) { $name = $this->getViewModelName($matchAgainst, $returnDefault, $resultReference); if (!$name) { return; } if (!class_exists($name)) { throw new InvalidArgumentException('The supplied View Model could not be found'); } return new $name(); } public function getViewModelName( array $matchAgainst = null, $returnDefault = true, & $resultReference = null ) { $res = $this->match($matchAgainst); if ($res) { $resultReference = $res; return $this->extractViewModelName($res); } if ($returnDefault) { return $this->defaultViewModelName; } } public function match(array $matchAgainst = null) { $request = $this->getRequest(); $headers = $request->getHeaders(); if ((!$matchAgainst && !$this->defaultMatchAgainst) || !$headers->has('accept')) { return null; } if (!$matchAgainst) { $matchAgainst = $this->defaultMatchAgainst; } $matchAgainstString = ''; foreach ($matchAgainst as $modelName => $modelStrings) { foreach ((array) $modelStrings as $modelString) { $matchAgainstString .= $this->injectViewModelName($modelString, $modelName); } } $accept = $headers->get('Accept'); if (($res = $accept->match($matchAgainstString)) === false) { return null; } return $res; } public function setDefaultViewModelName($defaultViewModelName) { $this->defaultViewModelName = (string) $defaultViewModelName; return $this; } public function getDefaultViewModelName() { return $this->defaultViewModelName; } public function setDefaultMatchAgainst(array $matchAgainst = null) { $this->defaultMatchAgainst = $matchAgainst; return $this; } public function getDefaultMatchAgainst() { return $this->defaultMatchAgainst; } protected function injectViewModelName($modelAcceptString, $modelName) { $modelName = str_replace('\\', '|', $modelName); return $modelAcceptString . '; ' . self::INJECT_VIEWMODEL_NAME . '="' . $modelName . '", '; } protected function extractViewModelName(AbstractFieldValuePart $res) { $modelName = $res->getMatchedAgainst()->params[self::INJECT_VIEWMODEL_NAME]; return str_replace('|', '\\', $modelName); } protected function getRequest() { if ($this->request) { return $this->request; } $event = $this->getEvent(); $request = $event->getRequest(); if (!$request instanceof Request) { throw new DomainException( 'The event used does not contain a valid Request, but must.' ); } $this->request = $request; return $request; } protected function getEvent() { if ($this->event) { return $this->event; } $controller = $this->getController(); if (!$controller instanceof InjectApplicationEventInterface) { throw new DomainException( 'A controller that implements InjectApplicationEventInterface ' . 'is required to use ' . __CLASS__ ); } $event = $controller->getEvent(); if (!$event instanceof MvcEvent) { $params = $event->getParams(); $event = new MvcEvent(); $event->setParams($params); } $this->event = $event; return $this->event; } } controller = $controller; } public function getController() { return $this->controller; } } getViewModel(); $viewModel->setTemplate((string) $template); return $this; } public function __invoke($template = null) { if (null === $template) { return $this->getViewModel(); } return $this->setTemplate($template); } protected function getEvent() { if ($this->event) { return $this->event; } $controller = $this->getController(); if (!$controller instanceof InjectApplicationEventInterface) { throw new Exception\DomainException('Layout plugin requires a controller that implements InjectApplicationEventInterface'); } $event = $controller->getEvent(); if (!$event instanceof MvcEvent) { $params = $event->getParams(); $event = new MvcEvent(); $event->setParams($params); } $this->event = $event; return $this->event; } protected function getViewModel() { $event = $this->getEvent(); $viewModel = $event->getViewModel(); if (!$viewModel instanceof Model) { throw new Exception\DomainException('Layout plugin requires that event view model is populated'); } return $viewModel; } } getServiceLocator(); if (!$services instanceof ServiceLocatorInterface) { throw new ServiceNotCreatedException(sprintf( '%s requires that the application service manager has been injected; none found', __CLASS__ )); } if (!$services->has('ControllerLoader')) { throw new ServiceNotCreatedException(sprintf( '%s requires that the application service manager contains a "%s" service; none found', __CLASS__, 'ControllerLoader' )); } $controllers = $services->get('ControllerLoader'); return new Forward($controllers); } } getServiceLocator(); $helper = new Identity(); if ($services->has('Zend\Authentication\AuthenticationService')) { $helper->setAuthenticationService($services->get('Zend\Authentication\AuthenticationService')); } return $helper; } } getController(); if (!$controller instanceof InjectApplicationEventInterface) { throw new Exception\DomainException('Url plugin requires a controller that implements InjectApplicationEventInterface'); } if (!is_array($params)) { if (!$params instanceof Traversable) { throw new Exception\InvalidArgumentException( 'Params is expected to be an array or a Traversable object' ); } $params = iterator_to_array($params); } $event = $controller->getEvent(); $router = null; $matches = null; if ($event instanceof MvcEvent) { $router = $event->getRouter(); $matches = $event->getRouteMatch(); } elseif ($event instanceof EventInterface) { $router = $event->getParam('router', false); $matches = $event->getParam('route-match', false); } if (!$router instanceof RouteStackInterface) { throw new Exception\DomainException('Url plugin requires that controller event compose a router; none found'); } if (3 == func_num_args() && is_bool($options)) { $reuseMatchedParams = $options; $options = array(); } if ($route === null) { if (!$matches) { throw new Exception\RuntimeException('No RouteMatch instance present'); } $route = $matches->getMatchedRouteName(); if ($route === null) { throw new Exception\RuntimeException('RouteMatch does not contain a matched route name'); } } if ($reuseMatchedParams && $matches) { $routeMatchParams = $matches->getParams(); if (isset($routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER])) { $routeMatchParams['controller'] = $routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER]; unset($routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER]); } if (isset($routeMatchParams[ModuleRouteListener::MODULE_NAMESPACE])) { unset($routeMatchParams[ModuleRouteListener::MODULE_NAMESPACE]); } $params = array_merge($routeMatchParams, $params); } $options['name'] = $route; return $router->assemble($params, $options); } } getController(); if (!$controller || !method_exists($controller, 'plugin')) { throw new Exception\DomainException('Redirect plugin requires a controller that defines the plugin() method'); } $urlPlugin = $controller->plugin('url'); if (is_scalar($options)) { $url = $urlPlugin->fromRoute($route, $params, $options); } else { $url = $urlPlugin->fromRoute($route, $params, $options, $reuseMatchedParams); } return $this->toUrl($url); } public function toUrl($url) { $response = $this->getResponse(); $response->getHeaders()->addHeaderLine('Location', $url); $response->setStatusCode(302); return $response; } public function refresh() { return $this->toRoute(null, array(), array(), true); } protected function getResponse() { if ($this->response) { return $this->response; } $event = $this->getEvent(); $response = $event->getResponse(); if (!$response instanceof Response) { throw new Exception\DomainException('Redirect plugin requires event compose a response'); } $this->response = $response; return $this->response; } protected function getEvent() { if ($this->event) { return $this->event; } $controller = $this->getController(); if (!$controller instanceof InjectApplicationEventInterface) { throw new Exception\DomainException('Redirect plugin requires a controller that implements InjectApplicationEventInterface'); } $event = $controller->getEvent(); if (!$event instanceof MvcEvent) { $params = $event->getParams(); $event = new MvcEvent(); $event->setParams($params); } $this->event = $event; return $this->event; } } fromRoute($param, $default); } public function fromFiles($name = null, $default = null) { if ($name === null) { return $this->getController()->getRequest()->getFiles($name, $default)->toArray(); } return $this->getController()->getRequest()->getFiles($name, $default); } public function fromHeader($header = null, $default = null) { if ($header === null) { return $this->getController()->getRequest()->getHeaders($header, $default)->toArray(); } return $this->getController()->getRequest()->getHeaders($header, $default); } public function fromPost($param = null, $default = null) { if ($param === null) { return $this->getController()->getRequest()->getPost($param, $default)->toArray(); } return $this->getController()->getRequest()->getPost($param, $default); } public function fromQuery($param = null, $default = null) { if ($param === null) { return $this->getController()->getRequest()->getQuery($param, $default)->toArray(); } return $this->getController()->getRequest()->getQuery($param, $default); } public function fromRoute($param = null, $default = null) { $controller = $this->getController(); if (!$controller instanceof InjectApplicationEventInterface) { throw new RuntimeException( 'Controllers must implement Zend\Mvc\InjectApplicationEventInterface to use this plugin.' ); } if ($param === null) { return $controller->getEvent()->getRouteMatch()->getParams(); } return $controller->getEvent()->getRouteMatch()->getParam($param, $default); } } authenticationService; } public function setAuthenticationService(AuthenticationService $authenticationService) { $this->authenticationService = $authenticationService; } public function __invoke() { if (!$this->authenticationService instanceof AuthenticationService) { throw new Exception\RuntimeException('No AuthenticationService instance provided'); } if (!$this->authenticationService->hasIdentity()) { return null; } return $this->authenticationService->getIdentity(); } } session = $manager; return $this; } public function getSessionManager() { if (!$this->session instanceof Manager) { $this->setSessionManager(Container::getDefaultManager()); } return $this->session; } public function getContainer() { if ($this->container instanceof Container) { return $this->container; } $manager = $this->getSessionManager(); $this->container = new Container('FlashMessenger', $manager); return $this->container; } public function setNamespace($namespace = 'default') { $this->namespace = $namespace; return $this; } public function getNamespace() { return $this->namespace; } public function addMessage($message) { $container = $this->getContainer(); $namespace = $this->getNamespace(); if (!$this->messageAdded) { $this->getMessagesFromContainer(); $container->setExpirationHops(1, null); } if (!isset($container->{$namespace}) || !($container->{$namespace} instanceof SplQueue) ) { $container->{$namespace} = new SplQueue(); } $container->{$namespace}->push($message); $this->messageAdded = true; return $this; } public function addInfoMessage($message) { $namespace = $this->getNamespace(); $this->setNamespace(self::NAMESPACE_INFO); $this->addMessage($message); $this->setNamespace($namespace); return $this; } public function addSuccessMessage($message) { $namespace = $this->getNamespace(); $this->setNamespace(self::NAMESPACE_SUCCESS); $this->addMessage($message); $this->setNamespace($namespace); return $this; } public function addErrorMessage($message) { $namespace = $this->getNamespace(); $this->setNamespace(self::NAMESPACE_ERROR); $this->addMessage($message); $this->setNamespace($namespace); return $this; } public function hasMessages() { $this->getMessagesFromContainer(); return isset($this->messages[$this->getNamespace()]); } public function hasInfoMessages() { $namespace = $this->getNamespace(); $this->setNamespace(self::NAMESPACE_INFO); $hasMessages = $this->hasMessages(); $this->setNamespace($namespace); return $hasMessages; } public function hasSuccessMessages() { $namespace = $this->getNamespace(); $this->setNamespace(self::NAMESPACE_SUCCESS); $hasMessages = $this->hasMessages(); $this->setNamespace($namespace); return $hasMessages; } public function hasErrorMessages() { $namespace = $this->getNamespace(); $this->setNamespace(self::NAMESPACE_ERROR); $hasMessages = $this->hasMessages(); $this->setNamespace($namespace); return $hasMessages; } public function getMessages() { if ($this->hasMessages()) { return $this->messages[$this->getNamespace()]->toArray(); } return array(); } public function getInfoMessages() { $namespace = $this->getNamespace(); $this->setNamespace(self::NAMESPACE_INFO); $messages = $this->getMessages(); $this->setNamespace($namespace); return $messages; } public function getSuccessMessages() { $namespace = $this->getNamespace(); $this->setNamespace(self::NAMESPACE_SUCCESS); $messages = $this->getMessages(); $this->setNamespace($namespace); return $messages; } public function getErrorMessages() { $namespace = $this->getNamespace(); $this->setNamespace(self::NAMESPACE_ERROR); $messages = $this->getMessages(); $this->setNamespace($namespace); return $messages; } public function clearMessages() { if ($this->hasMessages()) { unset($this->messages[$this->getNamespace()]); return true; } return false; } public function clearMessagesFromNamespace($namespaceToClear) { $namespace = $this->getNamespace(); $this->setNamespace($namespaceToClear); $cleared = $this->clearMessages(); $this->setNamespace($namespace); return $cleared; } public function clearMessagesFromContainer() { $this->getMessagesFromContainer(); if (empty($this->messages)) { return false; } unset($this->messages); $this->messages = array(); return true; } public function hasCurrentMessages() { $container = $this->getContainer(); $namespace = $this->getNamespace(); return isset($container->{$namespace}); } public function hasCurrentInfoMessages() { $namespace = $this->getNamespace(); $this->setNamespace(self::NAMESPACE_INFO); $hasMessages = $this->hasCurrentMessages(); $this->setNamespace($namespace); return $hasMessages; } public function hasCurrentSuccessMessages() { $namespace = $this->getNamespace(); $this->setNamespace(self::NAMESPACE_SUCCESS); $hasMessages = $this->hasCurrentMessages(); $this->setNamespace($namespace); return $hasMessages; } public function hasCurrentErrorMessages() { $namespace = $this->getNamespace(); $this->setNamespace(self::NAMESPACE_ERROR); $hasMessages = $this->hasCurrentMessages(); $this->setNamespace($namespace); return $hasMessages; } public function getCurrentMessages() { if ($this->hasCurrentMessages()) { $container = $this->getContainer(); $namespace = $this->getNamespace(); return $container->{$namespace}->toArray(); } return array(); } public function getCurrentInfoMessages() { $namespace = $this->getNamespace(); $this->setNamespace(self::NAMESPACE_INFO); $messages = $this->getCurrentMessages(); $this->setNamespace($namespace); return $messages; } public function getCurrentSuccessMessages() { $namespace = $this->getNamespace(); $this->setNamespace(self::NAMESPACE_SUCCESS); $messages = $this->getCurrentMessages(); $this->setNamespace($namespace); return $messages; } public function getCurrentErrorMessages() { $namespace = $this->getNamespace(); $this->setNamespace(self::NAMESPACE_ERROR); $messages = $this->getCurrentMessages(); $this->setNamespace($namespace); return $messages; } public function getCurrentMessagesFromNamespace($namespaceToGet) { $namespace = $this->getNamespace(); $this->setNamespace($namespaceToGet); $messages = $this->getCurrentMessages(); $this->setNamespace($namespace); return $messages; } public function clearCurrentMessages() { if ($this->hasCurrentMessages()) { $container = $this->getContainer(); $namespace = $this->getNamespace(); unset($container->{$namespace}); return true; } return false; } public function clearCurrentMessagesFromNamespace($namespaceToClear) { $namespace = $this->getNamespace(); $this->setNamespace($namespaceToClear); $cleared = $this->clearCurrentMessages(); $this->setNamespace($namespace); return $cleared; } public function clearCurrentMessagesFromContainer() { $container = $this->getContainer(); $namespaces = array(); foreach ($container as $namespace => $messages) { $namespaces[] = $namespace; } if (empty($namespaces)) { return false; } foreach ($namespaces as $namespace) { unset($container->{$namespace}); } return true; } public function getIterator() { if ($this->hasMessages()) { return new ArrayIterator($this->getMessages()); } return new ArrayIterator(); } public function count() { if ($this->hasMessages()) { return count($this->getMessages()); } return 0; } public function getMessagesFromNamespace($namespaceToGet) { $namespace = $this->getNamespace(); $this->setNamespace($namespaceToGet); $messages = $this->getMessages(); $this->setNamespace($namespace); return $messages; } protected function getMessagesFromContainer() { if (!empty($this->messages) || $this->messageAdded) { return; } $container = $this->getContainer(); $namespaces = array(); foreach ($container as $namespace => $messages) { $this->messages[$namespace] = $messages; $namespaces[] = $namespace; } foreach ($namespaces as $namespace) { unset($container->{$namespace}); } } } getController()->getRequest(); if ($request->isPost()) { return $this->handlePostRequest($form, $redirect, $redirectToUrl); } else { return $this->handleGetRequest($form); } } protected function handlePostRequest(FormInterface $form, $redirect, $redirectToUrl) { $container = $this->getSessionContainer(); $request = $this->getController()->getRequest(); $inputFilter = $form->getInputFilter(); $previousFiles = ($container->files) ?: array(); $this->traverseInputs( $inputFilter, $previousFiles, function($input, $value) { if ($input instanceof FileInput) { $input->setRequired(false); } return $value; } ); $postFiles = $request->getFiles()->toArray(); $postOther = $request->getPost()->toArray(); $post = array_merge_recursive($postOther, $postFiles); $form->setData($post); $isValid = $form->isValid(); $data = $form->getData(FormInterface::VALUES_AS_ARRAY); $errors = (!$isValid) ? $form->getMessages() : null; $prevFileData = $this->getEmptyUploadData($inputFilter, $previousFiles); $newFileData = $this->getNonEmptyUploadData($inputFilter, $data); $postFiles = array_merge_recursive( $prevFileData ?: array(), $newFileData ?: array() ); $post = array_merge_recursive($postOther, $postFiles); $container->setExpirationHops(1, array('post', 'errors', 'isValid')); $container->post = $post; $container->errors = $errors; $container->isValid = $isValid; $container->files = $postFiles; return $this->redirect($redirect, $redirectToUrl); } protected function handleGetRequest(FormInterface $form) { $container = $this->getSessionContainer(); if (null === $container->post) { unset($container->files); return false; } $post = $container->post; $errors = $container->errors; $isValid = $container->isValid; $previousFiles = ($container->files) ?: array(); unset($container->post); unset($container->errors); unset($container->isValid); $inputFilter = $form->getInputFilter(); $this->traverseInputs( $inputFilter, $post, function($input, $value) { if ($input instanceof FileInput) { $input->setAutoPrependUploadValidator(false) ->setValidatorChain(new ValidatorChain()) ->setFilterChain(new FilterChain); } return $value; } ); $form->setData($post); $form->isValid(); if (null !== $errors) { $form->setMessages($errors); } $this->setProtectedFormProperty($form, 'isValid', $isValid); if ($isValid) { unset($container->files); } return $post; } public function getSessionContainer() { if (!isset($this->sessionContainer)) { $this->sessionContainer = new Container('file_prg_post1'); } return $this->sessionContainer; } public function setSessionContainer(Container $container) { $this->sessionContainer = $container; return $this; } protected function setProtectedFormProperty(FormInterface $form, $property, $value) { $formClass = new \ReflectionClass($form); $property = $formClass->getProperty($property); $property->setAccessible(true); $property->setValue($form, $value); return $this; } protected function traverseInputs(InputFilterInterface $inputFilter, $values, $callback) { $returnValues = null; foreach ($values as $name => $value) { if (!$inputFilter->has($name)) { continue; } $input = $inputFilter->get($name); if ($input instanceof InputFilterInterface && is_array($value)) { $retVal = $this->traverseInputs($input, $value, $callback); if (null !== $retVal) { $returnValues[$name] = $retVal; } continue; } $retVal = $callback($input, $value); if (null !== $retVal) { $returnValues[$name] = $retVal; } } return $returnValues; } protected function getNonEmptyUploadData(InputFilterInterface $inputFilter, $data) { return $this->traverseInputs( $inputFilter, $data, function($input, $value) { $messages = $input->getMessages(); if (is_array($value) && $input instanceof FileInput && empty($messages)) { $rawValue = $input->getRawValue(); if ( (isset($rawValue['error']) && $rawValue['error'] !== UPLOAD_ERR_NO_FILE) || (isset($rawValue[0]['error']) && $rawValue[0]['error'] !== UPLOAD_ERR_NO_FILE) ) { return $value; } } return null; } ); } protected function getEmptyUploadData(InputFilterInterface $inputFilter, $data) { return $this->traverseInputs( $inputFilter, $data, function($input, $value) { $messages = $input->getMessages(); if (is_array($value) && $input instanceof FileInput && empty($messages)) { $rawValue = $input->getRawValue(); if ( (isset($rawValue['error']) && $rawValue['error'] === UPLOAD_ERR_NO_FILE) || (isset($rawValue[0]['error']) && $rawValue[0]['error'] === UPLOAD_ERR_NO_FILE) ) { return $value; } } return null; } ); } protected function redirect($redirect, $redirectToUrl) { $controller = $this->getController(); $params = array(); $options = array(); $reuseMatchedParams = false; if (null === $redirect) { $routeMatch = $controller->getEvent()->getRouteMatch(); $redirect = $routeMatch->getMatchedRouteName(); $reuseMatchedParams = true; } if (method_exists($controller, 'getPluginManager')) { $redirector = $controller->getPluginManager()->get('Redirect'); } else { if ($redirectToUrl === false) { throw new RuntimeException('Could not redirect to a route without a router'); } $redirector = new Redirect(); } if ($redirectToUrl === false) { $response = $redirector->toRoute($redirect, $params, $options, $reuseMatchedParams); $response->setStatusCode(303); return $response; } $response = $redirector->toUrl($redirect); $response->setStatusCode(303); return $response; } } getController(); $request = $controller->getRequest(); $container = $this->getSessionContainer(); if ($request->isPost()) { $container->setExpirationHops(1, 'post'); $container->post = $request->getPost()->toArray(); return $this->redirect($redirect, $redirectToUrl); } else { if ($container->post !== null) { $post = $container->post; unset($container->post); return $post; } return false; } } public function getSessionContainer() { if (!isset($this->sessionContainer)) { $this->sessionContainer = new Container('prg_post1'); } return $this->sessionContainer; } public function setSessionContainer(Container $container) { $this->sessionContainer = $container; return $this; } protected function redirect($redirect, $redirectToUrl) { $controller = $this->getController(); $params = array(); $options = array(); $reuseMatchedParams = false; if (null === $redirect) { $routeMatch = $controller->getEvent()->getRouteMatch(); $redirect = $routeMatch->getMatchedRouteName(); $reuseMatchedParams = true; } if (method_exists($controller, 'getPluginManager')) { $redirector = $controller->getPluginManager()->get('Redirect'); } else { if ($redirectToUrl === false) { throw new RuntimeException('Could not redirect to a route without a router'); } $redirector = new Redirect(); } if ($redirectToUrl === false) { $response = $redirector->toRoute($redirect, $params, $options, $reuseMatchedParams); $response->setStatusCode(303); return $response; } $response = $redirector->toUrl($redirect); $response->setStatusCode(303); return $response; } } array( 'application/hal+json', 'application/json' ) ); protected $identifierName = 'id'; protected $jsonDecodeType = Json::TYPE_ARRAY; protected $customHttpMethodsMap = array(); public function setIdentifierName($name) { $this->identifierName = (string) $name; return $this; } public function getIdentifierName() { return $this->identifierName; } public function create($data) { $this->response->setStatusCode(405); return array( 'content' => 'Method Not Allowed' ); } public function delete($id) { $this->response->setStatusCode(405); return array( 'content' => 'Method Not Allowed' ); } public function deleteList() { $this->response->setStatusCode(405); return array( 'content' => 'Method Not Allowed' ); } public function get($id) { $this->response->setStatusCode(405); return array( 'content' => 'Method Not Allowed' ); } public function getList() { $this->response->setStatusCode(405); return array( 'content' => 'Method Not Allowed' ); } public function head($id = null) { $this->response->setStatusCode(405); return array( 'content' => 'Method Not Allowed' ); } public function options() { $this->response->setStatusCode(405); return array( 'content' => 'Method Not Allowed' ); } public function patch($id, $data) { $this->response->setStatusCode(405); return array( 'content' => 'Method Not Allowed' ); } public function replaceList($data) { $this->response->setStatusCode(405); return array( 'content' => 'Method Not Allowed' ); } public function patchList($data) { $this->response->setStatusCode(405); return array( 'content' => 'Method Not Allowed' ); } public function update($id, $data) { $this->response->setStatusCode(405); return array( 'content' => 'Method Not Allowed' ); } public function notFoundAction() { $this->response->setStatusCode(404); return array( 'content' => 'Page not found' ); } public function dispatch(Request $request, Response $response = null) { if (! $request instanceof HttpRequest) { throw new Exception\InvalidArgumentException( 'Expected an HTTP request'); } return parent::dispatch($request, $response); } public function onDispatch(MvcEvent $e) { $routeMatch = $e->getRouteMatch(); if (! $routeMatch) { throw new Exception\DomainException( 'Missing route matches; unsure how to retrieve action'); } $request = $e->getRequest(); $action = $routeMatch->getParam('action', false); if ($action) { $method = static::getMethodFromAction($action); if (! method_exists($this, $method)) { $method = 'notFoundAction'; } $return = $this->$method(); $e->setResult($return); return $return; } $method = strtolower($request->getMethod()); switch ($method) { case (isset($this->customHttpMethodsMap[$method])): $callable = $this->customHttpMethodsMap[$method]; $action = $method; $return = call_user_func($callable, $e); break; case 'delete': $id = $this->getIdentifier($routeMatch, $request); if ($id !== false) { $action = 'delete'; $return = $this->delete($id); break; } $action = 'deleteList'; $return = $this->deleteList(); break; case 'get': $id = $this->getIdentifier($routeMatch, $request); if ($id !== false) { $action = 'get'; $return = $this->get($id); break; } $action = 'getList'; $return = $this->getList(); break; case 'head': $id = $this->getIdentifier($routeMatch, $request); if ($id === false) { $id = null; } $action = 'head'; $this->head($id); $response = $e->getResponse(); $response->setContent(''); $return = $response; break; case 'options': $action = 'options'; $this->options(); $return = $e->getResponse(); break; case 'patch': $id = $this->getIdentifier($routeMatch, $request); $data = $this->processBodyContent($request); if ($id !== false) { $action = 'patch'; $return = $this->patch($id, $data); break; } try { $action = 'patchList'; $return = $this->patchList($data); } catch (Exception\RuntimeException $ex) { $response = $e->getResponse(); $response->setStatusCode(405); return $response; } break; case 'post': $action = 'create'; $return = $this->processPostData($request); break; case 'put': $id = $this->getIdentifier($routeMatch, $request); $data = $this->processBodyContent($request); if ($id !== false) { $action = 'update'; $return = $this->update($id, $data); break; } $action = 'replaceList'; $return = $this->replaceList($data); break; default: $response = $e->getResponse(); $response->setStatusCode(405); return $response; } $routeMatch->setParam('action', $action); $e->setResult($return); return $return; } public function processPostData(Request $request) { if ($this->requestHasContentType($request, self::CONTENT_TYPE_JSON)) { $data = Json::decode($request->getContent(), $this->jsonDecodeType); } else { $data = $request->getPost()->toArray(); } return $this->create($data); } public function requestHasContentType(Request $request, $contentType = '') { $headerContentType = $request->getHeaders()->get('content-type'); if (!$headerContentType) { return false; } $requestedContentType = $headerContentType->getFieldValue(); if (strstr($requestedContentType, ';')) { $headerData = explode(';', $requestedContentType); $requestedContentType = array_shift($headerData); } $requestedContentType = trim($requestedContentType); if (array_key_exists($contentType, $this->contentTypes)) { foreach ($this->contentTypes[$contentType] as $contentTypeValue) { if (stripos($contentTypeValue, $requestedContentType) === 0) { return true; } } } return false; } public function addHttpMethodHandler($method, $handler) { if (!is_callable($handler)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid HTTP method handler: must be a callable; received "%s"', (is_object($handler) ? get_class($handler) : gettype($handler)) )); } $method = strtolower($method); $this->customHttpMethodsMap[$method] = $handler; return $this; } protected function getIdentifier($routeMatch, $request) { $identifier = $this->getIdentifierName(); $id = $routeMatch->getParam($identifier, false); if ($id !== false) { return $id; } $id = $request->getQuery()->get($identifier, false); if ($id !== false) { return $id; } return false; } protected function processBodyContent($request) { $content = $request->getContent(); if ($this->requestHasContentType($request, self::CONTENT_TYPE_JSON)) { return Json::decode($content, $this->jsonDecodeType); } parse_str($content, $parsedParams); if (!is_array($parsedParams) || (1 == count($parsedParams) && isset($parsedParams[0])) ) { return $content; } return $parsedParams; } } request = $request; if (!$response) { $response = new HttpResponse(); } $this->response = $response; $e = $this->getEvent(); $e->setRequest($request) ->setResponse($response) ->setTarget($this); $result = $this->getEventManager()->trigger(MvcEvent::EVENT_DISPATCH, $e, function ($test) { return ($test instanceof Response); }); if ($result->stopped()) { return $result->last(); } return $e->getResult(); } public function getRequest() { if (!$this->request) { $this->request = new HttpRequest(); } return $this->request; } public function getResponse() { if (!$this->response) { $this->response = new HttpResponse(); } return $this->response; } public function setEventManager(EventManagerInterface $events) { $events->setIdentifiers(array( 'Zend\Stdlib\DispatchableInterface', __CLASS__, get_class($this), $this->eventIdentifier, substr(get_class($this), 0, strpos(get_class($this), '\\')) )); $this->events = $events; $this->attachDefaultListeners(); return $this; } public function getEventManager() { if (!$this->events) { $this->setEventManager(new EventManager()); } return $this->events; } public function setEvent(Event $e) { if (!$e instanceof MvcEvent) { $eventParams = $e->getParams(); $e = new MvcEvent(); $e->setParams($eventParams); unset($eventParams); } $this->event = $e; } public function getEvent() { if (!$this->event) { $this->setEvent(new MvcEvent()); } return $this->event; } public function setServiceLocator(ServiceLocatorInterface $serviceLocator) { $this->serviceLocator = $serviceLocator; } public function getServiceLocator() { return $this->serviceLocator; } public function getPluginManager() { if (!$this->plugins) { $this->setPluginManager(new PluginManager()); } $this->plugins->setController($this); return $this->plugins; } public function setPluginManager(PluginManager $plugins) { $this->plugins = $plugins; $this->plugins->setController($this); return $this; } public function plugin($name, array $options = null) { return $this->getPluginManager()->get($name, $options); } public function __call($method, $params) { $plugin = $this->plugin($method); if (is_callable($plugin)) { return call_user_func_array($plugin, $params); } return $plugin; } protected function attachDefaultListeners() { $events = $this->getEventManager(); $events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'onDispatch')); } public static function getMethodFromAction($action) { $method = str_replace(array('.', '-', '_'), ' ', $action); $method = ucwords($method); $method = str_replace(' ', '', $method); $method = lcfirst($method); $method .= 'Action'; return $method; } } 'Placeholder page' )); } public function notFoundAction() { $response = $this->response; $event = $this->getEvent(); $routeMatch = $event->getRouteMatch(); $routeMatch->setParam('action', 'not-found'); if ($response instanceof HttpResponse) { return $this->createHttpNotFoundModel($response); } return $this->createConsoleNotFoundModel($response); } public function onDispatch(MvcEvent $e) { $routeMatch = $e->getRouteMatch(); if (!$routeMatch) { throw new Exception\DomainException('Missing route matches; unsure how to retrieve action'); } $action = $routeMatch->getParam('action', 'not-found'); $method = static::getMethodFromAction($action); if (!method_exists($this, $method)) { $method = 'notFoundAction'; } $actionResponse = $this->$method(); $e->setResult($actionResponse); return $actionResponse; } protected function createHttpNotFoundModel(HttpResponse $response) { $response->setStatusCode(404); return new ViewModel(array( 'content' => 'Page not found', )); } protected function createConsoleNotFoundModel($response) { $viewModel = new ConsoleModel(); $viewModel->setErrorLevel(1); $viewModel->setResult('Page not found'); return $viewModel; } } listeners[] = $events->attach(MvcEvent::EVENT_ROUTE, array($this, 'onRoute')); } public function detach(EventManagerInterface $events) { foreach ($this->listeners as $index => $listener) { if ($events->detach($listener)) { unset($this->listeners[$index]); } } } public function onRoute($e) { $target = $e->getTarget(); $request = $e->getRequest(); $router = $e->getRouter(); $routeMatch = $router->match($request); if (!$routeMatch instanceof Router\RouteMatch) { $e->setError(Application::ERROR_ROUTER_NO_MATCH); $results = $target->getEventManager()->trigger(MvcEvent::EVENT_DISPATCH_ERROR, $e); if (count($results)) { $return = $results->last(); } else { $return = $e->getParams(); } return $return; } $e->setRouteMatch($routeMatch); return $routeMatch; } } setIdentifiers(array( __CLASS__, get_class($this), )); $this->eventManager = $eventManager; $this->attachDefaultListeners(); return $this; } public function getEventManager() { if (!$this->eventManager instanceof EventManagerInterface) { $this->setEventManager(new EventManager()); } return $this->eventManager; } public function attach(EventManagerInterface $events) { $this->listeners[] = $events->attach(MvcEvent::EVENT_FINISH, array($this, 'sendResponse'), -10000); } public function detach(EventManagerInterface $events) { foreach ($this->listeners as $index => $listener) { if ($events->detach($listener)) { unset($this->listeners[$index]); } } } public function sendResponse(MvcEvent $e) { $response = $e->getResponse(); if (!$response instanceof Response) { return; } $event = $this->getEvent(); $event->setResponse($response); $event->setTarget($this); $this->getEventManager()->trigger($event); } public function getEvent() { if (!$this->event instanceof SendResponseEvent) { $this->setEvent(new SendResponseEvent()); } return $this->event; } public function setEvent(SendResponseEvent $e) { $this->event = $e; return $this; } protected function attachDefaultListeners() { $events = $this->getEventManager(); $events->attach(SendResponseEvent::EVENT_SEND_RESPONSE, new PhpEnvironmentResponseSender(), -1000); $events->attach(SendResponseEvent::EVENT_SEND_RESPONSE, new ConsoleResponseSender(), -2000); $events->attach(SendResponseEvent::EVENT_SEND_RESPONSE, new SimpleStreamResponseSender(), -3000); $events->attach(SendResponseEvent::EVENT_SEND_RESPONSE, new HttpResponseSender(), -4000); } } listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'onDispatch')); if (function_exists('zend_monitor_custom_event_ex')) { $this->listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'reportMonitorEvent')); } } public function detach(EventManagerInterface $events) { foreach ($this->listeners as $index => $listener) { if ($events->detach($listener)) { unset($this->listeners[$index]); } } } public function onDispatch(MvcEvent $e) { $routeMatch = $e->getRouteMatch(); $controllerName = $routeMatch->getParam('controller', 'not-found'); $application = $e->getApplication(); $events = $application->getEventManager(); $controllerLoader = $application->getServiceManager()->get('ControllerLoader'); if (!$controllerLoader->has($controllerName)) { $return = $this->marshallControllerNotFoundEvent($application::ERROR_CONTROLLER_NOT_FOUND, $controllerName, $e, $application); return $this->complete($return, $e); } try { $controller = $controllerLoader->get($controllerName); } catch (InvalidControllerException $exception) { $return = $this->marshallControllerNotFoundEvent($application::ERROR_CONTROLLER_INVALID, $controllerName, $e, $application, $exception); return $this->complete($return, $e); } catch (\Exception $exception) { $return = $this->marshallBadControllerEvent($controllerName, $e, $application, $exception); return $this->complete($return, $e); } $request = $e->getRequest(); $response = $application->getResponse(); if ($controller instanceof InjectApplicationEventInterface) { $controller->setEvent($e); } try { $return = $controller->dispatch($request, $response); } catch (\Exception $ex) { $e->setError($application::ERROR_EXCEPTION) ->setController($controllerName) ->setControllerClass(get_class($controller)) ->setParam('exception', $ex); $results = $events->trigger(MvcEvent::EVENT_DISPATCH_ERROR, $e); $return = $results->last(); if (! $return) { $return = $e->getResult(); } } return $this->complete($return, $e); } public function reportMonitorEvent(MvcEvent $e) { $error = $e->getError(); $exception = $e->getParam('exception'); if ($exception instanceof \Exception) { zend_monitor_custom_event_ex($error, $exception->getMessage(), 'Zend Framework Exception', array('code' => $exception->getCode(), 'trace' => $exception->getTraceAsString())); } } protected function complete($return, MvcEvent $event) { if (!is_object($return)) { if (ArrayUtils::hasStringKeys($return)) { $return = new ArrayObject($return, ArrayObject::ARRAY_AS_PROPS); } } $event->setResult($return); return $return; } protected function marshallControllerNotFoundEvent( $type, $controllerName, MvcEvent $event, Application $application, \Exception $exception = null ) { $event->setError($type) ->setController($controllerName) ->setControllerClass('invalid controller class or alias: ' . $controllerName); if ($exception !== null) { $event->setParam('exception', $exception); } $events = $application->getEventManager(); $results = $events->trigger(MvcEvent::EVENT_DISPATCH_ERROR, $event); $return = $results->last(); if (! $return) { $return = $event->getResult(); } return $return; } protected function marshallBadControllerEvent( $controllerName, MvcEvent $event, Application $application, \Exception $exception ) { $event->setError($application::ERROR_EXCEPTION) ->setController($controllerName) ->setParam('exception', $exception); $events = $application->getEventManager(); $results = $events->trigger(MvcEvent::EVENT_DISPATCH_ERROR, $event); $return = $results->last(); if (! $return) { $return = $event->getResult(); } return $return; } } setParam('application', $application); $this->application = $application; return $this; } public function getApplication() { return $this->application; } public function getRouter() { return $this->router; } public function setRouter(Router\RouteStackInterface $router) { $this->setParam('router', $router); $this->router = $router; return $this; } public function getRouteMatch() { return $this->routeMatch; } public function setRouteMatch(Router\RouteMatch $matches) { $this->setParam('route-match', $matches); $this->routeMatch = $matches; return $this; } public function getRequest() { return $this->request; } public function setRequest(Request $request) { $this->setParam('request', $request); $this->request = $request; return $this; } public function getResponse() { return $this->response; } public function setResponse(Response $response) { $this->setParam('response', $response); $this->response = $response; return $this; } public function setViewModel(Model $viewModel) { $this->viewModel = $viewModel; return $this; } public function getViewModel() { if (null === $this->viewModel) { $this->setViewModel(new ViewModel()); } return $this->viewModel; } public function getResult() { return $this->result; } public function setResult($result) { $this->setParam('__RESULT__', $result); $this->result = $result; return $this; } public function isError() { return (bool) $this->getParam('error', false); } public function setError($message) { $this->setParam('error', $message); return $this; } public function getError() { return $this->getParam('error', ''); } public function getController() { return $this->getParam('controller'); } public function setController($name) { $this->setParam('controller', $name); return $this; } public function getControllerClass() { return $this->getParam('controller-class'); } public function setControllerClass($class) { $this->setParam('controller-class', $class); return $this; } } contentSent()) { return $this; } $response = $event->getResponse(); echo $response->getContent(); $event->setContentSent(); return $this; } public function __invoke(SendResponseEvent $event) { $response = $event->getResponse(); if (!$response instanceof Response) { return; } $this->sendContent($event); $errorLevel = (int) $response->getMetadata('errorLevel',0); $event->stopPropagation(true); exit($errorLevel); } } headersSent()) { return $this; } $response = $event->getResponse(); foreach ($response->getHeaders() as $header) { if ($header instanceof MultipleHeaderInterface) { header($header->toString(), false); continue; } header($header->toString()); } $status = $response->renderStatusLine(); header($status); $event->setHeadersSent(); return $this; } } setParam('response', $response); $this->response = $response; return $this; } public function getResponse() { return $this->response; } public function setContentSent() { $response = $this->getResponse(); $contentSent = $this->getParam('contentSent', array()); $contentSent[spl_object_hash($response)] = true; $this->setParam('contentSent', $contentSent); $this->contentSent[spl_object_hash($response)] = true; return $this; } public function contentSent() { $response = $this->getResponse(); if (isset($this->contentSent[spl_object_hash($response)])) { return true; } return false; } public function setHeadersSent() { $response = $this->getResponse(); $headersSent = $this->getParam('headersSent', array()); $headersSent[spl_object_hash($response)] = true; $this->setParam('headersSent', $headersSent); $this->headersSent[spl_object_hash($response)] = true; return $this; } public function headersSent() { $response = $this->getResponse(); if (isset($this->headersSent[spl_object_hash($response)])) { return true; } return false; } } contentSent()) { return $this; } $response = $event->getResponse(); echo $response->getContent(); $event->setContentSent(); return $this; } public function __invoke(SendResponseEvent $event) { $response = $event->getResponse(); if (!$response instanceof Response) { return $this; } $this->sendHeaders($event) ->sendContent($event); $event->stopPropagation(true); return $this; } } contentSent()) { return $this; } $response = $event->getResponse(); $stream = $response->getStream(); fpassthru($stream); $event->setContentSent(); } public function __invoke(SendResponseEvent $event) { $response = $event->getResponse(); if (!$response instanceof Stream) { return $this; } $this->sendHeaders($event); $this->sendStream($event); $event->stopPropagation(true); return $this; } } getResponse(); if (!$response instanceof Response) { return $this; } $this->sendHeaders($event) ->sendContent($event); $event->stopPropagation(true); return $this; } } 'Zend\Serializer\Adapter\IgBinary', 'json' => 'Zend\Serializer\Adapter\Json', 'msgpack' => 'Zend\Serializer\Adapter\MsgPack', 'phpcode' => 'Zend\Serializer\Adapter\PhpCode', 'phpserialize' => 'Zend\Serializer\Adapter\PhpSerialize', 'pythonpickle' => 'Zend\Serializer\Adapter\PythonPickle', 'wddx' => 'Zend\Serializer\Adapter\Wddx', ); public function validatePlugin($plugin) { if ($plugin instanceof Adapter\AdapterInterface) { return; } throw new Exception\RuntimeException(sprintf( 'Plugin of type %s is invalid; must implement %s\Adapter\AdapterInterface', (is_object($plugin) ? get_class($plugin) : gettype($plugin)), __NAMESPACE__ )); } } comment = (string) $comment; return $this; } public function getComment() { return $this->comment; } } options = $options; return $this; } public function getOptions() { if ($this->options === null) { $this->options = new JsonOptions(); } return $this->options; } public function serialize($value) { $options = $this->getOptions(); $cycleCheck = $options->getCycleCheck(); $opts = array( 'enableJsonExprFinder' => $options->getEnableJsonExprFinder(), 'objectDecodeType' => $options->getObjectDecodeType(), ); try { return ZendJson::encode($value, $cycleCheck, $opts); } catch (\InvalidArgumentException $e) { throw new Exception\InvalidArgumentException('Serialization failed: ' . $e->getMessage(), 0, $e); } catch (\Exception $e) { throw new Exception\RuntimeException('Serialization failed: ' . $e->getMessage(), 0, $e); } } public function unserialize($json) { try { $ret = ZendJson::decode($json, $this->getOptions()->getObjectDecodeType()); } catch (\InvalidArgumentException $e) { throw new Exception\InvalidArgumentException('Unserialization failed: ' . $e->getMessage(), 0, $e); } catch (\Exception $e) { throw new Exception\RuntimeException('Unserialization failed: ' . $e->getMessage(), 0, $e); } return $ret; } } options = $options; return $this; } public function getOptions() { if ($this->options === null) { $this->options = new WddxOptions(); } return $this->options; } public function serialize($value) { $comment = $this->getOptions()->getComment(); ErrorHandler::start(); if ($comment !== '') { $wddx = wddx_serialize_value($value, $comment); } else { $wddx = wddx_serialize_value($value); } $error = ErrorHandler::stop(); if ($wddx === false) { throw new Exception\RuntimeException('Serialization failed', 0, $error); } return $wddx; } public function unserialize($wddx) { $ret = wddx_deserialize($wddx); if ($ret === null && class_exists('SimpleXMLElement', false)) { try { $oldLibxmlDisableEntityLoader = libxml_disable_entity_loader(true); $dom = new \DOMDocument; $dom->loadXML($wddx); foreach ($dom->childNodes as $child) { if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) { throw new Exception\InvalidArgumentException( 'Invalid XML: Detected use of illegal DOCTYPE' ); } } $simpleXml = simplexml_import_dom($dom); libxml_disable_entity_loader($oldLibxmlDisableEntityLoader); if (isset($simpleXml->data[0]->null[0])) { return null; } throw new Exception\RuntimeException('Unserialization failed: Invalid wddx packet'); } catch (\Exception $e) { throw new Exception\RuntimeException('Unserialization failed: ' . $e->getMessage(), 0, $e); } } return $ret; } } 3) { throw new Exception\InvalidArgumentException( "Invalid or unknown protocol version '{$protocol}'" ); } $this->protocol = $protocol; return $this; } public function getProtocol() { return $this->protocol; } } setOptions($options); } } public function setOptions($options) { if (!$options instanceof AdapterOptions) { $options = new AdapterOptions($options); } $this->options = $options; return $this; } public function getOptions() { if ($this->options === null) { $this->options = new AdapterOptions(); } return $this->options; } } cycleCheck = (bool) $flag; return $this; } public function getCycleCheck() { return $this->cycleCheck; } public function setEnableJsonExprFinder($flag) { $this->enableJsonExprFinder = (bool) $flag; return $this; } public function getEnableJsonExprFinder() { return $this->enableJsonExprFinder; } public function setObjectDecodeType($type) { if ($type != ZendJson::TYPE_ARRAY && $type != ZendJson::TYPE_OBJECT) { throw new Exception\InvalidArgumentException( 'Unknown decode type: ' . $type ); } $this->objectDecodeType = (int) $type; return $this; } public function getObjectDecodeType() { return $this->objectDecodeType; } } '\\\\', "\x00" => '\\x00', "\x01" => '\\x01', "\x02" => '\\x02', "\x03" => '\\x03', "\x04" => '\\x04', "\x05" => '\\x05', "\x06" => '\\x06', "\x07" => '\\x07', "\x08" => '\\x08', "\x09" => '\\t', "\x0a" => '\\n', "\x0b" => '\\x0b', "\x0c" => '\\x0c', "\x0d" => '\\r', "\x0e" => '\\x0e', "\x0f" => '\\x0f', "\x10" => '\\x10', "\x11" => '\\x11', "\x12" => '\\x12', "\x13" => '\\x13', "\x14" => '\\x14', "\x15" => '\\x15', "\x16" => '\\x16', "\x17" => '\\x17', "\x18" => '\\x18', "\x19" => '\\x19', "\x1a" => '\\x1a', "\x1b" => '\\x1b', "\x1c" => '\\x1c', "\x1d" => '\\x1d', "\x1e" => '\\x1e', "\x1f" => '\\x1f', "\xff" => '\\xff' ); protected $protocol = null; protected $memo = array(); protected $pickle = ''; protected $pickleLen = 0; protected $pos = 0; protected $stack = array(); protected $marker = null; protected $bigIntegerAdapter = null; protected $options = null; public function __construct($options = null) { if (static::$isLittleEndian === null) { static::$isLittleEndian = (pack('l', 1) === "\x01\x00\x00\x00"); } $this->marker = new stdClass(); parent::__construct($options); } public function setOptions($options) { if (!$options instanceof PythonPickleOptions) { $options = new PythonPickleOptions($options); } $this->options = $options; return $this; } public function getOptions() { if ($this->options === null) { $this->options = new PythonPickleOptions(); } return $this->options; } public function serialize($value) { $this->clearProcessVars(); $this->protocol = $this->getOptions()->getProtocol(); if ($this->protocol >= 2) { $this->writeProto($this->protocol); } $this->write($value); $this->writeStop(); $pickle = $this->pickle; $this->clearProcessVars(); return $pickle; } protected function write($value) { if ($value === null) { $this->writeNull(); } elseif (is_bool($value)) { $this->writeBool($value); } elseif (is_int($value)) { $this->writeInt($value); } elseif (is_float($value)) { $this->writeFloat($value); } elseif (is_string($value)) { $this->writeString($value); } elseif (is_array($value)) { if (ArrayUtils::isList($value)) { $this->writeArrayList($value); } else { $this->writeArrayDict($value); } } elseif (is_object($value)) { $this->writeObject($value); } else { throw new Exception\RuntimeException(sprintf( 'PHP-Type "%s" can not be serialized by %s', gettype($value), get_class($this) )); } } protected function writeProto($protocol) { $this->pickle .= self::OP_PROTO . $protocol; } protected function writeGet($id) { if ($this->protocol == 0) { $this->pickle .= self::OP_GET . $id . "\r\n"; } elseif ($id <= 0xFF) { $this->pickle .= self::OP_BINGET . chr($id); } else { $bin = pack('l', $id); if (static::$isLittleEndian === false) { $bin = strrev($bin); } $this->pickle .= self::OP_LONG_BINGET . $bin; } } protected function writePut($id) { if ($this->protocol == 0) { $this->pickle .= self::OP_PUT . $id . "\r\n"; } elseif ($id <= 0xff) { $this->pickle .= self::OP_BINPUT . chr($id); } else { $bin = pack('l', $id); if (static::$isLittleEndian === false) { $bin = strrev($bin); } $this->pickle .= self::OP_LONG_BINPUT . $bin; } } protected function writeNull() { $this->pickle .= self::OP_NONE; } protected function writeBool($value) { if ($this->protocol >= 2) { $this->pickle .= ($value === true) ? self::OP_NEWTRUE : self::OP_NEWFALSE; } else { $this->pickle .= self::OP_INT . (($value === true) ? '01' : '00') . "\r\n"; } } protected function writeInt($value) { if ($this->protocol == 0) { $this->pickle .= self::OP_INT . $value . "\r\n"; return; } if ($value >= 0) { if ($value <= 0xFF) { $this->pickle .= self::OP_BININT1 . chr($value); } elseif ($value <= 0xFFFF) { $this->pickle .= self::OP_BININT2 . pack('v', $value); } return; } $highBits = $value >> 31; if ($highBits == 0 || $highBits == -1) { $bin = pack('l', $value); if (static::$isLittleEndian === false) { $bin = strrev($bin); } $this->pickle .= self::OP_BININT . $bin; return; } } protected function writeFloat($value) { if ($this->protocol == 0) { $this->pickle .= self::OP_FLOAT . $value . "\r\n"; } else { $bin = pack('d', $value); if (static::$isLittleEndian === true) { $bin = strrev($bin); } $this->pickle .= self::OP_BINFLOAT . $bin; } } protected function writeString($value) { if (($id = $this->searchMemo($value)) !== false) { $this->writeGet($id); return; } if ($this->protocol == 0) { $this->pickle .= self::OP_STRING . $this->quoteString($value) . "\r\n"; } else { $n = strlen($value); if ($n <= 0xFF) { $this->pickle .= self::OP_SHORT_BINSTRING . chr($n) . $value; } else { $binLen = pack('l', $n); if (static::$isLittleEndian === false) { $binLen = strrev($binLen); } $this->pickle .= self::OP_BINSTRING . $binLen . $value; } } $this->memorize($value); } protected function writeArrayDict($value) { if (($id = $this->searchMemo($value)) !== false) { $this->writeGet($id); return; } $this->pickle .= self::OP_MARK . self::OP_DICT; $this->memorize($value); foreach ($value as $k => $v) { $this->write($k); $this->write($v); $this->pickle .= self::OP_SETITEM; } } protected function writeArrayList(array $value) { if (($id = $this->searchMemo($value)) !== false) { $this->writeGet($id); return; } $this->pickle .= self::OP_MARK . self::OP_LIST; $this->memorize($value); foreach ($value as $v) { $this->write($v); $this->pickle .= self::OP_APPEND; } } protected function writeObject($value) { if ($value instanceof \SplFixedArray) { $this->writeArrayList($value->toArray()); } elseif (method_exists($value, 'toArray')) { $this->writeArrayDict($value->toArray()); } elseif ($value instanceof Traversable) { $this->writeArrayDict($value); } else { $this->writeArrayDict(get_object_vars($value)); } } protected function writeStop() { $this->pickle .= self::OP_STOP; } protected function memorize($value) { $id = count($this->memo); $this->memo[$id] = $value; $this->writePut($id); } protected function searchMemo($value) { return array_search($value, $this->memo, true); } protected function quoteString($str) { $quoteArr = static::$quoteString; if (($cntSingleQuote = substr_count($str, "'")) && ($cntDoubleQuote = substr_count($str, '"')) && ($cntSingleQuote < $cntDoubleQuote) ) { $quoteArr['"'] = '\\"'; $enclosure = '"'; } else { $quoteArr["'"] = "\\'"; $enclosure = "'"; } return $enclosure . strtr($str, $quoteArr) . $enclosure; } public function unserialize($pickle) { $this->clearProcessVars(); $this->pickle = $pickle; $this->pickleLen = strlen($this->pickle); while (($op = $this->read(1)) !== self::OP_STOP) { $this->load($op); } if (!count($this->stack)) { throw new Exception\RuntimeException('No data found'); } $ret = array_pop($this->stack); $this->clearProcessVars(); return $ret; } protected function clearProcessVars() { $this->pos = 0; $this->pickle = ''; $this->pickleLen = 0; $this->memo = array(); $this->stack = array(); } protected function load($op) { switch ($op) { case self::OP_PUT: $this->loadPut(); break; case self::OP_BINPUT: $this->loadBinPut(); break; case self::OP_LONG_BINPUT: $this->loadLongBinPut(); break; case self::OP_GET: $this->loadGet(); break; case self::OP_BINGET: $this->loadBinGet(); break; case self::OP_LONG_BINGET: $this->loadLongBinGet(); break; case self::OP_NONE: $this->loadNone(); break; case self::OP_NEWTRUE: $this->loadNewTrue(); break; case self::OP_NEWFALSE: $this->loadNewFalse(); break; case self::OP_INT: $this->loadInt(); break; case self::OP_BININT: $this->loadBinInt(); break; case self::OP_BININT1: $this->loadBinInt1(); break; case self::OP_BININT2: $this->loadBinInt2(); break; case self::OP_LONG: $this->loadLong(); break; case self::OP_LONG1: $this->loadLong1(); break; case self::OP_LONG4: $this->loadLong4(); break; case self::OP_FLOAT: $this->loadFloat(); break; case self::OP_BINFLOAT: $this->loadBinFloat(); break; case self::OP_STRING: $this->loadString(); break; case self::OP_BINSTRING: $this->loadBinString(); break; case self::OP_SHORT_BINSTRING: $this->loadShortBinString(); break; case self::OP_BINBYTES: $this->loadBinBytes(); break; case self::OP_SHORT_BINBYTES: $this->loadShortBinBytes(); break; case self::OP_UNICODE: $this->loadUnicode(); break; case self::OP_BINUNICODE: $this->loadBinUnicode(); break; case self::OP_MARK: $this->loadMark(); break; case self::OP_LIST: $this->loadList(); break; case self::OP_EMPTY_LIST: $this->loadEmptyList(); break; case self::OP_APPEND: $this->loadAppend(); break; case self::OP_APPENDS: $this->loadAppends(); break; case self::OP_DICT: $this->loadDict(); break; case self::OP_EMPTY_DICT: $this->_loadEmptyDict(); break; case self::OP_SETITEM: $this->loadSetItem(); break; case self::OP_SETITEMS: $this->loadSetItems(); break; case self::OP_TUPLE: $this->loadTuple(); break; case self::OP_TUPLE1: $this->loadTuple1(); break; case self::OP_TUPLE2: $this->loadTuple2(); break; case self::OP_TUPLE3: $this->loadTuple3(); break; case self::OP_PROTO: $this->loadProto(); break; default: throw new Exception\RuntimeException("Invalid or unknown opcode '{$op}'"); } } protected function loadPut() { $id = (int) $this->readline(); $lastStack = count($this->stack) - 1; if (!isset($this->stack[$lastStack])) { throw new Exception\RuntimeException('No stack exist'); } $this->memo[$id] =& $this->stack[$lastStack]; } protected function loadBinPut() { $id = ord($this->read(1)); $lastStack = count($this->stack)-1; if (!isset($this->stack[$lastStack])) { throw new Exception\RuntimeException('No stack exist'); } $this->memo[$id] =& $this->stack[$lastStack]; } protected function loadLongBinPut() { $bin = $this->read(4); if (static::$isLittleEndian === false) { $bin = strrev($bin); } list(, $id) = unpack('l', $bin); $lastStack = count($this->stack)-1; if (!isset($this->stack[$lastStack])) { throw new Exception\RuntimeException('No stack exist'); } $this->memo[$id] =& $this->stack[$lastStack]; } protected function loadGet() { $id = (int) $this->readline(); if (!array_key_exists($id, $this->memo)) { throw new Exception\RuntimeException('Get id "' . $id . '" not found in memo'); } $this->stack[] =& $this->memo[$id]; } protected function loadBinGet() { $id = ord($this->read(1)); if (!array_key_exists($id, $this->memo)) { throw new Exception\RuntimeException('Get id "' . $id . '" not found in memo'); } $this->stack[] =& $this->memo[$id]; } protected function loadLongBinGet() { $bin = $this->read(4); if (static::$isLittleEndian === false) { $bin = strrev($bin); } list(, $id) = unpack('l', $bin); if (!array_key_exists($id, $this->memo)) { throw new Exception\RuntimeException('Get id "' . $id . '" not found in memo'); } $this->stack[] =& $this->memo[$id]; } protected function loadNone() { $this->stack[] = null; } protected function loadNewTrue() { $this->stack[] = true; } protected function loadNewFalse() { $this->stack[] = false; } protected function loadInt() { $line = $this->readline(); if ($line === '01') { $this->stack[] = true; } elseif ($line === '00') { $this->stack[] = false; } else { $this->stack[] = (int) $line; } } protected function loadBinInt() { $bin = $this->read(4); if (static::$isLittleEndian === false) { $bin = strrev($bin); } list(, $int) = unpack('l', $bin); $this->stack[] = $int; } protected function loadBinInt1() { $this->stack[] = ord($this->read(1)); } protected function loadBinInt2() { $bin = $this->read(2); list(, $int) = unpack('v', $bin); $this->stack[] = $int; } protected function loadLong() { $data = rtrim($this->readline(), 'L'); if ($data === '') { $this->stack[] = 0; } else { $this->stack[] = $data; } } protected function loadLong1() { $n = ord($this->read(1)); $data = $this->read($n); $this->stack[] = $this->decodeBinLong($data); } protected function loadLong4() { $nBin = $this->read(4); if (static::$isLittleEndian === false) { $nBin = strrev($$nBin); } list(, $n) = unpack('l', $nBin); $data = $this->read($n); $this->stack[] = $this->decodeBinLong($data); } protected function loadFloat() { $float = (float) $this->readline(); $this->stack[] = $float; } protected function loadBinFloat() { $bin = $this->read(8); if (static::$isLittleEndian === true) { $bin = strrev($bin); } list(, $float) = unpack('d', $bin); $this->stack[] = $float; } protected function loadString() { $this->stack[] = $this->unquoteString((string) $this->readline()); } protected function loadBinString() { $bin = $this->read(4); if (!static::$isLittleEndian) { $bin = strrev($bin); } list(, $len) = unpack('l', $bin); $this->stack[] = (string) $this->read($len); } protected function loadShortBinString() { $len = ord($this->read(1)); $this->stack[] = (string) $this->read($len); } protected function loadBinBytes() { $nBin = $this->read(4); if (static::$isLittleEndian === false) { $nBin = strrev($$nBin); } list(, $n) = unpack('l', $nBin); $this->stack[] = $this->read($n); } protected function loadShortBinBytes() { $n = ord($this->read(1)); $this->stack[] = $this->read($n); } protected function loadUnicode() { $data = $this->readline(); $pattern = '/\\\\u([a-fA-F0-9]{4})/u'; $data = preg_replace_callback($pattern, array($this, '_convertMatchingUnicodeSequence2Utf8'), $data); $this->stack[] = $data; } protected function _convertMatchingUnicodeSequence2Utf8(array $match) { return $this->hex2Utf8($match[1]); } protected function hex2Utf8($hex) { $uniCode = hexdec($hex); if ($uniCode < 0x80) { $utf8Char = chr($uniCode); } elseif ($uniCode < 0x800) { $utf8Char = chr(0xC0 | $uniCode >> 6) . chr(0x80 | $uniCode & 0x3F); } elseif ($uniCode < 0x10000) { $utf8Char = chr(0xE0 | $uniCode >> 12) . chr(0x80 | $uniCode >> 6 & 0x3F) . chr(0x80 | $uniCode & 0x3F); } elseif ($uniCode < 0x110000) { $utf8Char = chr(0xF0 | $uniCode >> 18) . chr(0x80 | $uniCode >> 12 & 0x3F) . chr(0x80 | $uniCode >> 6 & 0x3F) . chr(0x80 | $uniCode & 0x3F); } else { throw new Exception\RuntimeException(sprintf( 'Unsupported unicode character found "%s"', dechex($uniCode) )); } return $utf8Char; } protected function loadBinUnicode() { $n = $this->read(4); if (static::$isLittleEndian === false) { $n = strrev($n); } list(, $n) = unpack('l', $n); $data = $this->read($n); $this->stack[] = $data; } protected function loadMark() { $this->stack[] = $this->marker; } protected function loadList() { $k = $this->lastMarker(); $this->stack[$k] = array(); for ($i = $k + 1, $max = count($this->stack); $i < $max; $i++) { unset($this->stack[$i]); } } protected function loadAppend() { $value = array_pop($this->stack); $list =& $this->stack[count($this->stack) - 1]; $list[] = $value; } protected function loadEmptyList() { $this->stack[] = array(); } protected function loadAppends() { $k = $this->lastMarker(); $list =& $this->stack[$k - 1]; $max = count($this->stack); for ($i = $k + 1; $i < $max; $i++) { $list[] = $this->stack[$i]; unset($this->stack[$i]); } unset($this->stack[$k]); } protected function loadDict() { $k = $this->lastMarker(); $this->stack[$k] = array(); $max = count($this->stack); for ($i = $k + 1; $i < $max; $i++) { unset($this->stack[$i]); } } protected function loadSetItem() { $value = array_pop($this->stack); $key = array_pop($this->stack); $dict =& $this->stack[count($this->stack) - 1]; $dict[$key] = $value; } protected function _loadEmptyDict() { $this->stack[] = array(); } protected function loadSetItems() { $k = $this->lastMarker(); $dict =& $this->stack[$k - 1]; $max = count($this->stack); for ($i = $k + 1; $i < $max; $i += 2) { $key = $this->stack[$i]; $value = $this->stack[$i + 1]; $dict[$key] = $value; unset($this->stack[$i], $this->stack[$i+1]); } unset($this->stack[$k]); } protected function loadTuple() { $k = $this->lastMarker(); $this->stack[$k] = array(); $tuple =& $this->stack[$k]; $max = count($this->stack); for ($i = $k + 1; $i < $max; $i++) { $tuple[] = $this->stack[$i]; unset($this->stack[$i]); } } protected function loadTuple1() { $value1 = array_pop($this->stack); $this->stack[] = array($value1); } protected function loadTuple2() { $value2 = array_pop($this->stack); $value1 = array_pop($this->stack); $this->stack[] = array($value1, $value2); } protected function loadTuple3() { $value3 = array_pop($this->stack); $value2 = array_pop($this->stack); $value1 = array_pop($this->stack); $this->stack[] = array($value1, $value2, $value3); } protected function loadProto() { $proto = ord($this->read(1)); if ($proto < 2 || $proto > 3) { throw new Exception\RuntimeException( "Invalid or unknown protocol version '{$proto}' detected" ); } $this->protocol = $proto; } protected function read($len) { if (($this->pos + $len) > $this->pickleLen) { throw new Exception\RuntimeException('End of data'); } $this->pos += $len; return substr($this->pickle, ($this->pos - $len), $len); } protected function readline() { $eolLen = 2; $eolPos = strpos($this->pickle, "\r\n", $this->pos); if ($eolPos === false) { $eolPos = strpos($this->pickle, "\n", $this->pos); $eolLen = 1; } if ($eolPos === false) { throw new Exception\RuntimeException('No new line found'); } $ret = substr($this->pickle, $this->pos, $eolPos-$this->pos); $this->pos = $eolPos + $eolLen; return $ret; } protected function unquoteString($str) { $quoteArr = array_flip(static::$quoteString); if ($str[0] == '"') { $quoteArr['\\"'] = '"'; } else { $quoteArr["\\'"] = "'"; } return strtr(substr(trim($str), 1, -1), $quoteArr); } protected function lastMarker() { for ($k = count($this->stack)-1; $k >= 0; $k -= 1) { if ($this->stack[$k] === $this->marker) { break; } } return $k; } protected function decodeBinLong($data) { $nbytes = strlen($data); if ($nbytes == 0) { return 0; } $long = 0; if ($nbytes > 7) { if ($this->bigIntegerAdapter === null) { $this->bigIntegerAdapter = BigInteger\BigInteger::getDefaultAdapter(); } if (static::$isLittleEndian === true) { $data = strrev($data); } $long = $this->bigIntegerAdapter->binToInt($data, true); } else { for ($i = 0; $i < $nbytes; $i++) { $long += ord($data[$i]) * pow(256, $i); } if (0x80 <= ord($data[$nbytes - 1])) { $long -= pow(2, $nbytes * 8); } } return $long; } } get($adapterName, $adapterOptions); } public static function setAdapterPluginManager(AdapterPluginManager $adapters) { static::$adapters = $adapters; } public static function getAdapterPluginManager() { if (static::$adapters === null) { static::$adapters = new AdapterPluginManager(); } return static::$adapters; } public static function resetAdapterPluginManager() { static::$adapters = new AdapterPluginManager(); return static::$adapters; } public static function setDefaultAdapter($adapter, $adapterOptions = null) { static::$defaultAdapter = static::factory($adapter, $adapterOptions); } public static function getDefaultAdapter() { if (!static::$defaultAdapter instanceof Adapter) { static::setDefaultAdapter(static::$defaultAdapter); } return static::$defaultAdapter; } public static function serialize($value, $adapter = null, $adapterOptions = null) { if ($adapter !== null) { $adapter = static::factory($adapter, $adapterOptions); } else { $adapter = static::getDefaultAdapter(); } return $adapter->serialize($value); } public static function unserialize($serialized, $adapter = null, $adapterOptions = null) { if ($adapter !== null) { $adapter = static::factory($adapter, $adapterOptions); } else { $adapter = static::getDefaultAdapter(); } return $adapter->unserialize($serialized); } } inputFilter = $inputFilter; return $this; } public function getInputFilter() { return $this->inputFilter; } } getFactory()->createInputFilter($inputFilter); } if (!$inputFilter instanceof BaseInputFilter) { throw new Exception\RuntimeException(sprintf( '%s expects an instance of %s; received "%s"', __METHOD__, 'Zend\InputFilter\BaseInputFilter', (is_object($inputFilter) ? get_class($inputFilter) : gettype($inputFilter)) )); } $this->inputFilter = $inputFilter; $this->inputs = $inputFilter->getInputs(); return $this; } public function getInputFilter() { if (null === $this->inputFilter) { $this->setInputFilter(new InputFilter()); } return $this->inputFilter; } public function setIsRequired($isRequired) { $this->isRequired = $isRequired; return $this; } public function getIsRequired() { return $this->isRequired; } public function setCount($count) { $this->count = $count > 0 ? $count : 0; return $this; } public function getCount() { if (null === $this->count) { $this->count = count($this->collectionData); } return $this->count; } public function setData($data) { $this->collectionData = $data; } public function isValid() { $valid = true; if ($this->getCount() < 1) { if ($this->isRequired) { $valid = false; } return $valid; } if (count($this->collectionData) < $this->getCount()) { $valid = false; } $inputs = $this->validationGroup ?: array_keys($this->inputs); foreach ($this->collectionData as $key => $data) { if (!is_array($data)) { $data = array(); } $this->data = $data; $this->populate(); if ($this->validateInputs($inputs)) { $this->collectionValidInputs[$key] = $this->validInputs; } else { $this->collectionInvalidInputs[$key] = $this->invalidInputs; $valid = false; } $values = array(); $rawValues = array(); foreach ($inputs as $name) { $input = $this->inputs[$name]; if ($input instanceof InputFilterInterface) { $values[$name] = $input->getValues(); $rawValues[$name] = $input->getRawValues(); continue; } $values[$name] = $input->getValue($this->data); $rawValues[$name] = $input->getRawValue(); } $this->collectionValues[$key] = $values; $this->collectionRawValues[$key] = $rawValues; } return $valid; } public function setValidationGroup($name) { if ($name === self::VALIDATE_ALL) { $this->validationGroup = null; return $this; } if (is_array($name)) { if (count($name) == count($this->collectionData) && is_array(reset($name))) { return parent::setValidationGroup(reset($name)); } return parent::setValidationGroup($name); } return parent::setValidationGroup(func_get_args()); } public function getInvalidInput() { return (is_array($this->collectionInvalidInputs) ? $this->collectionInvalidInputs : array()); } public function getValidInput() { return (is_array($this->collectionValidInputs) ? $this->collectionValidInputs : array()); } public function getValues() { return $this->collectionValues; } public function getRawValues() { return $this->collectionRawValues; } public function getMessages() { $messages = array(); foreach ($this->getInvalidInput() as $key => $inputs) { foreach ($inputs as $name => $input) { $messages[$key][$name] = $input->getMessages(); } } return $messages; } } name = $name; } public function setAllowEmpty($allowEmpty) { $this->allowEmpty = (bool) $allowEmpty; return $this; } public function setBreakOnFailure($breakOnFailure) { $this->breakOnFailure = (bool) $breakOnFailure; return $this; } public function setContinueIfEmpty($continueIfEmpty) { $this->continueIfEmpty = (bool) $continueIfEmpty; return $this; } public function setErrorMessage($errorMessage) { $this->errorMessage = (null === $errorMessage) ? null : (string) $errorMessage; return $this; } public function setFilterChain(FilterChain $filterChain) { $this->filterChain = $filterChain; return $this; } public function setName($name) { $this->name = (string) $name; return $this; } public function setRequired($required) { $this->required = (bool) $required; $this->setAllowEmpty(!$required); return $this; } public function setValidatorChain(ValidatorChain $validatorChain) { $this->validatorChain = $validatorChain; return $this; } public function setValue($value) { $this->value = $value; return $this; } public function setFallbackValue($value) { $this->fallbackValue = $value; return $this; } public function allowEmpty() { return $this->allowEmpty; } public function breakOnFailure() { return $this->breakOnFailure; } public function continueIfEmpty() { return $this->continueIfEmpty; } public function getErrorMessage() { return $this->errorMessage; } public function getFilterChain() { if (!$this->filterChain) { $this->setFilterChain(new FilterChain()); } return $this->filterChain; } public function getName() { return $this->name; } public function getRawValue() { return $this->value; } public function isRequired() { return $this->required; } public function getValidatorChain() { if (!$this->validatorChain) { $this->setValidatorChain(new ValidatorChain()); } return $this->validatorChain; } public function getValue() { $filter = $this->getFilterChain(); return $filter->filter($this->value); } public function getFallbackValue() { return $this->fallbackValue; } public function merge(InputInterface $input) { $this->setAllowEmpty($input->allowEmpty()); $this->setBreakOnFailure($input->breakOnFailure()); $this->setContinueIfEmpty($input->continueIfEmpty()); $this->setErrorMessage($input->getErrorMessage()); $this->setName($input->getName()); $this->setRequired($input->isRequired()); $this->setValue($input->getRawValue()); $filterChain = $input->getFilterChain(); $this->getFilterChain()->merge($filterChain); $validatorChain = $input->getValidatorChain(); $this->getValidatorChain()->merge($validatorChain); return $this; } public function isValid($context = null) { if (!$this->continueIfEmpty()) { $this->injectNotEmptyValidator(); } $validator = $this->getValidatorChain(); $value = $this->getValue(); $result = $validator->isValid($value, $context); if (!$result && $fallbackValue = $this->getFallbackValue()) { $this->setValue($fallbackValue); $result = true; } return $result; } public function getMessages() { if (null !== $this->errorMessage) { return (array) $this->errorMessage; } if ($this->getFallbackValue()) { return array(); } $validator = $this->getValidatorChain(); return $validator->getMessages(); } protected function injectNotEmptyValidator() { if ((!$this->isRequired() && $this->allowEmpty()) || $this->notEmptyValidator) { return; } $chain = $this->getValidatorChain(); $validators = $chain->getValidators(); foreach ($validators as $validator) { if ($validator['instance'] instanceof NotEmpty) { $this->notEmptyValidator = true; return; } } $chain->prependByName('NotEmpty', array(), true); $this->notEmptyValidator = true; } } factory = $factory; return $this; } public function getFactory() { if (null === $this->factory) { $this->setFactory(new Factory()); } return $this->factory; } public function add($input, $name = null) { if (is_array($input) || ($input instanceof Traversable && !$input instanceof InputFilterInterface) ) { $factory = $this->getFactory(); $input = $factory->createInput($input); } return parent::add($input, $name); } } getFilterChain(); $result = array(); foreach ($this->value as $key => $value) { $result[$key] = $filter->filter($value); } return $result; } public function isValid($context = null) { $this->injectNotEmptyValidator(); $validator = $this->getValidatorChain(); $values = $this->getValue(); $result = true; foreach ($values as $value) { $result = $validator->isValid($value, $context); if (!$result) { if ($fallbackValue = $this->getFallbackValue()) { $this->setValue($fallbackValue); $result = true; } break; } } return $result; } } 'Zend\InputFilter\InputFilter', 'collection' => 'Zend\InputFilter\CollectionInputFilter', ); protected $shareByDefault = false; public function __construct(ConfigInterface $configuration = null) { parent::__construct($configuration); $this->addInitializer(array($this, 'populateFactory')); } public function populateFactory($inputfilter) { if ($inputfilter instanceof InputFilter) { $factory = $inputfilter->getFactory(); $factory->setInputFilterManager($this); if ($this->serviceLocator instanceof ServiceLocatorInterface) { $factory->getDefaultFilterChain()->setPluginManager($this->serviceLocator->get('FilterManager')); $factory->getDefaultValidatorChain()->setPluginManager($this->serviceLocator->get('ValidatorManager')); } } } public function validatePlugin($plugin) { if ($plugin instanceof InputFilterInterface) { if ($plugin instanceof InitializableInterface) { $plugin->init(); } return; } throw new Exception\RuntimeException(sprintf( 'Plugin of type %s is invalid; must implement Zend\InputFilter\InputFilterInterface', (is_object($plugin) ? get_class($plugin) : gettype($plugin)) )); } } autoPrependUploadValidator = $value; return $this; } public function getAutoPrependUploadValidator() { return $this->autoPrependUploadValidator; } public function getValue() { $value = $this->value; if ($this->isValid && is_array($value)) { $filter = $this->getFilterChain(); if (isset($value['tmp_name'])) { $value = $filter->filter($value); } else { $newValue = array(); foreach ($value as $fileData) { if (is_array($fileData) && isset($fileData['tmp_name'])) { $newValue[] = $filter->filter($fileData); } } $value = $newValue; } } return $value; } public function isValid($context = null) { $this->injectUploadValidator(); $validator = $this->getValidatorChain(); $rawValue = $this->getRawValue(); if (!is_array($rawValue)) { $rawValue = array( 'tmp_name' => $rawValue, 'name' => $rawValue, 'size' => 0, 'type' => '', 'error' => UPLOAD_ERR_NO_FILE, ); } if (is_array($rawValue) && isset($rawValue['tmp_name'])) { $this->isValid = $validator->isValid($rawValue, $context); } elseif (is_array($rawValue) && !empty($rawValue) && isset($rawValue[0]['tmp_name'])) { $this->isValid = true; foreach ($rawValue as $value) { if (!$validator->isValid($value, $context)) { $this->isValid = false; break; } } } return $this->isValid; } protected function injectUploadValidator() { if (!$this->autoPrependUploadValidator) { return; } $chain = $this->getValidatorChain(); $validators = $chain->getValidators(); if (isset($validators[0]['instance']) && $validators[0]['instance'] instanceof UploadValidator ) { $this->autoPrependUploadValidator = false; return; } $chain->prependByName('fileuploadfile', array(), true); $this->autoPrependUploadValidator = false; } protected function injectNotEmptyValidator() { $this->notEmptyValidator = true; } public function merge(InputInterface $input) { parent::merge($input); if ($input instanceof FileInput) { $this->setAutoPrependUploadValidator($input->getAutoPrependUploadValidator()); } return $this; } } inputs); } public function add($input, $name = null) { if (!$input instanceof InputInterface && !$input instanceof InputFilterInterface) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an instance of %s or %s as its first argument; received "%s"', __METHOD__, 'Zend\InputFilter\InputInterface', 'Zend\InputFilter\InputFilterInterface', (is_object($input) ? get_class($input) : gettype($input)) )); } if ($input instanceof InputInterface && (empty($name) || is_int($name))) { $name = $input->getName(); } if (isset($this->inputs[$name]) && $this->inputs[$name] instanceof InputInterface) { $original = $this->inputs[$name]; $original->merge($input); return $this; } $this->inputs[$name] = $input; return $this; } public function get($name) { if (!array_key_exists($name, $this->inputs)) { throw new Exception\InvalidArgumentException(sprintf( '%s: no input found matching "%s"', __METHOD__, $name )); } return $this->inputs[$name]; } public function has($name) { return (array_key_exists($name, $this->inputs)); } public function remove($name) { unset($this->inputs[$name]); return $this; } public function setData($data) { if (!is_array($data) && !$data instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an array or Traversable argument; received %s', __METHOD__, (is_object($data) ? get_class($data) : gettype($data)) )); } if (is_object($data) && !$data instanceof ArrayAccess) { $data = ArrayUtils::iteratorToArray($data); } $this->data = $data; $this->populate(); return $this; } public function isValid() { if (null === $this->data) { throw new Exception\RuntimeException(sprintf( '%s: no data present to validate!', __METHOD__ )); } $inputs = $this->validationGroup ?: array_keys($this->inputs); return $this->validateInputs($inputs); } protected function validateInputs(array $inputs) { $this->validInputs = array(); $this->invalidInputs = array(); $valid = true; foreach ($inputs as $name) { $input = $this->inputs[$name]; $dataExists = array_key_exists($name, $this->data); if (!$dataExists && $input instanceof InputInterface && !$input->isRequired() ) { $this->validInputs[$name] = $input; continue; } if (!$dataExists && $input instanceof InputInterface && $input->isRequired() && $input->allowEmpty() ) { if(!($input instanceOf EmptyContextInterface && $input->continueIfEmpty())) { $this->validInputs[$name] = $input; continue; } } if ($dataExists && null === $this->data[$name] && $input instanceof InputInterface && !$input->isRequired() ) { $this->validInputs[$name] = $input; continue; } if ($dataExists && null === $this->data[$name] && $input instanceof InputInterface && $input->isRequired() && $input->allowEmpty() ) { if (!($input instanceof EmptyContextInterface && $input->continueIfEmpty())) { $this->validInputs[$name] = $input; continue; } } if ($dataExists && '' === $this->data[$name] && $input instanceof InputInterface && !$input->isRequired() && $input->allowEmpty() ) { $this->validInputs[$name] = $input; continue; } if ($dataExists && '' === $this->data[$name] && $input instanceof InputInterface && $input->isRequired() && $input->allowEmpty() ) { if (!($input instanceof EmptyContextInterface && $input->continueIfEmpty())) { $this->validInputs[$name] = $input; continue; } } if ($dataExists && is_array($this->data[$name]) && ( (isset($this->data[$name]['error']) && $this->data[$name]['error'] === UPLOAD_ERR_NO_FILE) || (count($this->data[$name]) === 1 && isset($this->data[$name][0]) && is_array($this->data[$name][0]) && isset($this->data[$name][0]['error']) && $this->data[$name][0]['error'] === UPLOAD_ERR_NO_FILE) ) && $input instanceof InputInterface && (!$input->isRequired() || $input->allowEmpty()) ) { $this->validInputs[$name] = $input; continue; } if (!$dataExists) { $this->data[$name] = null; } if ($input instanceof InputFilterInterface) { if (!$input->isValid()) { $this->invalidInputs[$name] = $input; $valid = false; continue; } $this->validInputs[$name] = $input; continue; } if ($input instanceof InputInterface) { if (!$input->isValid($this->data)) { $this->invalidInputs[$name] = $input; $valid = false; if ($input->breakOnFailure()) { return false; } continue; } $this->validInputs[$name] = $input; continue; } } return $valid; } public function setValidationGroup($name) { if ($name === self::VALIDATE_ALL) { $this->validationGroup = null; return $this; } if (is_array($name)) { $inputs = array(); foreach ($name as $key => $value) { if (!$this->has($key)) { $inputs[] = $value; } else { $inputs[] = $key; $this->inputs[$key]->setValidationGroup($value); } } if (!empty($inputs)) { $this->validateValidationGroup($inputs); $this->validationGroup = $inputs; } return $this; } $inputs = func_get_args(); $this->validateValidationGroup($inputs); $this->validationGroup = $inputs; return $this; } public function getInvalidInput() { return (is_array($this->invalidInputs) ? $this->invalidInputs : array()); } public function getValidInput() { return (is_array($this->validInputs) ? $this->validInputs : array()); } public function getValue($name) { if (!array_key_exists($name, $this->inputs)) { throw new Exception\InvalidArgumentException(sprintf( '%s expects a valid input name; "%s" was not found in the filter', __METHOD__, $name )); } $input = $this->inputs[$name]; return $input->getValue(); } public function getValues() { $inputs = $this->validationGroup ?: array_keys($this->inputs); $values = array(); foreach ($inputs as $name) { $input = $this->inputs[$name]; if ($input instanceof InputFilterInterface) { $values[$name] = $input->getValues(); continue; } $values[$name] = $input->getValue(); } return $values; } public function getRawValue($name) { if (!array_key_exists($name, $this->inputs)) { throw new Exception\InvalidArgumentException(sprintf( '%s expects a valid input name; "%s" was not found in the filter', __METHOD__, $name )); } $input = $this->inputs[$name]; return $input->getRawValue(); } public function getRawValues() { $values = array(); foreach ($this->inputs as $name => $input) { if ($input instanceof InputFilterInterface) { $values[$name] = $input->getRawValues(); continue; } $values[$name] = $input->getRawValue(); } return $values; } public function getMessages() { $messages = array(); foreach ($this->getInvalidInput() as $name => $input) { $messages[$name] = $input->getMessages(); } return $messages; } protected function validateValidationGroup(array $inputs) { foreach ($inputs as $name) { if (!array_key_exists($name, $this->inputs)) { throw new Exception\InvalidArgumentException(sprintf( 'setValidationGroup() expects a list of valid input names; "%s" was not found', $name )); } } } protected function populate() { foreach (array_keys($this->inputs) as $name) { $input = $this->inputs[$name]; if (!isset($this->data[$name])) { if ($input instanceof InputFilterInterface) { $input->setData(array()); continue; } $input->setValue(null); continue; } $value = $this->data[$name]; if ($input instanceof InputFilterInterface) { $input->setData($value); continue; } $input->setValue($value); } } public function hasUnknown() { if (null === $this->data) { throw new Exception\RuntimeException(sprintf( '%s: no data present!', __METHOD__ )); } $data = array_keys($this->data); $inputs = array_keys($this->inputs); $diff = array_diff($data, $inputs); if (!empty($diff)) { return count(array_intersect($diff, $inputs)) == 0; } return false; } public function getUnknown() { if (null === $this->data) { throw new Exception\RuntimeException(sprintf( '%s: no data present!', __METHOD__ )); } $data = array_keys($this->data); $inputs = array_keys($this->inputs); $diff = array_diff($data, $inputs); $unknownInputs = array(); $intersect = array_intersect($diff, $data); if (!empty($intersect)) { foreach ($intersect as $key) { $unknownInputs[$key] = $this->data[$key]; } } return $unknownInputs; } public function getInputs() { return $this->inputs; } } setInputFilterManager($inputFilterManager); } $this->defaultFilterChain = new FilterChain(); $this->defaultValidatorChain = new ValidatorChain(); } public function setDefaultFilterChain(FilterChain $filterChain) { $this->defaultFilterChain = $filterChain; return $this; } public function getDefaultFilterChain() { return $this->defaultFilterChain; } public function clearDefaultFilterChain() { $this->defaultFilterChain = null; } public function setDefaultValidatorChain(ValidatorChain $validatorChain) { $this->defaultValidatorChain = $validatorChain; return $this; } public function getDefaultValidatorChain() { return $this->defaultValidatorChain; } public function clearDefaultValidatorChain() { $this->defaultValidatorChain = null; } public function setInputFilterManager(InputFilterPluginManager $inputFilterManager) { $this->inputFilterManager = $inputFilterManager; $serviceLocator = $this->inputFilterManager->getServiceLocator(); if ($serviceLocator && $serviceLocator instanceof ServiceLocatorInterface) { if ($serviceLocator->has('ValidatorManager')) { $this->getDefaultValidatorChain()->setPluginManager($serviceLocator->get('ValidatorManager')); } if ($serviceLocator->has('FilterManager')) { $this->getDefaultFilterChain()->setPluginManager($serviceLocator->get('FilterManager')); } } return $this; } public function getInputFilterManager() { if (null === $this->inputFilterManager) { $this->inputFilterManager = new InputFilterPluginManager; } return $this->inputFilterManager; } public function createInput($inputSpecification) { if (!is_array($inputSpecification) && !$inputSpecification instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an array or Traversable; received "%s"', __METHOD__, (is_object($inputSpecification) ? get_class($inputSpecification) : gettype($inputSpecification)) )); } if ($inputSpecification instanceof Traversable) { $inputSpecification = ArrayUtils::iteratorToArray($inputSpecification); } $class = 'Zend\InputFilter\Input'; if (isset($inputSpecification['type'])) { $class = $inputSpecification['type']; if ($this->getInputFilterManager()->has($class)) { return $this->createInputFilter($inputSpecification); } if (!class_exists($class)) { throw new Exception\RuntimeException(sprintf( 'Input factory expects the "type" to be a valid class; received "%s"', $class )); } } $input = new $class(); if ($input instanceof InputFilterInterface) { return $this->createInputFilter($inputSpecification); } if (!$input instanceof InputInterface) { throw new Exception\RuntimeException(sprintf( 'Input factory expects the "type" to be a class implementing %s; received "%s"', 'Zend\InputFilter\InputInterface', $class )); } if ($this->defaultFilterChain) { $input->setFilterChain(clone $this->defaultFilterChain); } if ($this->defaultValidatorChain) { $input->setValidatorChain(clone $this->defaultValidatorChain); } foreach ($inputSpecification as $key => $value) { switch ($key) { case 'name': $input->setName($value); break; case 'required': $input->setRequired($value); if (isset($inputSpecification['allow_empty'])) { $input->setAllowEmpty($inputSpecification['allow_empty']); } break; case 'allow_empty': $input->setAllowEmpty($value); if (!isset($inputSpecification['required'])) { $input->setRequired(!$value); } break; case 'continue_if_empty': $input->setContinueIfEmpty($inputSpecification['continue_if_empty']); break; case 'error_message': $input->setErrorMessage($value); break; case 'fallback_value': $input->setFallbackValue($value); break; case 'filters': if ($value instanceof FilterChain) { $input->setFilterChain($value); break; } if (!is_array($value) && !$value instanceof Traversable) { throw new Exception\RuntimeException(sprintf( '%s expects the value associated with "filters" to be an array/Traversable of filters or filter specifications, or a FilterChain; received "%s"', __METHOD__, (is_object($value) ? get_class($value) : gettype($value)) )); } $this->populateFilters($input->getFilterChain(), $value); break; case 'validators': if ($value instanceof ValidatorChain) { $input->setValidatorChain($value); break; } if (!is_array($value) && !$value instanceof Traversable) { throw new Exception\RuntimeException(sprintf( '%s expects the value associated with "validators" to be an array/Traversable of validators or validator specifications, or a ValidatorChain; received "%s"', __METHOD__, (is_object($value) ? get_class($value) : gettype($value)) )); } $this->populateValidators($input->getValidatorChain(), $value); break; default: break; } } return $input; } public function createInputFilter($inputFilterSpecification) { if (!is_array($inputFilterSpecification) && !$inputFilterSpecification instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an array or Traversable; received "%s"', __METHOD__, (is_object($inputFilterSpecification) ? get_class($inputFilterSpecification) : gettype($inputFilterSpecification)) )); } if ($inputFilterSpecification instanceof Traversable) { $inputFilterSpecification = ArrayUtils::iteratorToArray($inputFilterSpecification); } $type = 'Zend\InputFilter\InputFilter'; if (isset($inputFilterSpecification['type']) && is_string($inputFilterSpecification['type'])) { $type = $inputFilterSpecification['type']; unset($inputFilterSpecification['type']); } $inputFilter = $this->getInputFilterManager()->get($type); if ($inputFilter instanceof CollectionInputFilter) { $inputFilter->setFactory($this); if (isset($inputFilterSpecification['input_filter'])) { $inputFilter->setInputFilter($inputFilterSpecification['input_filter']); } if (isset($inputFilterSpecification['count'])) { $inputFilter->setCount($inputFilterSpecification['count']); } return $inputFilter; } foreach ($inputFilterSpecification as $key => $value) { if (($value instanceof InputInterface) || ($value instanceof InputFilterInterface) ) { $input = $value; } else { $input = $this->createInput($value); } $inputFilter->add($input, $key); } return $inputFilter; } protected function populateFilters(FilterChain $chain, $filters) { foreach ($filters as $filter) { if (is_object($filter) || is_callable($filter)) { $chain->attach($filter); continue; } if (is_array($filter)) { if (!isset($filter['name'])) { throw new Exception\RuntimeException( 'Invalid filter specification provided; does not include "name" key' ); } $name = $filter['name']; $priority = isset($filter['priority']) ? $filter['priority'] : FilterChain::DEFAULT_PRIORITY; $options = array(); if (isset($filter['options'])) { $options = $filter['options']; } $chain->attachByName($name, $options, $priority); continue; } throw new Exception\RuntimeException( 'Invalid filter specification provided; was neither a filter instance nor an array specification' ); } } protected function populateValidators(ValidatorChain $chain, $validators) { foreach ($validators as $validator) { if ($validator instanceof ValidatorInterface) { $chain->attach($validator); continue; } if (is_array($validator)) { if (!isset($validator['name'])) { throw new Exception\RuntimeException( 'Invalid validator specification provided; does not include "name" key' ); } $name = $validator['name']; $options = array(); if (isset($validator['options'])) { $options = $validator['options']; } $breakChainOnFailure = false; if (isset($validator['break_chain_on_failure'])) { $breakChainOnFailure = $validator['break_chain_on_failure']; } $chain->attachByName($name, $options, $breakChainOnFailure); continue; } throw new Exception\RuntimeException( 'Invalid validator specification provided; was neither a validator instance nor an array specification' ); } } } setOptions($options); } } public function setOptions($options) { if (!is_array($options) && !($options instanceof \Traversable)) { require_once __DIR__ . '/Exception/InvalidArgumentException.php'; throw new Exception\InvalidArgumentException('Options must be either an array or Traversable'); } foreach ($options as $type => $pairs) { switch ($type) { case self::AUTOREGISTER_ZF: if ($pairs) { $this->registerNamespace('Zend', dirname(__DIR__)); } break; case self::LOAD_NS: if (is_array($pairs) || $pairs instanceof \Traversable) { $this->registerNamespaces($pairs); } break; case self::LOAD_PREFIX: if (is_array($pairs) || $pairs instanceof \Traversable) { $this->registerPrefixes($pairs); } break; case self::ACT_AS_FALLBACK: $this->setFallbackAutoloader($pairs); break; default: } } return $this; } public function setFallbackAutoloader($flag) { $this->fallbackAutoloaderFlag = (bool) $flag; return $this; } public function isFallbackAutoloader() { return $this->fallbackAutoloaderFlag; } public function registerNamespace($namespace, $directory) { $namespace = rtrim($namespace, self::NS_SEPARATOR) . self::NS_SEPARATOR; $this->namespaces[$namespace] = $this->normalizeDirectory($directory); return $this; } public function registerNamespaces($namespaces) { if (!is_array($namespaces) && !$namespaces instanceof \Traversable) { require_once __DIR__ . '/Exception/InvalidArgumentException.php'; throw new Exception\InvalidArgumentException('Namespace pairs must be either an array or Traversable'); } foreach ($namespaces as $namespace => $directory) { $this->registerNamespace($namespace, $directory); } return $this; } public function registerPrefix($prefix, $directory) { $prefix = rtrim($prefix, self::PREFIX_SEPARATOR). self::PREFIX_SEPARATOR; $this->prefixes[$prefix] = $this->normalizeDirectory($directory); return $this; } public function registerPrefixes($prefixes) { if (!is_array($prefixes) && !$prefixes instanceof \Traversable) { require_once __DIR__ . '/Exception/InvalidArgumentException.php'; throw new Exception\InvalidArgumentException('Prefix pairs must be either an array or Traversable'); } foreach ($prefixes as $prefix => $directory) { $this->registerPrefix($prefix, $directory); } return $this; } public function autoload($class) { $isFallback = $this->isFallbackAutoloader(); if (false !== strpos($class, self::NS_SEPARATOR)) { if ($this->loadClass($class, self::LOAD_NS)) { return $class; } elseif ($isFallback) { return $this->loadClass($class, self::ACT_AS_FALLBACK); } return false; } if (false !== strpos($class, self::PREFIX_SEPARATOR)) { if ($this->loadClass($class, self::LOAD_PREFIX)) { return $class; } elseif ($isFallback) { return $this->loadClass($class, self::ACT_AS_FALLBACK); } return false; } if ($isFallback) { return $this->loadClass($class, self::ACT_AS_FALLBACK); } return false; } public function register() { spl_autoload_register(array($this, 'autoload')); } protected function transformClassNameToFilename($class, $directory) { $matches = array(); preg_match('/(?P.+\\\)?(?P[^\\\]+$)/', $class, $matches); $class = (isset($matches['class'])) ? $matches['class'] : ''; $namespace = (isset($matches['namespace'])) ? $matches['namespace'] : ''; return $directory . str_replace(self::NS_SEPARATOR, '/', $namespace) . str_replace(self::PREFIX_SEPARATOR, '/', $class) . '.php'; } protected function loadClass($class, $type) { if (!in_array($type, array(self::LOAD_NS, self::LOAD_PREFIX, self::ACT_AS_FALLBACK))) { require_once __DIR__ . '/Exception/InvalidArgumentException.php'; throw new Exception\InvalidArgumentException(); } if ($type === self::ACT_AS_FALLBACK) { $filename = $this->transformClassNameToFilename($class, ''); $resolvedName = stream_resolve_include_path($filename); if ($resolvedName !== false) { return include $resolvedName; } return false; } foreach ($this->$type as $leader => $path) { if (0 === strpos($class, $leader)) { $trimmedClass = substr($class, strlen($leader)); $filename = $this->transformClassNameToFilename($trimmedClass, $path); if (file_exists($filename)) { return include $filename; } return false; } } return false; } protected function normalizeDirectory($directory) { $last = $directory[strlen($directory) - 1]; if (in_array($last, array('/', '\\'))) { $directory[strlen($directory) - 1] = DIRECTORY_SEPARATOR; return $directory; } $directory .= DIRECTORY_SEPARATOR; return $directory; } } setOptions($options); } } public function setOptions($options) { $this->registerAutoloadMaps($options); return $this; } public function registerAutoloadMap($map) { if (is_string($map)) { $location = $map; if ($this === ($map = $this->loadMapFromFile($location))) { return $this; } } if (!is_array($map)) { require_once __DIR__ . '/Exception/InvalidArgumentException.php'; throw new Exception\InvalidArgumentException(sprintf( 'Map file provided does not return a map. Map file: "%s"', (isset($location) && is_string($location) ? $location : 'unexpected type: ' . gettype($map)) )); } $this->map = array_merge($this->map, $map); if (isset($location)) { $this->mapsLoaded[] = $location; } return $this; } public function registerAutoloadMaps($locations) { if (!is_array($locations) && !($locations instanceof Traversable)) { require_once __DIR__ . '/Exception/InvalidArgumentException.php'; throw new Exception\InvalidArgumentException('Map list must be an array or implement Traversable'); } foreach ($locations as $location) { $this->registerAutoloadMap($location); } return $this; } public function getAutoloadMap() { return $this->map; } public function autoload($class) { if (isset($this->map[$class])) { require_once $this->map[$class]; return $class; } return false; } public function register() { spl_autoload_register(array($this, 'autoload'), true, true); } protected function loadMapFromFile($location) { if (!file_exists($location)) { require_once __DIR__ . '/Exception/InvalidArgumentException.php'; throw new Exception\InvalidArgumentException(sprintf( 'Map file provided does not exist. Map file: "%s"', (is_string($location) ? $location : 'unexpected type: ' . gettype($location)) )); } if (!$path = static::realPharPath($location)) { $path = realpath($location); } if (in_array($path, $this->mapsLoaded)) { return $this; } $map = include $path; return $map; } public static function realPharPath($path) { if (strpos($path, 'phar:///') !== 0) { return; } $parts = explode('/', str_replace(array('/', '\\'), '/', substr($path, 8))); $parts = array_values(array_filter($parts, function ($p) { return ($p !== '' && $p !== '.'); })); array_walk($parts, function ($value, $key) use(&$parts) { if ($value === '..') { unset($parts[$key], $parts[$key-1]); $parts = array_values($parts); } }); if (file_exists($realPath = 'phar:///' . implode('/', $parts))) { return $realPath; } } } pharExtensions = array( 'phar', 'phar.tar', 'tar', ); if (extension_loaded('zlib')) { $this->pharExtensions[] = 'phar.gz'; $this->pharExtensions[] = 'phar.tar.gz'; $this->pharExtensions[] = 'tar.gz'; $this->pharExtensions[] = 'phar.zip'; $this->pharExtensions[] = 'zip'; } if (extension_loaded('bzip2')) { $this->pharExtensions[] = 'phar.bz2'; $this->pharExtensions[] = 'phar.tar.bz2'; $this->pharExtensions[] = 'tar.bz2'; } } if (null !== $options) { $this->setOptions($options); } } public function setOptions($options) { $this->registerPaths($options); return $this; } public function getModuleClassMap() { return $this->moduleClassMap; } public function setModuleClassMap(array $classmap) { $this->moduleClassMap = $classmap; return $this; } public function autoload($class) { if (substr($class, -7) !== '\Module') { return false; } if (isset($this->moduleClassMap[$class])) { require_once $this->moduleClassMap[$class]; return $class; } $moduleName = substr($class, 0, -7); if (isset($this->explicitPaths[$moduleName])) { $classLoaded = $this->loadModuleFromDir($this->explicitPaths[$moduleName], $class); if ($classLoaded) { return $classLoaded; } $classLoaded = $this->loadModuleFromPhar($this->explicitPaths[$moduleName], $class); if ($classLoaded) { return $classLoaded; } } if (count($this->namespacedPaths) >= 1) { foreach ($this->namespacedPaths as $namespace => $path) { if (false === strpos($moduleName, $namespace)) { continue; } $moduleNameBuffer = str_replace($namespace . "\\", "", $moduleName ); $path .= DIRECTORY_SEPARATOR . $moduleNameBuffer . DIRECTORY_SEPARATOR; $classLoaded = $this->loadModuleFromDir($path, $class); if ($classLoaded) { return $classLoaded; } $classLoaded = $this->loadModuleFromPhar($path, $class); if ($classLoaded) { return $classLoaded; } } } $moduleClassPath = str_replace('\\', DIRECTORY_SEPARATOR, $moduleName); $pharSuffixPattern = null; if ($this->pharExtensions) { $pharSuffixPattern = '(' . implode('|', array_map('preg_quote', $this->pharExtensions)) . ')'; } foreach ($this->paths as $path) { $path = $path . $moduleClassPath; $classLoaded = $this->loadModuleFromDir($path, $class); if ($classLoaded) { return $classLoaded; } if ($pharSuffixPattern) { foreach (new GlobIterator($path . '.*') as $entry) { if ($entry->isDir()) { continue; } if (!preg_match('#.+\.' . $pharSuffixPattern . '$#', $entry->getPathname())) { continue; } $classLoaded = $this->loadModuleFromPhar($entry->getPathname(), $class); if ($classLoaded) { return $classLoaded; } } } } return false; } protected function loadModuleFromDir($dirPath, $class) { $file = new SplFileInfo($dirPath . '/Module.php'); if ($file->isReadable() && $file->isFile()) { require_once $file->getRealPath(); if (class_exists($class)) { $this->moduleClassMap[$class] = $file->getRealPath(); return $class; } } return false; } protected function loadModuleFromPhar($pharPath, $class) { $pharPath = static::normalizePath($pharPath, false); $file = new SplFileInfo($pharPath); if (!$file->isReadable() || !$file->isFile()) { return false; } $fileRealPath = $file->getRealPath(); if (strpos($fileRealPath, '.phar') !== false) { require_once $fileRealPath; if (class_exists($class)) { $this->moduleClassMap[$class] = $fileRealPath; return $class; } } $moduleClassFile = 'phar://' . $fileRealPath . '/Module.php'; $moduleFile = new SplFileInfo($moduleClassFile); if ($moduleFile->isReadable() && $moduleFile->isFile()) { require_once $moduleClassFile; if (class_exists($class)) { $this->moduleClassMap[$class] = $moduleClassFile; return $class; } } $pharBaseName = $this->pharFileToModuleName($fileRealPath); $moduleClassFile = 'phar://' . $fileRealPath . '/' . $pharBaseName . '/Module.php'; $moduleFile = new SplFileInfo($moduleClassFile); if ($moduleFile->isReadable() && $moduleFile->isFile()) { require_once $moduleClassFile; if (class_exists($class)) { $this->moduleClassMap[$class] = $moduleClassFile; return $class; } } return false; } public function register() { spl_autoload_register(array($this, 'autoload')); } public function unregister() { spl_autoload_unregister(array($this, 'autoload')); } public function registerPaths($paths) { if (!is_array($paths) && !$paths instanceof Traversable) { require_once __DIR__ . '/Exception/InvalidArgumentException.php'; throw new Exception\InvalidArgumentException( 'Parameter to \\Zend\\Loader\\ModuleAutoloader\'s ' . 'registerPaths method must be an array or ' . 'implement the Traversable interface' ); } foreach ($paths as $module => $path) { if (is_string($module)) { $this->registerPath($path, $module); } else { $this->registerPath($path); } } return $this; } public function registerPath($path, $moduleName = false) { if (!is_string($path)) { require_once __DIR__ . '/Exception/InvalidArgumentException.php'; throw new Exception\InvalidArgumentException(sprintf( 'Invalid path provided; must be a string, received %s', gettype($path) )); } if ($moduleName) { if (in_array( substr($moduleName, -2), array('\\*', '\\%'))) { $this->namespacedPaths[substr($moduleName, 0, -2)] = static::normalizePath($path); } else { $this->explicitPaths[$moduleName] = static::normalizePath($path); } } else { $this->paths[] = static::normalizePath($path); } return $this; } public function getPaths() { return $this->paths; } protected function pharFileToModuleName($pharPath) { do { $pathinfo = pathinfo($pharPath); $pharPath = $pathinfo['filename']; } while (isset($pathinfo['extension'])); return $pathinfo['filename']; } public static function normalizePath($path, $trailingSlash = true) { $path = rtrim($path, '/'); $path = rtrim($path, '\\'); if ($trailingSlash) { $path .= DIRECTORY_SEPARATOR; } return $path; } } registerPlugins(static::$staticMap); } if ($map !== null) { $this->registerPlugins($map); } } public static function addStaticMap($map) { if (null === $map) { static::$staticMap = array(); return; } if (!is_array($map) && !$map instanceof Traversable) { throw new Exception\InvalidArgumentException('Expects an array or Traversable object'); } foreach ($map as $key => $value) { static::$staticMap[$key] = $value; } } public function registerPlugin($shortName, $className) { $this->plugins[strtolower($shortName)] = $className; return $this; } public function registerPlugins($map) { if (is_string($map)) { if (!class_exists($map)) { throw new Exception\InvalidArgumentException('Map class provided is invalid'); } $map = new $map; } if (is_array($map)) { $map = new ArrayIterator($map); } if (!$map instanceof Traversable) { throw new Exception\InvalidArgumentException('Map provided is invalid; must be traversable'); } if ($map instanceof IteratorAggregate) { $map = $map->getIterator(); } foreach ($map as $name => $class) { if (is_int($name) || is_numeric($name)) { if (!is_object($class) && class_exists($class)) { $class = new $class(); } if ($class instanceof Traversable) { $this->registerPlugins($class); continue; } } $this->registerPlugin($name, $class); } return $this; } public function unregisterPlugin($shortName) { $lookup = strtolower($shortName); if (array_key_exists($lookup, $this->plugins)) { unset($this->plugins[$lookup]); } return $this; } public function getRegisteredPlugins() { return $this->plugins; } public function isLoaded($name) { $lookup = strtolower($name); return isset($this->plugins[$lookup]); } public function getClassName($name) { return $this->load($name); } public function load($name) { if (!$this->isLoaded($name)) { return false; } return $this->plugins[strtolower($name)]; } public function getIterator() { return new ArrayIterator($this->plugins); } } register(); static::$loaders[static::STANDARD_AUTOLOADER] = $autoloader; } return; } if (!is_array($options) && !($options instanceof Traversable)) { require_once __DIR__ . '/Exception/InvalidArgumentException.php'; throw new Exception\InvalidArgumentException( 'Options provided must be an array or Traversable' ); } foreach ($options as $class => $autoloaderOptions) { if (!isset(static::$loaders[$class])) { $autoloader = static::getStandardAutoloader(); if (!class_exists($class) && !$autoloader->autoload($class)) { require_once 'Exception/InvalidArgumentException.php'; throw new Exception\InvalidArgumentException( sprintf('Autoloader class "%s" not loaded', $class) ); } if (!static::isSubclassOf($class, 'Zend\Loader\SplAutoloader')) { require_once 'Exception/InvalidArgumentException.php'; throw new Exception\InvalidArgumentException( sprintf('Autoloader class %s must implement Zend\\Loader\\SplAutoloader', $class) ); } if ($class === static::STANDARD_AUTOLOADER) { $autoloader->setOptions($autoloaderOptions); } else { $autoloader = new $class($autoloaderOptions); } $autoloader->register(); static::$loaders[$class] = $autoloader; } else { static::$loaders[$class]->setOptions($autoloaderOptions); } } } public static function getRegisteredAutoloaders() { return static::$loaders; } public static function getRegisteredAutoloader($class) { if (!isset(static::$loaders[$class])) { require_once 'Exception/InvalidArgumentException.php'; throw new Exception\InvalidArgumentException(sprintf('Autoloader class "%s" not loaded', $class)); } return static::$loaders[$class]; } public static function unregisterAutoloaders() { foreach (static::getRegisteredAutoloaders() as $class => $autoloader) { spl_autoload_unregister(array($autoloader, 'autoload')); unset(static::$loaders[$class]); } } public static function unregisterAutoloader($autoloaderClass) { if (!isset(static::$loaders[$autoloaderClass])) { return false; } $autoloader = static::$loaders[$autoloaderClass]; spl_autoload_unregister(array($autoloader, 'autoload')); unset(static::$loaders[$autoloaderClass]); return true; } protected static function getStandardAutoloader() { if (null !== static::$standardAutoloader) { return static::$standardAutoloader; } if (!class_exists(static::STANDARD_AUTOLOADER)) { $stdAutoloader = substr(strrchr(static::STANDARD_AUTOLOADER, '\\'), 1); require_once __DIR__ . "/$stdAutoloader.php"; } $loader = new StandardAutoloader(); static::$standardAutoloader = $loader; return static::$standardAutoloader; } protected static function isSubclassOf($className, $type) { if (is_subclass_of($className, $type)) { return true; } if (version_compare(PHP_VERSION, '5.3.7', '>=')) { return false; } if (!interface_exists($type)) { return false; } $r = new ReflectionClass($className); return $r->implementsInterface($type); } } view->paginator) and $this->view->paginator !== null and $this->view->paginator instanceof Paginator\Paginator) { $paginator = $this->view->paginator; } else { throw new Exception\RuntimeException('No paginator instance provided or incorrect type'); } } if ($partial === null) { if (static::$defaultViewPartial === null) { throw new Exception\RuntimeException('No view partial provided and no default set'); } $partial = static::$defaultViewPartial; } if ($scrollingStyle === null) { $scrollingStyle = static::$defaultScrollingStyle; } $pages = get_object_vars($paginator->getPages($scrollingStyle)); if ($params !== null) { $pages = array_merge($pages, (array) $params); } if (is_array($partial)) { if (count($partial) != 2) { throw new Exception\InvalidArgumentException( 'A view partial supplied as an array must contain two values: the filename and its module' ); } if ($partial[1] !== null) { $partialHelper = $this->view->plugin('partial'); return $partialHelper($partial[0], $pages); } $partial = $partial[0]; } $partialHelper = $this->view->plugin('partial'); return $partialHelper($partial, $pages); } public static function setDefaultScrollingStyle($style) { static::$defaultScrollingStyle = $style; } public static function getDefaultScrollingStyle() { return static::$defaultScrollingStyle; } public static function setDefaultViewPartial($partial) { static::$defaultViewPartial = $partial; } public static function getDefaultViewPartial() { return static::$defaultViewPartial; } } basePath) { throw new Exception\RuntimeException('No base path provided'); } if (null !== $file) { $file = '/' . ltrim($file, '/'); } return $this->basePath . $file; } public function setBasePath($basePath) { $this->basePath = rtrim($basePath, '/'); return $this; } } getView()->render($name); } if (is_scalar($values)) { $values = array(); } elseif ($values instanceof ModelInterface) { $values = $values->getVariables(); } elseif (is_object($values)) { if (null !== ($objectKey = $this->getObjectKey())) { $values = array($objectKey => $values); } elseif (method_exists($values, 'toArray')) { $values = $values->toArray(); } else { $values = get_object_vars($values); } } return $this->getView()->render($name, $values); } public function setObjectKey($key) { if (null === $key) { $this->objectKey = null; return $this; } $this->objectKey = (string) $key; return $this; } public function getObjectKey() { return $this->objectKey; } } getDefaultAttachOrder()) ? Placeholder\Container\AbstractContainer::APPEND : $this->getDefaultAttachOrder(); } $title = (string) $title; if ($title !== '') { if ($setType == Placeholder\Container\AbstractContainer::SET) { $this->set($title); } elseif ($setType == Placeholder\Container\AbstractContainer::PREPEND) { $this->prepend($title); } else { $this->append($title); } } return $this; } public function toString($indent = null) { $indent = (null !== $indent) ? $this->getWhitespace($indent) : $this->getIndent(); $output = $this->renderTitle(); return $indent . '' . $output . ''; } public function renderTitle() { $items = array(); if (null !== ($translator = $this->getTranslator())) { foreach ($this as $item) { $items[] = $translator->translate( $item, $this->getTranslatorTextDomain() ); } } else { foreach ($this as $item) { $items[] = $item; } } $separator = $this->getSeparator(); $output = ''; $prefix = $this->getPrefix(); if ($prefix) { $output .= $prefix; } $output .= implode($separator, $items); $postfix = $this->getPostfix(); if ($postfix) { $output .= $postfix; } $output = ($this->autoEscape) ? $this->escape($output) : $output; return $output; } public function setDefaultAttachOrder($setType) { if (!in_array($setType, array( Placeholder\Container\AbstractContainer::APPEND, Placeholder\Container\AbstractContainer::SET, Placeholder\Container\AbstractContainer::PREPEND ))) { throw new Exception\DomainException( "You must use a valid attach order: 'PREPEND', 'APPEND' or 'SET'" ); } $this->defaultAttachOrder = $setType; return $this; } public function getDefaultAttachOrder() { return $this->defaultAttachOrder; } public function setTranslator(Translator $translator = null, $textDomain = null) { $this->translator = $translator; if (null !== $textDomain) { $this->setTranslatorTextDomain($textDomain); } return $this; } public function getTranslator() { if (! $this->isTranslatorEnabled()) { return null; } return $this->translator; } public function hasTranslator() { return (bool) $this->getTranslator(); } public function setTranslatorEnabled($enabled = true) { $this->translatorEnabled = (bool) $enabled; return $this; } public function isTranslatorEnabled() { return $this->translatorEnabled; } public function setTranslatorTextDomain($textDomain = 'default') { $this->translatorTextDomain = $textDomain; return $this; } public function getTranslatorTextDomain() { return $this->translatorTextDomain; } } getRoot(); } return $this->setTemplate($template); } public function getLayout() { return $this->getRoot()->getTemplate(); } protected function getRoot() { $helper = $this->getViewModelHelper(); if (!$helper->hasRoot()) { throw new Exception\RuntimeException(sprintf( '%s: no view model currently registered as root in renderer', __METHOD__ )); } return $helper->getRoot(); } public function setTemplate($template) { $this->getRoot()->setTemplate((string) $template); return $this; } protected function getViewModelHelper() { if (null === $this->viewModelHelper) { $this->viewModelHelper = $this->getView()->plugin('view_model'); } return $this->viewModelHelper; } } setSeparator(PHP_EOL); } public function __invoke($mode = self::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript') { if ((null !== $spec) && is_string($spec)) { $action = ucfirst(strtolower($mode)); $placement = strtolower($placement); switch ($placement) { case 'set': case 'prepend': case 'append': $action = $placement . $action; break; default: $action = 'append' . $action; break; } $this->$action($spec, $type, $attrs); } return $this; } public function __call($method, $args) { if (preg_match('/^(?Pset|(ap|pre)pend|offsetSet)(?PFile|Script)$/', $method, $matches)) { if (1 > count($args)) { throw new Exception\BadMethodCallException(sprintf( 'Method "%s" requires at least one argument', $method )); } $action = $matches['action']; $mode = strtolower($matches['mode']); $type = 'text/javascript'; $attrs = array(); if ('offsetSet' == $action) { $index = array_shift($args); if (1 > count($args)) { throw new Exception\BadMethodCallException(sprintf( 'Method "%s" requires at least two arguments, an index and source', $method )); } } $content = $args[0]; if (isset($args[1])) { $type = (string) $args[1]; } if (isset($args[2])) { $attrs = (array) $args[2]; } switch ($mode) { case 'script': $item = $this->createData($type, $attrs, $content); if ('offsetSet' == $action) { $this->offsetSet($index, $item); } else { $this->$action($item); } break; case 'file': default: if (!$this->isDuplicate($content)) { $attrs['src'] = $content; $item = $this->createData($type, $attrs); if ('offsetSet' == $action) { $this->offsetSet($index, $item); } else { $this->$action($item); } } break; } return $this; } return parent::__call($method, $args); } public function toString($indent = null) { $indent = (null !== $indent) ? $this->getWhitespace($indent) : $this->getIndent(); if ($this->view) { $useCdata = $this->view->plugin('doctype')->isXhtml() ? true : false; } else { $useCdata = $this->useCdata ? true : false; } $escapeStart = ($useCdata) ? '//' : '//-->'; $items = array(); $this->getContainer()->ksort(); foreach ($this as $item) { if (!$this->isValid($item)) { continue; } $items[] = $this->itemToString($item, $indent, $escapeStart, $escapeEnd); } return implode($this->getSeparator(), $items); } public function captureStart($captureType = Placeholder\Container\AbstractContainer::APPEND, $type = 'text/javascript', $attrs = array()) { if ($this->captureLock) { throw new Exception\RuntimeException('Cannot nest headScript captures'); } $this->captureLock = true; $this->captureType = $captureType; $this->captureScriptType = $type; $this->captureScriptAttrs = $attrs; ob_start(); } public function captureEnd() { $content = ob_get_clean(); $type = $this->captureScriptType; $attrs = $this->captureScriptAttrs; $this->captureScriptType = null; $this->captureScriptAttrs = null; $this->captureLock = false; switch ($this->captureType) { case Placeholder\Container\AbstractContainer::SET: case Placeholder\Container\AbstractContainer::PREPEND: case Placeholder\Container\AbstractContainer::APPEND: $action = strtolower($this->captureType) . 'Script'; break; default: $action = 'appendScript'; break; } $this->$action($content, $type, $attrs); } public function createData($type, array $attributes, $content = null) { $data = new stdClass(); $data->type = $type; $data->attributes = $attributes; $data->source = $content; return $data; } protected function isDuplicate($file) { foreach ($this->getContainer() as $item) { if (($item->source === null) && array_key_exists('src', $item->attributes) && ($file == $item->attributes['src'])) { return true; } } return false; } protected function isValid($value) { if ((!$value instanceof stdClass) || !isset($value->type) || (!isset($value->source) && !isset($value->attributes))) { return false; } return true; } public function itemToString($item, $indent, $escapeStart, $escapeEnd) { $attrString = ''; if (!empty($item->attributes)) { foreach ($item->attributes as $key => $value) { if ((!$this->arbitraryAttributesAllowed() && !in_array($key, $this->optionalAttributes)) || in_array($key, array('conditional', 'noescape'))) { continue; } if ('defer' == $key) { $value = 'defer'; } $attrString .= sprintf(' %s="%s"', $key, ($this->autoEscape) ? $this->escape($value) : $value); } } $addScriptEscape = !(isset($item->attributes['noescape']) && filter_var($item->attributes['noescape'], FILTER_VALIDATE_BOOLEAN)); $type = ($this->autoEscape) ? $this->escape($item->type) : $item->type; $html = ''; if (isset($item->attributes['conditional']) && !empty($item->attributes['conditional']) && is_string($item->attributes['conditional'])) { $html = $indent . ''; } else { $html = $indent . $html; } return $html; } public function append($value) { if (!$this->isValid($value)) { throw new Exception\InvalidArgumentException( 'Invalid argument passed to append(); please use one of the helper methods, appendScript() or appendFile()' ); } return $this->getContainer()->append($value); } public function prepend($value) { if (!$this->isValid($value)) { throw new Exception\InvalidArgumentException( 'Invalid argument passed to prepend(); please use one of the helper methods, prependScript() or prependFile()' ); } return $this->getContainer()->prepend($value); } public function set($value) { if (!$this->isValid($value)) { throw new Exception\InvalidArgumentException( 'Invalid argument passed to set(); please use one of the helper methods, setScript() or setFile()' ); } return $this->getContainer()->set($value); } public function offsetSet($index, $value) { if (!$this->isValid($value)) { throw new Exception\InvalidArgumentException( 'Invalid argument passed to offsetSet(); please use one of the helper methods, offsetSetScript() or offsetSetFile()' ); } return $this->getContainer()->offsetSet($index, $value); } public function setAllowArbitraryAttributes($flag) { $this->arbitraryAttributes = (bool) $flag; return $this; } public function arbitraryAttributesAllowed() { return $this->arbitraryAttributes; } } getEscaper()->escapeHtml($value); } } current = $model; return $this; } public function getCurrent() { return $this->current; } public function hasCurrent() { return ($this->current instanceof Model); } public function setRoot(Model $model) { $this->root = $model; return $this; } public function getRoot() { return $this->root; } public function hasRoot() { return ($this->root instanceof Model); } } getServiceLocator(); $helper = new FlashMessenger(); $controllerPluginManager = $serviceLocator->get('ControllerPluginManager'); $flashMessenger = $controllerPluginManager->get('flashmessenger'); $helper->setPluginFlashMessenger($flashMessenger); $config = $serviceLocator->get('Config'); if (isset($config['view_helper_config']['flashmessenger'])) { $configHelper = $config['view_helper_config']['flashmessenger']; if (isset($configHelper['message_open_format'])) { $helper->setMessageOpenFormat($configHelper['message_open_format']); } if (isset($configHelper['message_separator_string'])) { $helper->setMessageSeparatorString($configHelper['message_separator_string']); } if (isset($configHelper['message_close_string'])) { $helper->setMessageCloseString($configHelper['message_close_string']); } } return $helper; } } getServiceLocator(); $helper = new Identity(); if ($services->has('Zend\Authentication\AuthenticationService')) { $helper->setAuthenticationService($services->get('Zend\Authentication\AuthenticationService')); } return $helper; } } getView()->plugin('escapeHtml'); $item = $escaper($item); } $list .= '
  • ' . $item . '
  • ' . self::EOL; } else { $itemLength = 5 + strlen(self::EOL); if ($itemLength < strlen($list)) { $list = substr($list, 0, strlen($list) - $itemLength) . $this($item, $ordered, $attribs, $escape) . '' . self::EOL; } else { $list .= '
  • ' . $this($item, $ordered, $attribs, $escape) . '
  • ' . self::EOL; } } } if ($attribs) { $attribs = $this->htmlAttribs($attribs); } else { $attribs = ''; } $tag = ($ordered) ? 'ol' : 'ul'; return '<' . $tag . $attribs . '>' . self::EOL . $list . '' . self::EOL; } } setDoctype($this->defaultDoctype); } $this->registry = static::$registeredDoctypes; } public function __invoke($doctype = null) { if (null !== $doctype) { switch ($doctype) { case self::XHTML11: case self::XHTML1_STRICT: case self::XHTML1_TRANSITIONAL: case self::XHTML1_FRAMESET: case self::XHTML_BASIC1: case self::XHTML1_RDFA: case self::XHTML1_RDFA11: case self::XHTML5: case self::HTML4_STRICT: case self::HTML4_LOOSE: case self::HTML4_FRAMESET: case self::HTML5: $this->setDoctype($doctype); break; default: if (substr($doctype, 0, 9) != 'setDoctype($type); $this->registry['doctypes'][$type] = $doctype; break; } } return $this; } public function __toString() { $doctypes = $this->getDoctypes(); return $doctypes[$this->getDoctype()]; } protected static function registerDefaultDoctypes() { static::$registeredDoctypes = new ArrayObject(array( 'doctypes' => array( self::XHTML11 => '', self::XHTML1_STRICT => '', self::XHTML1_TRANSITIONAL => '', self::XHTML1_FRAMESET => '', self::XHTML1_RDFA => '', self::XHTML1_RDFA11 => '', self::XHTML_BASIC1 => '', self::XHTML5 => '', self::HTML4_STRICT => '', self::HTML4_LOOSE => '', self::HTML4_FRAMESET => '', self::HTML5 => '', ), )); } public static function unsetDoctypeRegistry() { static::$registeredDoctypes = null; } public function setDoctype($doctype) { $this->registry['doctype'] = $doctype; return $this; } public function getDoctype() { if (!isset($this->registry['doctype'])) { $this->setDoctype($this->defaultDoctype); } return $this->registry['doctype']; } public function getDoctypes() { return $this->registry['doctypes']; } public function isXhtml() { return (stristr($this->getDoctype(), 'xhtml') ? true : false); } public function isHtml5() { return (stristr($this->__invoke(), '') ? true : false); } public function isRdfa() { return ($this->isHtml5() || stristr($this->getDoctype(), 'rdfa') ? true : false); } } getEscaper()->escapeUrl($value); } } router) { throw new Exception\RuntimeException('No RouteStackInterface instance provided'); } if (3 == func_num_args() && is_bool($options)) { $reuseMatchedParams = $options; $options = array(); } if ($name === null) { if ($this->routeMatch === null) { throw new Exception\RuntimeException('No RouteMatch instance provided'); } $name = $this->routeMatch->getMatchedRouteName(); if ($name === null) { throw new Exception\RuntimeException('RouteMatch does not contain a matched route name'); } } if (!is_array($params)) { if (!$params instanceof Traversable) { throw new Exception\InvalidArgumentException( 'Params is expected to be an array or a Traversable object' ); } $params = iterator_to_array($params); } if ($reuseMatchedParams && $this->routeMatch !== null) { $routeMatchParams = $this->routeMatch->getParams(); if (isset($routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER])) { $routeMatchParams['controller'] = $routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER]; unset($routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER]); } if (isset($routeMatchParams[ModuleRouteListener::MODULE_NAMESPACE])) { unset($routeMatchParams[ModuleRouteListener::MODULE_NAMESPACE]); } $params = array_merge($routeMatchParams, $params); } $options['name'] = $name; return $this->router->assemble($params, $options); } public function setRouter(RouteStackInterface $router) { $this->router = $router; return $this; } public function setRouteMatch(RouteMatch $routeMatch) { $this->routeMatch = $routeMatch; return $this; } } getEscaper()->escapeCss($value); } } getScheme() . '://' . $this->getHost() . $path; } protected function detectHost() { if ($this->setHostFromProxy()) { return; } if (isset($_SERVER['HTTP_HOST']) && !empty($_SERVER['HTTP_HOST'])) { if (isset($_SERVER['SERVER_PORT'])) { $portStr = ':' . $_SERVER['SERVER_PORT']; if (substr($_SERVER['HTTP_HOST'], 0-strlen($portStr), strlen($portStr)) == $portStr) { $this->setHost(substr($_SERVER['HTTP_HOST'], 0, 0-strlen($portStr))); return; } } $this->setHost($_SERVER['HTTP_HOST']); return; } if (!isset($_SERVER['SERVER_NAME']) || !isset($_SERVER['SERVER_PORT'])) { return; } $name = $_SERVER['SERVER_NAME']; $this->setHost($name); } protected function detectPort() { if ($this->setPortFromProxy()) { return; } if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT']) { $this->setPort($_SERVER['SERVER_PORT']); return; } } protected function detectScheme() { if ($this->setSchemeFromProxy()) { return; } switch (true) { case (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] === true)): case (isset($_SERVER['HTTP_SCHEME']) && ($_SERVER['HTTP_SCHEME'] == 'https')): case (443 === $this->getPort()): $scheme = 'https'; break; default: $scheme = 'http'; break; } $this->setScheme($scheme); } protected function setHostFromProxy() { if (!$this->useProxy) { return false; } if (!isset($_SERVER['HTTP_X_FORWARDED_HOST']) || empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { return false; } $host = $_SERVER['HTTP_X_FORWARDED_HOST']; if (strpos($host, ',') !== false) { $hosts = explode(',', $host); $host = trim(array_pop($hosts)); } if (empty($host)) { return false; } $this->setHost($host); return true; } protected function setPortFromProxy() { if (!$this->useProxy) { return false; } if (!isset($_SERVER['HTTP_X_FORWARDED_PORT']) || empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { return false; } $port = $_SERVER['HTTP_X_FORWARDED_PORT']; $this->setPort($port); return true; } protected function setSchemeFromProxy() { if (!$this->useProxy) { return false; } if (isset($_SERVER['SSL_HTTPS'])) { $sslHttps = strtolower($_SERVER['SSL_HTTPS']); if (in_array($sslHttps, array('on', 1))) { $this->setScheme('https'); return true; } } if (!isset($_SERVER['HTTP_X_FORWARDED_PROTO']) || empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) { return false; } $scheme = trim(strtolower($_SERVER['HTTP_X_FORWARDED_PROTO'])); if (empty($scheme)) { return false; } $this->setScheme($scheme); return true; } public function setHost($host) { $port = $this->getPort(); $scheme = $this->getScheme(); if (($scheme == 'http' && (null === $port || $port == 80)) || ($scheme == 'https' && (null === $port || $port == 443)) ) { $this->host = $host; return $this; } $this->host = $host . ':' . $port; return $this; } public function getHost() { if (null === $this->host) { $this->detectHost(); } return $this->host; } public function setPort($port) { $this->port = (int) $port; return $this; } public function getPort() { if (null === $this->port) { $this->detectPort(); } return $this->port; } public function setScheme($scheme) { $this->scheme = $scheme; return $this; } public function getScheme() { if (null === $this->scheme) { $this->detectScheme(); } return $this->scheme; } public function setUseProxy($useProxy = false) { $this->useProxy = (bool) $useProxy; return $this; } } toArray(); } else { throw new Exception\InvalidArgumentException('PartialLoop helper requires iterable data'); } } $this->partialCounter = 0; $content = ''; foreach ($values as $item) { $this->partialCounter++; $content .= parent::__invoke($name, $item); } return $content; } public function getPartialCounter() { return $this->partialCounter; } } closingBracket) { if ($this->isXhtml()) { $this->closingBracket = ' />'; } else { $this->closingBracket = '>'; } } return $this->closingBracket; } protected function isXhtml() { return $this->getView()->plugin('doctype')->isXhtml(); } protected function htmlAttribs($attribs) { $xhtml = ''; $escaper = $this->getView()->plugin('escapehtml'); foreach ((array) $attribs as $key => $val) { $key = $escaper($key); if (('on' == substr($key, 0, 2)) || ('constraints' == $key)) { if (!is_scalar($val)) { $val = \Zend\Json\Json::encode($val); } $val = str_replace('\'', ''', $val); } else { if (is_array($val)) { $val = implode(' ', $val); } $val = $escaper($val); } if ('id' == $key) { $val = $this->normalizeId($val); } if (strpos($val, '"') !== false) { $xhtml .= " $key='$val'"; } else { $xhtml .= " $key=\"$val\""; } } return $xhtml; } protected function normalizeId($value) { if (strstr($value, '[')) { if ('[]' == substr($value, -2)) { $value = substr($value, 0, strlen($value) - 2); } $value = trim($value, ']'); $value = str_replace('][', '-', $value); $value = str_replace('[', '-', $value); } return $value; } } response instanceof Response) { $headers = $this->response->getHeaders(); $headers->addHeaderLine('Content-Type', 'application/json'); } return $data; } public function setResponse(Response $response) { $this->response = $response; return $this; } } view->plugin('placeholder'); $placeholderHelper($placeholder)->captureStart(); echo $this->view->render($script); $placeholderHelper($placeholder)->captureEnd(); } } setSeparator(PHP_EOL); } public function __invoke($content = null, $keyValue = null, $keyType = 'name', $modifiers = array(), $placement = Placeholder\Container\AbstractContainer::APPEND) { if ((null !== $content) && (null !== $keyValue)) { $item = $this->createData($keyType, $keyValue, $content, $modifiers); $action = strtolower($placement); switch ($action) { case 'append': case 'prepend': case 'set': $this->$action($item); break; default: $this->append($item); break; } } return $this; } public function __call($method, $args) { if (preg_match( '/^(?Pset|(pre|ap)pend|offsetSet)(?PName|HttpEquiv|Property|Itemprop)$/', $method, $matches) ) { $action = $matches['action']; $type = $this->normalizeType($matches['type']); $argc = count($args); $index = null; if ('offsetSet' == $action) { if (0 < $argc) { $index = array_shift($args); --$argc; } } if (2 > $argc) { throw new Exception\BadMethodCallException( 'Too few arguments provided; requires key value, and content' ); } if (3 > $argc) { $args[] = array(); } $item = $this->createData($type, $args[0], $args[1], $args[2]); if ('offsetSet' == $action) { return $this->offsetSet($index, $item); } $this->$action($item); return $this; } return parent::__call($method, $args); } public function toString($indent = null) { $indent = (null !== $indent) ? $this->getWhitespace($indent) : $this->getIndent(); $items = array(); $this->getContainer()->ksort(); try { foreach ($this as $item) { $items[] = $this->itemToString($item); } } catch (Exception\InvalidArgumentException $e) { trigger_error($e->getMessage(), E_USER_WARNING); return ''; } return $indent . implode($this->escape($this->getSeparator()) . $indent, $items); } public function createData($type, $typeValue, $content, array $modifiers) { $data = new stdClass; $data->type = $type; $data->$type = $typeValue; $data->content = $content; $data->modifiers = $modifiers; return $data; } public function itemToString(stdClass $item) { if (!in_array($item->type, $this->typeKeys)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid type "%s" provided for meta', $item->type )); } $type = $item->type; $modifiersString = ''; foreach ($item->modifiers as $key => $value) { if ($this->view->plugin('doctype')->isHtml5() && $key == 'scheme' ) { throw new Exception\InvalidArgumentException( 'Invalid modifier "scheme" provided; not supported by HTML5' ); } if (!in_array($key, $this->modifierKeys)) { continue; } $modifiersString .= $key . '="' . $this->escape($value) . '" '; } $modifiersString = rtrim($modifiersString); if ('' != $modifiersString) { $modifiersString = ' ' . $modifiersString; } if (method_exists($this->view, 'plugin')) { if ($this->view->plugin('doctype')->isHtml5() && $type == 'charset' ) { $tpl = ($this->view->plugin('doctype')->isXhtml()) ? '' : ''; } elseif ($this->view->plugin('doctype')->isXhtml()) { $tpl = ''; } else { $tpl = ''; } } else { $tpl = ''; } $meta = sprintf( $tpl, $type, $this->escape($item->$type), $this->escape($item->content), $modifiersString ); if (isset($item->modifiers['conditional']) && !empty($item->modifiers['conditional']) && is_string($item->modifiers['conditional'])) { $meta = ''; } return $meta; } protected function normalizeType($type) { switch ($type) { case 'Name': return 'name'; case 'HttpEquiv': return 'http-equiv'; case 'Property': return 'property'; case 'Itemprop': return 'itemprop'; default: throw new Exception\DomainException(sprintf( 'Invalid type "%s" passed to normalizeType', $type )); } } protected function isValid($item) { if ((!$item instanceof stdClass) || !isset($item->type) || !isset($item->modifiers) ) { return false; } if (!isset($item->content) && (! $this->view->plugin('doctype')->isHtml5() || (! $this->view->plugin('doctype')->isHtml5() && $item->type !== 'charset')) ) { return false; } if (! $this->view->plugin('doctype')->isHtml5() && $item->type === 'itemprop' ) { return false; } if (!$this->view->plugin('doctype')->isRdfa() && $item->type === 'property' ) { return false; } return true; } public function append($value) { if (!$this->isValid($value)) { throw new Exception\InvalidArgumentException( 'Invalid value passed to append; please use appendMeta()' ); } return $this->getContainer()->append($value); } public function offsetSet($index, $value) { if (!$this->isValid($value)) { throw new Exception\InvalidArgumentException( 'Invalid value passed to offsetSet; please use offsetSetName() or offsetSetHttpEquiv()' ); } return $this->getContainer()->offsetSet($index, $value); } public function offsetUnset($index) { if (!in_array($index, $this->getContainer()->getKeys())) { throw new Exception\InvalidArgumentException('Invalid index passed to offsetUnset()'); } return $this->getContainer()->offsetUnset($index); } public function prepend($value) { if (!$this->isValid($value)) { throw new Exception\InvalidArgumentException( 'Invalid value passed to prepend; please use prependMeta()' ); } return $this->getContainer()->prepend($value); } public function set($value) { if (!$this->isValid($value)) { throw new Exception\InvalidArgumentException('Invalid value passed to set; please use setMeta()'); } $container = $this->getContainer(); foreach ($container->getArrayCopy() as $index => $item) { if ($item->type == $value->type && $item->{$item->type} == $value->{$value->type}) { $this->offsetUnset($index); } } return $this->append($value); } public function setCharset($charset) { $item = new stdClass; $item->type = 'charset'; $item->charset = $charset; $item->content = null; $item->modifiers = array(); $this->set($item); return $this; } } authenticationService instanceof AuthenticationService) { throw new Exception\RuntimeException('No AuthenticationService instance provided'); } if (!$this->authenticationService->hasIdentity()) { return null; } return $this->authenticationService->getIdentity(); } public function setAuthenticationService(AuthenticationService $authenticationService) { $this->authenticationService = $authenticationService; return $this; } public function getAuthenticationService() { return $this->authenticationService; } } self::ATTRIB_CLASSID); public function __invoke($data, array $attribs = array(), array $params = array(), $content = null) { $attribs = array_merge($this->attribs, $attribs); $params = array_merge(array('data' => $data), $params); $htmlObject = $this->getView()->plugin('htmlObject'); return $htmlObject($data, self::TYPE, $attribs, $params, $content); } } 'info', PluginFlashMessenger::NAMESPACE_ERROR => 'error', PluginFlashMessenger::NAMESPACE_SUCCESS => 'success', PluginFlashMessenger::NAMESPACE_DEFAULT => 'default', ); protected $messageCloseString = ''; protected $messageOpenFormat = '
  • '; protected $messageSeparatorString = '
  • '; protected $escapeHtmlHelper; protected $pluginFlashMessenger; protected $serviceLocator; public function __invoke($namespace = null) { if (null === $namespace) { return $this; } $flashMessenger = $this->getPluginFlashMessenger(); return $flashMessenger->getMessagesFromNamespace($namespace); } public function __call($method, $argv) { $flashMessenger = $this->getPluginFlashMessenger(); return call_user_func_array(array($flashMessenger, $method), $argv); } public function render($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $classes = array()) { $flashMessenger = $this->getPluginFlashMessenger(); $messages = $flashMessenger->getMessagesFromNamespace($namespace); if (empty($classes)) { $classes = isset($this->classMessages[$namespace]) ? $this->classMessages[$namespace] : $this->classMessages[PluginFlashMessenger::NAMESPACE_DEFAULT]; $classes = array($classes); } $escapeHtml = $this->getEscapeHtmlHelper(); $messagesToPrint = array(); $translator = $this->getTranslator(); $translatorTextDomain = $this->getTranslatorTextDomain(); array_walk_recursive($messages, function($item) use (&$messagesToPrint, $escapeHtml, $translator, $translatorTextDomain) { if ($translator !== null) { $item = $translator->translate( $item, $translatorTextDomain ); } $messagesToPrint[] = $escapeHtml($item); }); if (empty($messagesToPrint)) { return ''; } $markup = sprintf($this->getMessageOpenFormat(), ' class="' . implode(' ', $classes) . '"'); $markup .= implode(sprintf($this->getMessageSeparatorString(), ' class="' . implode(' ', $classes) . '"'), $messagesToPrint); $markup .= $this->getMessageCloseString(); return $markup; } public function setMessageCloseString($messageCloseString) { $this->messageCloseString = (string) $messageCloseString; return $this; } public function getMessageCloseString() { return $this->messageCloseString; } public function setMessageOpenFormat($messageOpenFormat) { $this->messageOpenFormat = (string) $messageOpenFormat; return $this; } public function getMessageOpenFormat() { return $this->messageOpenFormat; } public function setMessageSeparatorString($messageSeparatorString) { $this->messageSeparatorString = (string) $messageSeparatorString; return $this; } public function getMessageSeparatorString() { return $this->messageSeparatorString; } public function setPluginFlashMessenger(PluginFlashMessenger $pluginFlashMessenger) { $this->pluginFlashMessenger = $pluginFlashMessenger; return $this; } public function getPluginFlashMessenger() { if (null === $this->pluginFlashMessenger) { $this->setPluginFlashMessenger(new PluginFlashMessenger()); } return $this->pluginFlashMessenger; } public function setServiceLocator(ServiceLocatorInterface $serviceLocator) { $this->serviceLocator = $serviceLocator; return $this; } public function getServiceLocator() { return $this->serviceLocator; } protected function getEscapeHtmlHelper() { if ($this->escapeHtmlHelper) { return $this->escapeHtmlHelper; } if (method_exists($this->getView(), 'plugin')) { $this->escapeHtmlHelper = $this->view->plugin('escapehtml'); } if (!$this->escapeHtmlHelper instanceof EscapeHtml) { $this->escapeHtmlHelper = new EscapeHtml(); } return $this->escapeHtmlHelper; } } $data, 'quality' => 'high'), $params); $htmlObject = $this->getView()->plugin('htmlObject'); return $htmlObject($data, self::TYPE, $attribs, $params, $content); } } array()); protected $name = self::DEFAULT_NAME; protected $pointers = array(self::DEFAULT_NAME =>-1); public function __invoke(array $data = array(), $name = self::DEFAULT_NAME) { if (!empty($data)) { $this->data[$name] = $data; } $this->setName($name); return $this; } public function __toString() { return $this->toString(); } public function toString() { return (string) $this->data[$this->name][$this->key()]; } public function assign(Array $data , $name = self::DEFAULT_NAME) { $this->setName($name); $this->data[$name] = $data; $this->rewind(); return $this; } public function setName($name = self::DEFAULT_NAME) { $this->name = $name; if (!isset($this->data[$this->name])) { $this->data[$this->name] = array(); } if (!isset($this->pointers[$this->name])) { $this->rewind(); } return $this; } public function getName() { return $this->name; } public function getAll() { return $this->data[$this->name]; } public function next() { $count = count($this->data[$this->name]); if ($this->pointers[$this->name] == ($count - 1)) { $this->pointers[$this->name] = 0; } else { $this->pointers[$this->name] = ++$this->pointers[$this->name]; } return $this; } public function prev() { $count = count($this->data[$this->name]); if ($this->pointers[$this->name] <= 0) { $this->pointers[$this->name] = $count - 1; } else { $this->pointers[$this->name] = --$this->pointers[$this->name]; } return $this; } public function key() { if ($this->pointers[$this->name] < 0) { return 0; } return $this->pointers[$this->name]; } public function rewind() { $this->pointers[$this->name] = -1; return $this; } public function valid() { return isset($this->data[$this->name][$this->key()]); } public function current() { return $this->data[$this->name][$this->key()]; } } setContainer($container); } return $this; } public function render($container = null) { $partial = $this->getPartial(); if ($partial) { return $this->renderPartial($container, $partial); } return $this->renderMenu($container); } protected function renderDeepestMenu( AbstractContainer $container, $ulClass, $indent, $minDepth, $maxDepth, $escapeLabels, $addClassToListItem ) { if (!$active = $this->findActive($container, $minDepth - 1, $maxDepth)) { return ''; } if ($active['depth'] < $minDepth) { if (!$active['page']->hasPages()) { return ''; } } elseif (!$active['page']->hasPages()) { $active['page'] = $active['page']->getParent(); } elseif (is_int($maxDepth) && $active['depth'] +1 > $maxDepth) { $active['page'] = $active['page']->getParent(); } $ulClass = $ulClass ? ' class="' . $ulClass . '"' : ''; $html = $indent . '' . self::EOL; foreach ($active['page'] as $subPage) { if (!$this->accept($subPage)) { continue; } $liClasses = array(); if ($subPage->isActive(true)) { $liClasses[] = 'active'; } if ($addClassToListItem && $subPage->getClass()) { $liClasses[] = $subPage->getClass(); } $liClass = empty($liClasses) ? '' : ' class="' . implode(' ', $liClasses) . '"'; $html .= $indent . ' ' . self::EOL; $html .= $indent . ' ' . $this->htmlify($subPage, $escapeLabels, $addClassToListItem) . self::EOL; $html .= $indent . '
  • ' . self::EOL; } $html .= $indent . ''; return $html; } public function renderMenu($container = null, array $options = array()) { $this->parseContainer($container); if (null === $container) { $container = $this->getContainer(); } $options = $this->normalizeOptions($options); if ($options['onlyActiveBranch'] && !$options['renderParents']) { $html = $this->renderDeepestMenu($container, $options['ulClass'], $options['indent'], $options['minDepth'], $options['maxDepth'], $options['escapeLabels'], $options['addClassToListItem'] ); } else { $html = $this->renderNormalMenu($container, $options['ulClass'], $options['indent'], $options['minDepth'], $options['maxDepth'], $options['onlyActiveBranch'], $options['escapeLabels'], $options['addClassToListItem'] ); } return $html; } protected function renderNormalMenu( AbstractContainer $container, $ulClass, $indent, $minDepth, $maxDepth, $onlyActive, $escapeLabels, $addClassToListItem ) { $html = ''; $found = $this->findActive($container, $minDepth, $maxDepth); if ($found) { $foundPage = $found['page']; $foundDepth = $found['depth']; } else { $foundPage = null; } $iterator = new RecursiveIteratorIterator($container, RecursiveIteratorIterator::SELF_FIRST); if (is_int($maxDepth)) { $iterator->setMaxDepth($maxDepth); } $prevDepth = -1; foreach ($iterator as $page) { $depth = $iterator->getDepth(); $isActive = $page->isActive(true); if ($depth < $minDepth || !$this->accept($page)) { continue; } elseif ($onlyActive && !$isActive) { $accept = false; if ($foundPage) { if ($foundPage->hasPage($page)) { $accept = true; } elseif ($foundPage->getParent()->hasPage($page)) { if (!$foundPage->hasPages() || is_int($maxDepth) && $foundDepth + 1 > $maxDepth) { $accept = true; } } } if (!$accept) { continue; } } $depth -= $minDepth; $myIndent = $indent . str_repeat(' ', $depth); if ($depth > $prevDepth) { if ($ulClass && $depth == 0) { $ulClass = ' class="' . $ulClass . '"'; } else { $ulClass = ''; } $html .= $myIndent . '' . self::EOL; } elseif ($prevDepth > $depth) { for ($i = $prevDepth; $i > $depth; $i--) { $ind = $indent . str_repeat(' ', $i); $html .= $ind . ' ' . self::EOL; $html .= $ind . '' . self::EOL; } $html .= $myIndent . ' ' . self::EOL; } else { $html .= $myIndent . ' ' . self::EOL; } $liClasses = array(); if ($isActive) { $liClasses[] = 'active'; } if ($addClassToListItem && $page->getClass()) { $liClasses[] = $page->getClass(); } $liClass = empty($liClasses) ? '' : ' class="' . implode(' ', $liClasses) . '"'; $html .= $myIndent . ' ' . self::EOL . $myIndent . ' ' . $this->htmlify($page, $escapeLabels, $addClassToListItem) . self::EOL; $prevDepth = $depth; } if ($html) { for ($i = $prevDepth+1; $i > 0; $i--) { $myIndent = $indent . str_repeat(' ', $i-1); $html .= $myIndent . ' ' . self::EOL . $myIndent . '' . self::EOL; } $html = rtrim($html, self::EOL); } return $html; } public function renderPartial($container = null, $partial = null) { $this->parseContainer($container); if (null === $container) { $container = $this->getContainer(); } if (null === $partial) { $partial = $this->getPartial(); } if (empty($partial)) { throw new Exception\RuntimeException( 'Unable to render menu: No partial view script provided' ); } $model = array( 'container' => $container ); if (is_array($partial)) { if (count($partial) != 2) { throw new Exception\InvalidArgumentException( 'Unable to render menu: A view partial supplied as ' . 'an array must contain two values: partial view ' . 'script and module where script can be found' ); } $partialHelper = $this->view->plugin('partial'); return $partialHelper($partial[0], $model); } $partialHelper = $this->view->plugin('partial'); return $partialHelper($partial, $model); } public function renderSubMenu( AbstractContainer $container = null, $ulClass = null, $indent = null ) { return $this->renderMenu($container, array( 'indent' => $indent, 'ulClass' => $ulClass, 'minDepth' => null, 'maxDepth' => null, 'onlyActiveBranch' => true, 'renderParents' => false, 'escapeLabels' => true, 'addClassToListItem' => false, )); } public function htmlify(AbstractPage $page, $escapeLabel = true, $addClassToListItem = false) { $label = $page->getLabel(); $title = $page->getTitle(); if (null !== ($translator = $this->getTranslator())) { $textDomain = $this->getTranslatorTextDomain(); if (is_string($label) && !empty($label)) { $label = $translator->translate($label, $textDomain); } if (is_string($title) && !empty($title)) { $title = $translator->translate($title, $textDomain); } } $attribs = array( 'id' => $page->getId(), 'title' => $title, ); if ($addClassToListItem === false) { $attribs['class'] = $page->getClass(); } $href = $page->getHref(); if ($href) { $element = 'a'; $attribs['href'] = $href; $attribs['target'] = $page->getTarget(); } else { $element = 'span'; } $html = '<' . $element . $this->htmlAttribs($attribs) . '>'; if ($escapeLabel === true) { $escaper = $this->view->plugin('escapeHtml'); $html .= $escaper($label); } else { $html .= $label; } $html .= ''; return $html; } protected function normalizeOptions(array $options = array()) { if (isset($options['indent'])) { $options['indent'] = $this->getWhitespace($options['indent']); } else { $options['indent'] = $this->getIndent(); } if (isset($options['ulClass']) && $options['ulClass'] !== null) { $options['ulClass'] = (string) $options['ulClass']; } else { $options['ulClass'] = $this->getUlClass(); } if (array_key_exists('minDepth', $options)) { if (null !== $options['minDepth']) { $options['minDepth'] = (int) $options['minDepth']; } } else { $options['minDepth'] = $this->getMinDepth(); } if ($options['minDepth'] < 0 || $options['minDepth'] === null) { $options['minDepth'] = 0; } if (array_key_exists('maxDepth', $options)) { if (null !== $options['maxDepth']) { $options['maxDepth'] = (int) $options['maxDepth']; } } else { $options['maxDepth'] = $this->getMaxDepth(); } if (!isset($options['onlyActiveBranch'])) { $options['onlyActiveBranch'] = $this->getOnlyActiveBranch(); } if (!isset($options['escapeLabels'])) { $options['escapeLabels'] = $this->escapeLabels; } if (!isset($options['renderParents'])) { $options['renderParents'] = $this->getRenderParents(); } if (!isset($options['addClassToListItem'])) { $options['addClassToListItem'] = $this->getAddClassToListItem(); } return $options; } public function escapeLabels($flag = true) { $this->escapeLabels = (bool) $flag; return $this; } public function setAddClassToListItem($flag = true) { $this->addClassToListItem = (bool) $flag; return $this; } public function getAddClassToListItem() { return $this->addClassToListItem; } public function setOnlyActiveBranch($flag = true) { $this->onlyActiveBranch = (bool) $flag; return $this; } public function getOnlyActiveBranch() { return $this->onlyActiveBranch; } public function setPartial($partial) { if (null === $partial || is_string($partial) || is_array($partial)) { $this->partial = $partial; } return $this; } public function getPartial() { return $this->partial; } public function setRenderParents($flag = true) { $this->renderParents = (bool) $flag; return $this; } public function getRenderParents() { return $this->renderParents; } public function setUlClass($ulClass) { if (is_string($ulClass)) { $this->ulClass = $ulClass; } return $this; } public function getUlClass() { return $this->ulClass; } } setContainer($container); } return $this; } public function render($container = null) { $partial = $this->getPartial(); if ($partial) { return $this->renderPartial($container, $partial); } return $this->renderStraight($container); } public function renderStraight($container = null) { $this->parseContainer($container); if (null === $container) { $container = $this->getContainer(); } if (!$active = $this->findActive($container)) { return ''; } $active = $active['page']; if ($this->getLinkLast()) { $html = $this->htmlify($active); } else { $html = $active->getLabel(); if (null !== ($translator = $this->getTranslator())) { $html = $translator->translate($html, $this->getTranslatorTextDomain()); } $escaper = $this->view->plugin('escapeHtml'); $html = $escaper($html); } while ($parent = $active->getParent()) { if ($parent instanceof AbstractPage) { $html = $this->htmlify($parent) . $this->getSeparator() . $html; } if ($parent === $container) { break; } $active = $parent; } return strlen($html) ? $this->getIndent() . $html : ''; } public function renderPartial($container = null, $partial = null) { $this->parseContainer($container); if (null === $container) { $container = $this->getContainer(); } if (null === $partial) { $partial = $this->getPartial(); } if (empty($partial)) { throw new Exception\RuntimeException( 'Unable to render menu: No partial view script provided' ); } $model = array('pages' => array()); $active = $this->findActive($container); if ($active) { $active = $active['page']; $model['pages'][] = $active; while ($parent = $active->getParent()) { if ($parent instanceof AbstractPage) { $model['pages'][] = $parent; } else { break; } if ($parent === $container) { break; } $active = $parent; } $model['pages'] = array_reverse($model['pages']); } if (is_array($partial)) { if (count($partial) != 2) { throw new Exception\InvalidArgumentException( 'Unable to render menu: A view partial supplied as ' . 'an array must contain two values: partial view ' . 'script and module where script can be found' ); } $partialHelper = $this->view->plugin('partial'); return $partialHelper($partial[0], $model); } $partialHelper = $this->view->plugin('partial'); return $partialHelper($partial, $model); } public function setLinkLast($linkLast) { $this->linkLast = (bool) $linkLast; return $this; } public function getLinkLast() { return $this->linkLast; } public function setPartial($partial) { if (null === $partial || is_string($partial) || is_array($partial)) { $this->partial = $partial; } return $this; } public function getPartial() { return $this->partial; } public function setSeparator($separator) { if (is_string($separator)) { $this->separator = $separator; } return $this; } public function getSeparator() { return $this->separator; } } 'Zend\View\Helper\Navigation\Breadcrumbs', 'links' => 'Zend\View\Helper\Navigation\Links', 'menu' => 'Zend\View\Helper\Navigation\Menu', 'sitemap' => 'Zend\View\Helper\Navigation\Sitemap', ); public function validatePlugin($plugin) { if ($plugin instanceof AbstractHelper) { return; } throw new Exception\InvalidArgumentException(sprintf( 'Plugin of type %s is invalid; must implement %s\AbstractHelper', (is_object($plugin) ? get_class($plugin) : gettype($plugin)), __NAMESPACE__ )); } } getParams(); $acl = $params['acl']; $page = $params['page']; $role = $params['role']; if (!$acl) { return $accepted; } $resource = $page->getResource(); $privilege = $page->getPrivilege(); if ($resource || $privilege) { $accepted = $acl->hasResource($resource) && $acl->isAllowed($role, $resource, $privilege); } return $accepted; } } setContainer($container); } return $this; } public function render($container = null) { $dom = $this->getDomSitemap($container); $xml = $this->getUseXmlDeclaration() ? $dom->saveXML() : $dom->saveXML($dom->documentElement); return rtrim($xml, PHP_EOL); } public function getDomSitemap(AbstractContainer $container = null) { $this->urls = array(); if (null === $container) { $container = $this->getContainer(); } if ($this->getUseSitemapValidators()) { $locValidator = new \Zend\Validator\Sitemap\Loc(); $lastmodValidator = new \Zend\Validator\Sitemap\Lastmod(); $changefreqValidator = new \Zend\Validator\Sitemap\Changefreq(); $priorityValidator = new \Zend\Validator\Sitemap\Priority(); } $dom = new DOMDocument('1.0', 'UTF-8'); $dom->formatOutput = $this->getFormatOutput(); $urlSet = $dom->createElementNS(self::SITEMAP_NS, 'urlset'); $dom->appendChild($urlSet); $iterator = new RecursiveIteratorIterator($container, RecursiveIteratorIterator::SELF_FIRST); $maxDepth = $this->getMaxDepth(); if (is_int($maxDepth)) { $iterator->setMaxDepth($maxDepth); } $minDepth = $this->getMinDepth(); if (!is_int($minDepth) || $minDepth < 0) { $minDepth = 0; } foreach ($iterator as $page) { if ($iterator->getDepth() < $minDepth || !$this->accept($page)) { continue; } if (!$url = $this->url($page)) { continue; } $urlNode = $dom->createElementNS(self::SITEMAP_NS, 'url'); $urlSet->appendChild($urlNode); if ($this->getUseSitemapValidators() && !$locValidator->isValid($url) ) { throw new Exception\RuntimeException(sprintf( 'Encountered an invalid URL for Sitemap XML: "%s"', $url )); } $urlNode->appendChild($dom->createElementNS(self::SITEMAP_NS, 'loc', $url)); if (isset($page->lastmod)) { $lastmod = strtotime((string) $page->lastmod); if ($lastmod !== false) { $lastmod = date('c', $lastmod); } if (!$this->getUseSitemapValidators() || $lastmodValidator->isValid($lastmod)) { $urlNode->appendChild( $dom->createElementNS(self::SITEMAP_NS, 'lastmod', $lastmod) ); } } if (isset($page->changefreq)) { $changefreq = $page->changefreq; if (!$this->getUseSitemapValidators() || $changefreqValidator->isValid($changefreq)) { $urlNode->appendChild( $dom->createElementNS(self::SITEMAP_NS, 'changefreq', $changefreq) ); } } if (isset($page->priority)) { $priority = $page->priority; if (!$this->getUseSitemapValidators() || $priorityValidator->isValid($priority)) { $urlNode->appendChild( $dom->createElementNS(self::SITEMAP_NS, 'priority', $priority) ); } } } if ($this->getUseSchemaValidation()) { ErrorHandler::start(); $test = $dom->schemaValidate(self::SITEMAP_XSD); $error = ErrorHandler::stop(); if (!$test) { throw new Exception\RuntimeException(sprintf( 'Sitemap is invalid according to XML Schema at "%s"', self::SITEMAP_XSD ), 0, $error); } } return $dom; } public function url(AbstractPage $page) { $href = $page->getHref(); if (!isset($href{0})) { return ''; } elseif ($href{0} == '/') { $url = $this->getServerUrl() . $href; } elseif (preg_match('/^[a-z]+:/im', (string) $href)) { $url = (string) $href; } else { $basePathHelper = $this->getView()->plugin('basepath'); $curDoc = $basePathHelper(); $curDoc = ('/' == $curDoc) ? '' : trim($curDoc, '/'); $url = rtrim($this->getServerUrl(), '/') . '/' . $curDoc . (empty($curDoc) ? '' : '/') . $href; } if (! in_array($url, $this->urls)) { $this->urls[] = $url; return $this->xmlEscape($url); } return null; } protected function xmlEscape($string) { $escaper = $this->view->plugin('escapeHtml'); return $escaper($string); } public function setFormatOutput($formatOutput = true) { $this->formatOutput = (bool) $formatOutput; return $this; } public function getFormatOutput() { return $this->formatOutput; } public function setServerUrl($serverUrl) { $uri = Uri\UriFactory::factory($serverUrl); $uri->setFragment(''); $uri->setPath(''); $uri->setQuery(''); if ($uri->isValid()) { $this->serverUrl = $uri->toString(); } else { throw new Exception\InvalidArgumentException(sprintf( 'Invalid server URL: "%s"', $serverUrl )); } return $this; } public function getServerUrl() { if (!isset($this->serverUrl)) { $serverUrlHelper = $this->getView()->plugin('serverUrl'); $this->serverUrl = $serverUrlHelper(); } return $this->serverUrl; } public function setUseSitemapValidators($useSitemapValidators) { $this->useSitemapValidators = (bool) $useSitemapValidators; return $this; } public function getUseSitemapValidators() { return $this->useSitemapValidators; } public function setUseSchemaValidation($schemaValidation) { $this->useSchemaValidation = (bool) $schemaValidation; return $this; } public function getUseSchemaValidation() { return $this->useSchemaValidation; } public function setUseXmlDeclaration($useXmlDecl) { $this->useXmlDeclaration = (bool) $useXmlDecl; return $this; } public function getUseXmlDeclaration() { return $this->useXmlDeclaration; } } 'alternate', self::RENDER_STYLESHEET => 'stylesheet', self::RENDER_START => 'start', self::RENDER_NEXT => 'next', self::RENDER_PREV => 'prev', self::RENDER_CONTENTS => 'contents', self::RENDER_INDEX => 'index', self::RENDER_GLOSSARY => 'glossary', self::RENDER_COPYRIGHT => 'copyright', self::RENDER_CHAPTER => 'chapter', self::RENDER_SECTION => 'section', self::RENDER_SUBSECTION => 'subsection', self::RENDER_APPENDIX => 'appendix', self::RENDER_HELP => 'help', self::RENDER_BOOKMARK => 'bookmark', ); protected $renderFlag = self::RENDER_ALL; protected $root; public function __invoke($container = null) { if (null !== $container) { $this->setContainer($container); } return $this; } public function __call($method, array $arguments = array()) { ErrorHandler::start(E_WARNING); $result = preg_match('/find(Rel|Rev)(.+)/', $method, $match); ErrorHandler::stop(); if ($result) { return $this->findRelation($arguments[0], strtolower($match[1]), strtolower($match[2])); } return parent::__call($method, $arguments); } public function render($container = null) { $this->parseContainer($container); if (null === $container) { $container = $this->getContainer(); } $active = $this->findActive($container); if ($active) { $active = $active['page']; } else { return ''; } $output = ''; $indent = $this->getIndent(); $this->root = $container; $result = $this->findAllRelations($active, $this->getRenderFlag()); foreach ($result as $attrib => $types) { foreach ($types as $relation => $pages) { foreach ($pages as $page) { $r = $this->renderLink($page, $attrib, $relation); if ($r) { $output .= $indent . $r . self::EOL; } } } } $this->root = null; return strlen($output) ? rtrim($output, self::EOL) : ''; } public function renderLink(AbstractPage $page, $attrib, $relation) { if (!in_array($attrib, array('rel', 'rev'))) { throw new Exception\DomainException(sprintf( 'Invalid relation attribute "%s", must be "rel" or "rev"', $attrib )); } if (!$href = $page->getHref()) { return ''; } $attribs = array( $attrib => $relation, 'href' => $href, 'title' => $page->getLabel() ); return 'htmlAttribs($attribs) . $this->getClosingBracket(); } public function findAllRelations(AbstractPage $page, $flag = null) { if (!is_int($flag)) { $flag = self::RENDER_ALL; } $result = array('rel' => array(), 'rev' => array()); $native = array_values(static::$RELATIONS); foreach (array_keys($result) as $rel) { $meth = 'getDefined' . ucfirst($rel); $types = array_merge($native, array_diff($page->$meth(), $native)); foreach ($types as $type) { if (!$relFlag = array_search($type, static::$RELATIONS)) { $relFlag = self::RENDER_CUSTOM; } if (!($flag & $relFlag)) { continue; } $found = $this->findRelation($page, $rel, $type); if ($found) { if (!is_array($found)) { $found = array($found); } $result[$rel][$type] = $found; } } } return $result; } public function findRelation(AbstractPage $page, $rel, $type) { if (!in_array($rel, array('rel', 'rev'))) { throw new Exception\DomainException(sprintf( 'Invalid argument: $rel must be "rel" or "rev"; "%s" given', $rel )); } if (!$result = $this->findFromProperty($page, $rel, $type)) { $result = $this->findFromSearch($page, $rel, $type); } return $result; } protected function findFromProperty(AbstractPage $page, $rel, $type) { $method = 'get' . ucfirst($rel); $result = $page->$method($type); if ($result) { $result = $this->convertToPages($result); if ($result) { if (!is_array($result)) { $result = array($result); } foreach ($result as $key => $page) { if (!$this->accept($page)) { unset($result[$key]); } } return count($result) == 1 ? $result[0] : $result; } } return null; } protected function findFromSearch(AbstractPage $page, $rel, $type) { $found = null; $method = 'search' . ucfirst($rel) . ucfirst($type); if (method_exists($this, $method)) { $found = $this->$method($page); } return $found; } public function searchRelStart(AbstractPage $page) { $found = $this->findRoot($page); if (!$found instanceof AbstractPage) { $found->rewind(); $found = $found->current(); } if ($found === $page || !$this->accept($found)) { $found = null; } return $found; } public function searchRelNext(AbstractPage $page) { $found = null; $break = false; $iterator = new RecursiveIteratorIterator($this->findRoot($page), RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $intermediate) { if ($intermediate === $page) { $break = true; continue; } if ($break && $this->accept($intermediate)) { $found = $intermediate; break; } } return $found; } public function searchRelPrev(AbstractPage $page) { $found = null; $prev = null; $iterator = new RecursiveIteratorIterator( $this->findRoot($page), RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $intermediate) { if (!$this->accept($intermediate)) { continue; } if ($intermediate === $page) { $found = $prev; break; } $prev = $intermediate; } return $found; } public function searchRelChapter(AbstractPage $page) { $found = array(); $root = $this->findRoot($page); $start = $this->findRelation($page, 'rel', 'start'); if (!is_array($start)) { $start = array($start); } foreach ($root as $chapter) { if ($chapter !== $page && !in_array($chapter, $start) && $this->accept($chapter)) { $found[] = $chapter; } } switch (count($found)) { case 0: return null; case 1: return $found[0]; default: return $found; } } public function searchRelSection(AbstractPage $page) { $found = array(); if ($page->hasPages() && $this->findRoot($page)->hasPage($page)) { foreach ($page as $section) { if ($this->accept($section)) { $found[] = $section; } } } switch (count($found)) { case 0: return null; case 1: return $found[0]; default: return $found; } } public function searchRelSubsection(AbstractPage $page) { $found = array(); if ($page->hasPages()) { foreach ($this->findRoot($page) as $chapter) { if ($chapter->hasPage($page)) { foreach ($page as $subsection) { if ($this->accept($subsection)) { $found[] = $subsection; } } } } } switch (count($found)) { case 0: return null; case 1: return $found[0]; default: return $found; } } public function searchRevSection(AbstractPage $page) { $found = null; $parent = $page->getParent(); if ($parent) { if ($parent instanceof AbstractPage && $this->findRoot($page)->hasPage($parent)) { $found = $parent; } } return $found; } public function searchRevSubsection(AbstractPage $page) { $found = null; $parent = $page->getParent(); if ($parent) { if ($parent instanceof AbstractPage) { $root = $this->findRoot($page); foreach ($root as $chapter) { if ($chapter->hasPage($parent)) { $found = $parent; break; } } } } return $found; } protected function findRoot(AbstractPage $page) { if ($this->root) { return $this->root; } $root = $page; while ($parent = $page->getParent()) { $root = $parent; if ($parent instanceof AbstractPage) { $page = $parent; } else { break; } } return $root; } protected function convertToPages($mixed, $recursive = true) { if ($mixed instanceof AbstractPage) { return $mixed; } elseif ($mixed instanceof AbstractContainer) { $pages = array(); foreach ($mixed as $page) { $pages[] = $page; } return $pages; } elseif ($mixed instanceof Traversable) { $mixed = ArrayUtils::iteratorToArray($mixed); } elseif (is_string($mixed)) { return AbstractPage::factory(array( 'type' => 'uri', 'uri' => $mixed )); } if (is_array($mixed) && !empty($mixed)) { if ($recursive && is_numeric(key($mixed))) { $pages = array(); foreach ($mixed as $value) { $value = $this->convertToPages($value, false); if ($value) { $pages[] = $value; } } return $pages; } else { try { $page = AbstractPage::factory($mixed); return $page; } catch (\Exception $e) { } } } return null; } public function setRenderFlag($renderFlag) { $this->renderFlag = (int) $renderFlag; return $this; } public function getRenderFlag() { return $this->renderFlag; } } getContainer(), $method), $arguments); } public function __toString() { try { return $this->render(); } catch (\Exception $e) { $msg = get_class($e) . ': ' . $e->getMessage(); trigger_error($msg, E_USER_ERROR); return ''; } } public function findActive($container, $minDepth = null, $maxDepth = -1) { $this->parseContainer($container); if (!is_int($minDepth)) { $minDepth = $this->getMinDepth(); } if ((!is_int($maxDepth) || $maxDepth < 0) && null !== $maxDepth) { $maxDepth = $this->getMaxDepth(); } $found = null; $foundDepth = -1; $iterator = new RecursiveIteratorIterator($container, RecursiveIteratorIterator::CHILD_FIRST); foreach ($iterator as $page) { $currDepth = $iterator->getDepth(); if ($currDepth < $minDepth || !$this->accept($page)) { continue; } if ($page->isActive(false) && $currDepth > $foundDepth) { $found = $page; $foundDepth = $currDepth; } } if (is_int($maxDepth) && $foundDepth > $maxDepth) { while ($foundDepth > $maxDepth) { if (--$foundDepth < $minDepth) { $found = null; break; } $found = $found->getParent(); if (!$found instanceof AbstractPage) { $found = null; break; } } } if ($found) { return array('page' => $found, 'depth' => $foundDepth); } return array(); } protected function parseContainer(&$container = null) { if (null === $container) { return; } if (is_string($container)) { if (!$this->getServiceLocator()) { throw new Exception\InvalidArgumentException(sprintf( 'Attempted to set container with alias "%s" but no ServiceLocator was set', $container )); } $sl = $this->getServiceLocator(); if ($sl instanceof View\HelperPluginManager) { $sl = $sl->getServiceLocator(); } $container = $sl->get($container); return; } if (!$container instanceof Navigation\AbstractContainer) { throw new Exception\InvalidArgumentException( 'Container must be a string alias or an instance of ' . 'Zend\Navigation\AbstractContainer' ); } } public function accept(AbstractPage $page, $recursive = true) { $accept = true; if (!$page->isVisible(false) && !$this->getRenderInvisible()) { $accept = false; } elseif ($this->getUseAcl()) { $acl = $this->getAcl(); $role = $this->getRole(); $params = array('acl' => $acl, 'page' => $page, 'role' => $role); $accept = $this->isAllowed($params); } if ($accept && $recursive) { $parent = $page->getParent(); if ($parent instanceof AbstractPage) { $accept = $this->accept($parent, true); } } return $accept; } protected function isAllowed($params) { $results = $this->getEventManager()->trigger(__FUNCTION__, $this, $params); return $results->last(); } protected function getWhitespace($indent) { if (is_int($indent)) { $indent = str_repeat(' ', $indent); } return (string) $indent; } protected function htmlAttribs($attribs) { foreach ($attribs as $key => $value) { if ($value === null || (is_string($value) && !strlen($value))) { unset($attribs[$key]); } } return parent::htmlAttribs($attribs); } public function htmlify(AbstractPage $page) { $label = $page->getLabel(); $title = $page->getTitle(); if (null !== ($translator = $this->getTranslator())) { $textDomain = $this->getTranslatorTextDomain(); if (is_string($label) && !empty($label)) { $label = $translator->translate($label, $textDomain); } if (is_string($title) && !empty($title)) { $title = $translator->translate($title, $textDomain); } } $attribs = array( 'id' => $page->getId(), 'title' => $title, 'class' => $page->getClass(), 'href' => $page->getHref(), 'target' => $page->getTarget() ); $escaper = $this->view->plugin('escapeHtml'); return 'htmlAttribs($attribs) . '>' . $escaper($label) . ''; } protected function normalizeId($value) { $prefix = get_class($this); $prefix = strtolower(trim(substr($prefix, strrpos($prefix, '\\')), '\\')); return $prefix . '-' . $value; } public function setAcl(Acl\AclInterface $acl = null) { $this->acl = $acl; return $this; } public function getAcl() { if ($this->acl === null && static::$defaultAcl !== null) { return static::$defaultAcl; } return $this->acl; } public function hasAcl() { if ($this->acl instanceof Acl\Acl || static::$defaultAcl instanceof Acl\Acl ) { return true; } return false; } public function setEventManager(EventManagerInterface $events) { $events->setIdentifiers(array( __CLASS__, get_called_class(), )); $this->events = $events; $this->setDefaultListeners(); return $this; } public function getEventManager() { if (null === $this->events) { $this->setEventManager(new EventManager()); } return $this->events; } public function setContainer($container = null) { $this->parseContainer($container); $this->container = $container; return $this; } public function getContainer() { if (null === $this->container) { $this->container = new Navigation\Navigation(); } return $this->container; } public function hasContainer() { return null !== $this->container; } public function setIndent($indent) { $this->indent = $this->getWhitespace($indent); return $this; } public function getIndent() { return $this->indent; } public function setMaxDepth($maxDepth = null) { if (null === $maxDepth || is_int($maxDepth)) { $this->maxDepth = $maxDepth; } else { $this->maxDepth = (int) $maxDepth; } return $this; } public function getMaxDepth() { return $this->maxDepth; } public function setMinDepth($minDepth = null) { if (null === $minDepth || is_int($minDepth)) { $this->minDepth = $minDepth; } else { $this->minDepth = (int) $minDepth; } return $this; } public function getMinDepth() { if (!is_int($this->minDepth) || $this->minDepth < 0) { return 0; } return $this->minDepth; } public function setRenderInvisible($renderInvisible = true) { $this->renderInvisible = (bool) $renderInvisible; return $this; } public function getRenderInvisible() { return $this->renderInvisible; } public function setRole($role = null) { if (null === $role || is_string($role) || $role instanceof Acl\Role\RoleInterface ) { $this->role = $role; } else { throw new Exception\InvalidArgumentException(sprintf( '$role must be a string, null, or an instance of ' . 'Zend\Permissions\Role\RoleInterface; %s given', (is_object($role) ? get_class($role) : gettype($role)) )); } return $this; } public function getRole() { if ($this->role === null && static::$defaultRole !== null) { return static::$defaultRole; } return $this->role; } public function hasRole() { if ($this->role instanceof Acl\Role\RoleInterface || is_string($this->role) || static::$defaultRole instanceof Acl\Role\RoleInterface || is_string(static::$defaultRole) ) { return true; } return false; } public function setServiceLocator(ServiceLocatorInterface $serviceLocator) { $this->serviceLocator = $serviceLocator; return $this; } public function getServiceLocator() { return $this->serviceLocator; } public function setTranslator(Translator $translator = null, $textDomain = null) { $this->translator = $translator; if (null !== $textDomain) { $this->setTranslatorTextDomain($textDomain); } return $this; } public function getTranslator() { if (! $this->isTranslatorEnabled()) { return null; } return $this->translator; } public function hasTranslator() { return (bool) $this->getTranslator(); } public function setTranslatorEnabled($enabled = true) { $this->translatorEnabled = (bool) $enabled; return $this; } public function isTranslatorEnabled() { return $this->translatorEnabled; } public function setTranslatorTextDomain($textDomain = 'default') { $this->translatorTextDomain = $textDomain; return $this; } public function getTranslatorTextDomain() { return $this->translatorTextDomain; } public function setUseAcl($useAcl = true) { $this->useAcl = (bool) $useAcl; return $this; } public function getUseAcl() { return $this->useAcl; } public static function setDefaultAcl(Acl\AclInterface $acl = null) { static::$defaultAcl = $acl; } public static function setDefaultRole($role = null) { if (null === $role || is_string($role) || $role instanceof Acl\Role\RoleInterface ) { static::$defaultRole = $role; } else { throw new Exception\InvalidArgumentException(sprintf( '$role must be null|string|Zend\Permissions\Role\RoleInterface; received "%s"', (is_object($role) ? get_class($role) : gettype($role)) )); } } protected function setDefaultListeners() { if (!$this->getUseAcl()) { return; } $this->getEventManager()->getSharedManager()->attach( 'Zend\View\Helper\Navigation\AbstractHelper', 'isAllowed', array('Zend\View\Helper\Navigation\Listener\AclListener', 'accept') ); } } getEscaper()->escapeJs($value); } } getContainer($name); } public function createContainer($key, array $value = array()) { $key = (string) $key; $this->items[$key] = new $this->containerClass($value); return $this->items[$key]; } public function getContainer($key) { $key = (string) $key; if (isset($this->items[$key])) { return $this->items[$key]; } $container = $this->createContainer($key); return $container; } public function containerExists($key) { $key = (string) $key; $return = array_key_exists($key, $this->items); return $return; } } getView(); $args = func_get_args(); foreach ($args as $key) { if (is_array($key)) { foreach ($key as $name => $value) { $this->declareVar($name, $value); } } elseif (!isset($view->vars()->$key)) { $this->declareVar($key); } } } protected function declareVar($key, $value = '') { $view = $this->getView(); $vars = $view->vars(); if (!isset($vars->$key)) { $vars->$key = $value; } } } $data, 'type' => $type), $attribs); $paramHtml = array(); $closingBracket = $this->getClosingBracket(); foreach ($params as $param => $options) { if (is_string($options)) { $options = array('value' => $options); } $options = array_merge(array('name' => $param), $options); $paramHtml[] = 'htmlAttribs($options) . $closingBracket; } if (is_array($content)) { $content = implode(self::EOL, $content); } $xhtml = 'htmlAttribs($attribs) . '>' . self::EOL . implode(self::EOL, $paramHtml) . self::EOL . ($content ? $content . self::EOL : '') . ''; return $xhtml; } } setContainer($container); } return $this; } public function __call($method, array $arguments = array()) { $helper = $this->findHelper($method, false); if ($helper) { if ($helper instanceof ServiceLocatorAwareInterface && $this->getServiceLocator()) { $helper->setServiceLocator($this->getServiceLocator()); } return call_user_func_array($helper, $arguments); } return parent::__call($method, $arguments); } public function render($container = null) { return $this->findHelper($this->getDefaultProxy())->render($container); } public function findHelper($proxy, $strict = true) { $plugins = $this->getPluginManager(); if (!$plugins->has($proxy)) { if ($strict) { throw new Exception\RuntimeException(sprintf( 'Failed to find plugin for %s', $proxy )); } return false; } $helper = $plugins->get($proxy); $container = $this->getContainer(); $hash = spl_object_hash($container) . spl_object_hash($helper); if (!isset($this->injected[$hash])) { $helper->setContainer(); $this->inject($helper); $this->injected[$hash] = true; } else { if ($this->getInjectContainer()) { $helper->setContainer($container); } } return $helper; } protected function inject(NavigationHelper $helper) { if ($this->getInjectContainer() && !$helper->hasContainer()) { $helper->setContainer($this->getContainer()); } if ($this->getInjectAcl()) { if (!$helper->hasAcl()) { $helper->setAcl($this->getAcl()); } if (!$helper->hasRole()) { $helper->setRole($this->getRole()); } } if ($this->getInjectTranslator() && !$helper->hasTranslator()) { $helper->setTranslator( $this->getTranslator(), $this->getTranslatorTextDomain() ); } } public function setDefaultProxy($proxy) { $this->defaultProxy = (string) $proxy; return $this; } public function getDefaultProxy() { return $this->defaultProxy; } public function setInjectContainer($injectContainer = true) { $this->injectContainer = (bool) $injectContainer; return $this; } public function getInjectContainer() { return $this->injectContainer; } public function setInjectAcl($injectAcl = true) { $this->injectAcl = (bool) $injectAcl; return $this; } public function getInjectAcl() { return $this->injectAcl; } public function setInjectTranslator($injectTranslator = true) { $this->injectTranslator = (bool) $injectTranslator; return $this; } public function getInjectTranslator() { return $this->injectTranslator; } public function setPluginManager(Navigation\PluginManager $plugins) { $renderer = $this->getView(); if ($renderer) { $plugins->setRenderer($renderer); } $this->plugins = $plugins; return $this; } public function getPluginManager() { if (null === $this->plugins) { $this->setPluginManager(new Navigation\PluginManager()); } return $this->plugins; } } self::ATTRIB_CLASSID, 'codebase' => self::ATTRIB_CODEBASE); public function __invoke($data, array $attribs = array(), array $params = array(), $content = null) { $attribs = array_merge($this->attribs, $attribs); $params = array_merge(array('src' => $data), $params); $htmlObject = $this->getView()->plugin('htmlObject'); return $htmlObject($data, self::TYPE, $attribs, $params, $content); } } view = $view; return $this; } public function getView() { return $this->view; } } render($child); } public function render($child) { $model = $this->findChild($child); if (!$model) { return ''; } $current = $this->current; $view = $this->getView(); $return = $view->render($model); $helper = $this->getViewModelHelper(); $helper->setCurrent($current); return $return; } protected function findChild($child) { $this->current = $model = $this->getCurrent(); foreach ($model->getChildren() as $childModel) { if ($childModel->captureTo() == $child) { return $childModel; } } return false; } protected function getCurrent() { $helper = $this->getViewModelHelper(); if (!$helper->hasCurrent()) { throw new Exception\RuntimeException(sprintf( '%s: no view model currently registered in renderer; cannot query for children', __METHOD__ )); } return $helper->getCurrent(); } protected function getViewModelHelper() { if ($this->viewModelHelper) { return $this->viewModelHelper; } if (method_exists($this->getView(), 'plugin')) { $this->viewModelHelper = $this->view->plugin('view_model'); } return $this->viewModelHelper; } } setSeparator(PHP_EOL); } public function headLink(array $attributes = null, $placement = Placeholder\Container\AbstractContainer::APPEND) { return call_user_func_array(array($this, '__invoke'), func_get_args()); } public function __invoke(array $attributes = null, $placement = Placeholder\Container\AbstractContainer::APPEND) { if (null !== $attributes) { $item = $this->createData($attributes); switch ($placement) { case Placeholder\Container\AbstractContainer::SET: $this->set($item); break; case Placeholder\Container\AbstractContainer::PREPEND: $this->prepend($item); break; case Placeholder\Container\AbstractContainer::APPEND: default: $this->append($item); break; } } return $this; } public function __call($method, $args) { if (preg_match('/^(?Pset|(ap|pre)pend|offsetSet)(?PStylesheet|Alternate|Prev|Next)$/', $method, $matches)) { $argc = count($args); $action = $matches['action']; $type = $matches['type']; $index = null; if ('offsetSet' == $action) { if (0 < $argc) { $index = array_shift($args); --$argc; } } if (1 > $argc) { throw new Exception\BadMethodCallException(sprintf( '%s requires at least one argument', $method )); } if (is_array($args[0])) { $item = $this->createData($args[0]); } else { $dataMethod = 'createData' . $type; $item = $this->$dataMethod($args); } if ($item) { if ('offsetSet' == $action) { $this->offsetSet($index, $item); } else { $this->$action($item); } } return $this; } return parent::__call($method, $args); } protected function isValid($value) { if (!$value instanceof stdClass) { return false; } $vars = get_object_vars($value); $keys = array_keys($vars); $intersection = array_intersect($this->itemKeys, $keys); if (empty($intersection)) { return false; } return true; } public function append($value) { if (!$this->isValid($value)) { throw new Exception\InvalidArgumentException( 'append() expects a data token; please use one of the custom append*() methods' ); } return $this->getContainer()->append($value); } public function offsetSet($index, $value) { if (!$this->isValid($value)) { throw new Exception\InvalidArgumentException( 'offsetSet() expects a data token; please use one of the custom offsetSet*() methods' ); } return $this->getContainer()->offsetSet($index, $value); } public function prepend($value) { if (!$this->isValid($value)) { throw new Exception\InvalidArgumentException( 'prepend() expects a data token; please use one of the custom prepend*() methods' ); } return $this->getContainer()->prepend($value); } public function set($value) { if (!$this->isValid($value)) { throw new Exception\InvalidArgumentException( 'set() expects a data token; please use one of the custom set*() methods' ); } return $this->getContainer()->set($value); } public function itemToString(stdClass $item) { $attributes = (array) $item; $link = 'itemKeys as $itemKey) { if (isset($attributes[$itemKey])) { if (is_array($attributes[$itemKey])) { foreach ($attributes[$itemKey] as $key => $value) { $link .= sprintf(' %s="%s"', $key, ($this->autoEscape) ? $this->escape($value) : $value); } } else { $link .= sprintf(' %s="%s"', $itemKey, ($this->autoEscape) ? $this->escape($attributes[$itemKey]) : $attributes[$itemKey]); } } } if (method_exists($this->view, 'plugin')) { $link .= ($this->view->plugin('doctype')->isXhtml()) ? ' />' : '>'; } else { $link .= ' />'; } if (($link == '') || ($link == '')) { return ''; } if (isset($attributes['conditionalStylesheet']) && !empty($attributes['conditionalStylesheet']) && is_string($attributes['conditionalStylesheet'])) { $link = ''; } return $link; } public function toString($indent = null) { $indent = (null !== $indent) ? $this->getWhitespace($indent) : $this->getIndent(); $items = array(); $this->getContainer()->ksort(); foreach ($this as $item) { $items[] = $this->itemToString($item); } return $indent . implode($this->escape($this->getSeparator()) . $indent, $items); } public function createData(array $attributes) { return (object) $attributes; } public function createDataStylesheet(array $args) { $rel = 'stylesheet'; $type = 'text/css'; $media = 'screen'; $conditionalStylesheet = false; $href = array_shift($args); if ($this->isDuplicateStylesheet($href)) { return false; } if (0 < count($args)) { $media = array_shift($args); if (is_array($media)) { $media = implode(',', $media); } else { $media = (string) $media; } } if (0 < count($args)) { $conditionalStylesheet = array_shift($args); if (!empty($conditionalStylesheet) && is_string($conditionalStylesheet)) { $conditionalStylesheet = (string) $conditionalStylesheet; } else { $conditionalStylesheet = null; } } if (0 < count($args) && is_array($args[0])) { $extras = array_shift($args); $extras = (array) $extras; } $attributes = compact('rel', 'type', 'href', 'media', 'conditionalStylesheet', 'extras'); return $this->createData($attributes); } protected function isDuplicateStylesheet($uri) { foreach ($this->getContainer() as $item) { if (($item->rel == 'stylesheet') && ($item->href == $uri)) { return true; } } return false; } public function createDataAlternate(array $args) { if (3 > count($args)) { throw new Exception\InvalidArgumentException(sprintf( 'Alternate tags require 3 arguments; %s provided', count($args) )); } $rel = 'alternate'; $href = array_shift($args); $type = array_shift($args); $title = array_shift($args); if (0 < count($args) && is_array($args[0])) { $extras = array_shift($args); $extras = (array) $extras; if (isset($extras['media']) && is_array($extras['media'])) { $extras['media'] = implode(',', $extras['media']); } } $href = (string) $href; $type = (string) $type; $title = (string) $title; $attributes = compact('rel', 'href', 'type', 'title', 'extras'); return $this->createData($attributes); } public function createDataPrev(array $args) { $rel = 'prev'; $href = (string) array_shift($args); $attributes = compact('rel', 'href'); return $this->createData($attributes); } public function createDataNext(array $args) { $rel = 'next'; $href = (string) array_shift($args); $attributes = compact('rel', 'href'); return $this->createData($attributes); } } setSeparator(PHP_EOL); } public function __invoke($content = null, $placement = 'APPEND', $attributes = array()) { if ((null !== $content) && is_string($content)) { switch (strtoupper($placement)) { case 'SET': $action = 'setStyle'; break; case 'PREPEND': $action = 'prependStyle'; break; case 'APPEND': default: $action = 'appendStyle'; break; } $this->$action($content, $attributes); } return $this; } public function __call($method, $args) { if (preg_match('/^(?Pset|(ap|pre)pend|offsetSet)(Style)$/', $method, $matches)) { $index = null; $argc = count($args); $action = $matches['action']; if ('offsetSet' == $action) { if (0 < $argc) { $index = array_shift($args); --$argc; } } if (1 > $argc) { throw new Exception\BadMethodCallException(sprintf( 'Method "%s" requires minimally content for the stylesheet', $method )); } $content = $args[0]; $attrs = array(); if (isset($args[1])) { $attrs = (array) $args[1]; } $item = $this->createData($content, $attrs); if ('offsetSet' == $action) { $this->offsetSet($index, $item); } else { $this->$action($item); } return $this; } return parent::__call($method, $args); } public function toString($indent = null) { $indent = (null !== $indent) ? $this->getWhitespace($indent) : $this->getIndent(); $items = array(); $this->getContainer()->ksort(); foreach ($this as $item) { if (!$this->isValid($item)) { continue; } $items[] = $this->itemToString($item, $indent); } $return = $indent . implode($this->getSeparator() . $indent, $items); $return = preg_replace("/(\r\n?|\n)/", '$1' . $indent, $return); return $return; } public function captureStart($type = Placeholder\Container\AbstractContainer::APPEND, $attrs = null) { if ($this->captureLock) { throw new Exception\RuntimeException('Cannot nest headStyle captures'); } $this->captureLock = true; $this->captureAttrs = $attrs; $this->captureType = $type; ob_start(); } public function captureEnd() { $content = ob_get_clean(); $attrs = $this->captureAttrs; $this->captureAttrs = null; $this->captureLock = false; switch ($this->captureType) { case Placeholder\Container\AbstractContainer::SET: $this->setStyle($content, $attrs); break; case Placeholder\Container\AbstractContainer::PREPEND: $this->prependStyle($content, $attrs); break; case Placeholder\Container\AbstractContainer::APPEND: default: $this->appendStyle($content, $attrs); break; } } public function createData($content, array $attributes) { if (!isset($attributes['media'])) { $attributes['media'] = 'screen'; } elseif (is_array($attributes['media'])) { $attributes['media'] = implode(',', $attributes['media']); } $data = new stdClass(); $data->content = $content; $data->attributes = $attributes; return $data; } protected function isValid($value) { if ((!$value instanceof stdClass) || !isset($value->content) || !isset($value->attributes)) { return false; } return true; } public function itemToString(stdClass $item, $indent) { $attrString = ''; if (!empty($item->attributes)) { $enc = 'UTF-8'; if ($this->view instanceof View\Renderer\RendererInterface && method_exists($this->view, 'getEncoding') ) { $enc = $this->view->getEncoding(); } $escaper = $this->getEscaper($enc); foreach ($item->attributes as $key => $value) { if (!in_array($key, $this->optionalAttributes)) { continue; } if ('media' == $key) { if (false === strpos($value, ',')) { if (!in_array($value, $this->mediaTypes)) { continue; } } else { $mediaTypes = explode(',', $value); $value = ''; foreach ($mediaTypes as $type) { $type = trim($type); if (!in_array($type, $this->mediaTypes)) { continue; } $value .= $type .','; } $value = substr($value, 0, -1); } } $attrString .= sprintf(' %s="%s"', $key, $escaper->escapeHtmlAttr($value)); } } $escapeStart = $indent . '' . PHP_EOL; if (isset($item->attributes['conditional']) && !empty($item->attributes['conditional']) && is_string($item->attributes['conditional']) ) { $escapeStart = null; $escapeEnd = null; } $html = ''; if (null == $escapeStart && null == $escapeEnd) { $html = ''; } return $html; } public function append($value) { if (!$this->isValid($value)) { throw new Exception\InvalidArgumentException( 'Invalid value passed to append; please use appendStyle()' ); } return $this->getContainer()->append($value); } public function offsetSet($index, $value) { if (!$this->isValid($value)) { throw new Exception\InvalidArgumentException( 'Invalid value passed to offsetSet; please use offsetSetStyle()' ); } return $this->getContainer()->offsetSet($index, $value); } public function prepend($value) { if (!$this->isValid($value)) { throw new Exception\InvalidArgumentException( 'Invalid value passed to prepend; please use prependStyle()' ); } return $this->getContainer()->prepend($value); } public function set($value) { if (!$this->isValid($value)) { throw new Exception\InvalidArgumentException('Invalid value passed to set; please use setStyle()'); } return $this->getContainer()->set($value); } } 80, 'default_img' => self::DEFAULT_MM, 'rating' => self::RATING_G, 'secure' => null, ); public function __invoke($email = "", $options = array(), $attribs = array()) { if (!empty($email)) { $this->setEmail($email); } if (!empty($options)) { $this->setOptions($options); } if (!empty($attribs)) { $this->setAttribs($attribs); } return $this; } public function __toString() { return $this->getImgTag(); } public function setOptions(array $options) { foreach ($options as $key => $value) { $method = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))); if (method_exists($this, $method)) { $this->{$method}($value); } } return $this; } protected function getAvatarUrl() { $src = $this->getGravatarUrl() . '/' . ($this->emailIsHashed ? $this->getEmail() : md5($this->getEmail())) . '?s=' . $this->getImgSize() . '&d=' . $this->getDefaultImg() . '&r=' . $this->getRating(); return $src; } protected function getGravatarUrl() { return ($this->getSecure() === false) ? self::GRAVATAR_URL : self::GRAVATAR_URL_SECURE; } public function getImgTag() { $this->setSrcAttribForImg(); $html = 'htmlAttribs($this->getAttribs()) . $this->getClosingBracket(); return $html; } public function setAttribs(array $attribs) { $this->attribs = $attribs; return $this; } public function getAttribs() { return $this->attribs; } public function setDefaultImg($defaultImg) { $this->options['default_img'] = urlencode($defaultImg); return $this; } public function getDefaultImg() { return $this->options['default_img']; } public function setEmail($email) { $this->emailIsHashed = (bool) preg_match('/^[A-Za-z0-9]{32}$/', $email); $this->email = strtolower(trim($email)); return $this; } public function getEmail() { return $this->email; } public function setImgSize($imgSize) { $this->options['img_size'] = (int) $imgSize; return $this; } public function getImgSize() { return $this->options['img_size']; } public function setRating($rating) { switch ($rating) { case self::RATING_G: case self::RATING_PG: case self::RATING_R: case self::RATING_X: $this->options['rating'] = $rating; break; default: throw new Exception\DomainException(sprintf( 'The rating value "%s" is not allowed', $rating )); } return $this; } public function getRating() { return $this->options['rating']; } public function setSecure($flag) { $this->options['secure'] = ($flag === null) ? null : (bool) $flag; return $this; } public function getSecure() { if ($this->options['secure'] === null) { return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'); } return $this->options['secure']; } protected function setSrcAttribForImg() { $attribs = $this->getAttribs(); $attribs['src'] = $this->getAvatarUrl(); $this->setAttribs($attribs); } } getEscaper()->escapeHtmlAttr($value); } } toString(); } public function toString($indent = null) { $indent = ($indent !== null) ? $this->getWhitespace($indent) : $this->getIndent(); $items = $this->getArrayCopy(); $return = $indent . $this->getPrefix() . implode($this->getSeparator(), $items) . $this->getPostfix(); $return = preg_replace("/(\r\n?|\n)/", '$1' . $indent, $return); return $return; } public function captureStart($type = AbstractContainer::APPEND, $key = null) { if ($this->captureLock) { throw new Exception\RuntimeException( 'Cannot nest placeholder captures for the same placeholder' ); } $this->captureLock = true; $this->captureType = $type; if ((null !== $key) && is_scalar($key)) { $this->captureKey = (string) $key; } ob_start(); } public function captureEnd() { $data = ob_get_clean(); $key = null; $this->captureLock = false; if (null !== $this->captureKey) { $key = $this->captureKey; } switch ($this->captureType) { case self::SET: if (null !== $key) { $this[$key] = $data; } else { $this->exchangeArray(array($data)); } break; case self::PREPEND: if (null !== $key) { $array = array($key => $data); $values = $this->getArrayCopy(); $final = $array + $values; $this->exchangeArray($final); } else { $this->prepend($data); } break; case self::APPEND: default: if (null !== $key) { if (empty($this[$key])) { $this[$key] = $data; } else { $this[$key] .= $data; } } else { $this[$this->nextIndex()] = $data; } break; } } public function getKeys() { $array = $this->getArrayCopy(); return array_keys($array); } public function getValue() { if (1 == count($this)) { $keys = $this->getKeys(); $key = array_shift($keys); return $this[$key]; } return $this->getArrayCopy(); } public function getWhitespace($indent) { if (is_int($indent)) { $indent = str_repeat(' ', $indent); } return (string) $indent; } public function set($value) { $this->exchangeArray(array($value)); return $this; } public function prepend($value) { $values = $this->getArrayCopy(); array_unshift($values, $value); $this->exchangeArray($values); return $this; } public function nextIndex() { $keys = $this->getKeys(); if (0 == count($keys)) { return 0; } return $nextIndex = max($keys) + 1; } public function setIndent($indent) { $this->indent = $this->getWhitespace($indent); return $this; } public function getIndent() { return $this->indent; } public function setPostfix($postfix) { $this->postfix = (string) $postfix; return $this; } public function getPostfix() { return $this->postfix; } public function setPrefix($prefix) { $this->prefix = (string) $prefix; return $this; } public function getPrefix() { return $this->prefix; } public function setSeparator($separator) { $this->separator = (string) $separator; return $this; } public function getSeparator() { return $this->separator; } } setContainer($this->getContainer()); } public function __call($method, $args) { $container = $this->getContainer(); if (method_exists($container, $method)) { $return = call_user_func_array(array($container, $method), $args); if ($return === $container) { return $this; } return $return; } throw new Exception\BadMethodCallException('Method "' . $method . '" does not exist'); } public function __set($key, $value) { $container = $this->getContainer(); $container[$key] = $value; } public function __get($key) { $container = $this->getContainer(); if (isset($container[$key])) { return $container[$key]; } return null; } public function __isset($key) { $container = $this->getContainer(); return isset($container[$key]); } public function __unset($key) { $container = $this->getContainer(); if (isset($container[$key])) { unset($container[$key]); } } public function __toString() { return $this->toString(); } public function toString() { return $this->getContainer()->toString(); } protected function escape($string) { if ($this->getView() instanceof RendererInterface && method_exists($this->getView(), 'getEncoding') ) { $enc = $this->getView()->getEncoding(); $escaper = $this->getView()->plugin('escapeHtml'); return $escaper((string) $string); } return $this->getEscaper()->escapeHtml((string) $string); } public function setAutoEscape($autoEscape = true) { $this->autoEscape = ($autoEscape) ? true : false; return $this; } public function getAutoEscape() { return $this->autoEscape; } public function setContainer(AbstractContainer $container) { $this->container = $container; return $this; } public function getContainer() { if (!$this->container instanceof AbstractContainer) { $this->container = new $this->containerClass(); } return $this->container; } public function deleteContainer() { if (null != $this->container) { $this->container = null; return true; } return false; } public function setContainerClass($name) { if (!class_exists($name)) { throw new Exception\DomainException( sprintf('%s expects a valid container class name; received "%s", which did not resolve', __METHOD__, $name )); } if (!in_array('Zend\View\Helper\Placeholder\Container\AbstractContainer', class_parents($name))) { throw new Exception\InvalidArgumentException('Invalid Container class specified'); } $this->containerClass = $name; return $this; } public function getContainerClass() { return $this->containerClass; } public function setEscaper(Escaper $escaper) { $encoding = $escaper->getEncoding(); $this->escapers[$encoding] = $escaper; return $this; } public function getEscaper($enc = 'UTF-8') { $enc = strtolower($enc); if (!isset($this->escapers[$enc])) { $this->setEscaper(new Escaper($enc)); } return $this->escapers[$enc]; } public function count() { $container = $this->getContainer(); return count($container); } public function offsetExists($offset) { return $this->getContainer()->offsetExists($offset); } public function offsetGet($offset) { return $this->getContainer()->offsetGet($offset); } public function offsetSet($offset, $value) { return $this->getContainer()->offsetSet($offset, $value); } public function offsetUnset($offset) { return $this->getContainer()->offsetUnset($offset); } public function getIterator() { return $this->getContainer()->getIterator(); } } items[$key] = $container; return $this; } public function getContainer($key) { $key = (string) $key; if (isset($this->items[$key])) { return $this->items[$key]; } $container = $this->createContainer($key); return $container; } public function containerExists($key) { $key = (string) $key; return array_key_exists($key, $this->items); } public function createContainer($key, array $value = array()) { $key = (string) $key; $this->items[$key] = new $this->containerClass($value); return $this->items[$key]; } public function deleteContainer($key) { $key = (string) $key; if (isset($this->items[$key])) { unset($this->items[$key]); return true; } return false; } public function setContainerClass($name) { if (!class_exists($name)) { throw new Exception\DomainException( sprintf('%s expects a valid registry class name; received "%s", which did not resolve', __METHOD__, $name )); } if (!in_array('Zend\View\Helper\Placeholder\Container\AbstractContainer', class_parents($name))) { throw new Exception\InvalidArgumentException('Invalid Container class specified'); } $this->containerClass = $name; return $this; } public function getContainerClass() { return $this->containerClass; } } escape($value); } if (is_array($value)) { if (!(self::RECURSE_ARRAY & $recurse)) { throw new Exception\InvalidArgumentException( 'Array provided to Escape helper, but flags do not allow recursion' ); } foreach ($value as $k => $v) { $value[$k] = $this->__invoke($v, $recurse); } return $value; } if (is_object($value)) { if (!(self::RECURSE_OBJECT & $recurse)) { if (method_exists($value, '__toString')) { return $this->escape((string) $value); } throw new Exception\InvalidArgumentException( 'Object provided to Escape helper, but flags do not allow recursion' ); } if (method_exists($value, 'toArray')) { return $this->__invoke($value->toArray(), $recurse | self::RECURSE_ARRAY); } return $this->__invoke((array) $value, $recurse | self::RECURSE_ARRAY); } return $value; } abstract protected function escape($value); public function setEncoding($encoding) { if (null !== $this->escaper) { throw new Exception\InvalidArgumentException( 'Character encoding settings cannot be changed once the Helper has been used or ' . ' if a Zend\Escaper\Escaper object (with preset encoding option) is set.' ); } $this->encoding = $encoding; return $this; } public function getEncoding() { return $this->encoding; } public function setEscaper(Escaper\Escaper $escaper) { $this->escaper = $escaper; $this->encoding = $escaper->getEncoding(); return $this; } public function getEscaper() { if (null === $this->escaper) { $this->setEscaper(new Escaper\Escaper($this->getEncoding())); } return $this->escaper; } } model = $model; return $this; } public function setRequest(Request $request) { $this->request = $request; return $this; } public function setResponse(Response $response) { $this->response = $response; return $this; } public function setResult($result) { $this->result = $result; return $this; } public function getModel() { return $this->model; } public function setRenderer(Renderer $renderer) { $this->renderer = $renderer; return $this; } public function getRenderer() { return $this->renderer; } public function getRequest() { return $this->request; } public function getResponse() { return $this->response; } public function getResult() { return $this->result; } public function getParam($name, $default = null) { switch ($name) { case 'model': return $this->getModel(); case 'renderer': return $this->getRenderer(); case 'request': return $this->getRequest(); case 'response': return $this->getResponse(); case 'result': return $this->getResult(); default: return parent::getParam($name, $default); } } public function getParams() { $params = parent::getParams(); $params['model'] = $this->getModel(); $params['renderer'] = $this->getRenderer(); $params['request'] = $this->getRequest(); $params['response'] = $this->getResponse(); $params['result'] = $this->getResult(); return $params; } public function setParams($params) { parent::setParams($params); if (!is_array($params) && !$params instanceof ArrayAccess) { return $this; } foreach (array('model', 'renderer', 'request', 'response', 'result') as $param) { if (isset($params[$param])) { $method = 'set' . $param; $this->$method($params[$param]); } } return $this; } public function setParam($name, $value) { switch ($name) { case 'model': $this->setModel($value); break; case 'renderer': $this->setRenderer($value); break; case 'request': $this->setRequest($value); break; case 'response': $this->setResponse($value); break; case 'result': $this->setResult($value); break; default: parent::setParam($name, $value); break; } return $this; } } 'Zend\View\Helper\Service\FlashMessengerFactory', 'identity' => 'Zend\View\Helper\Service\IdentityFactory', ); protected $invokableClasses = array( 'doctype' => 'Zend\View\Helper\Doctype', 'basepath' => 'Zend\View\Helper\BasePath', 'url' => 'Zend\View\Helper\Url', 'cycle' => 'Zend\View\Helper\Cycle', 'declarevars' => 'Zend\View\Helper\DeclareVars', 'escapehtml' => 'Zend\View\Helper\EscapeHtml', 'escapehtmlattr' => 'Zend\View\Helper\EscapeHtmlAttr', 'escapejs' => 'Zend\View\Helper\EscapeJs', 'escapecss' => 'Zend\View\Helper\EscapeCss', 'escapeurl' => 'Zend\View\Helper\EscapeUrl', 'gravatar' => 'Zend\View\Helper\Gravatar', 'headlink' => 'Zend\View\Helper\HeadLink', 'headmeta' => 'Zend\View\Helper\HeadMeta', 'headscript' => 'Zend\View\Helper\HeadScript', 'headstyle' => 'Zend\View\Helper\HeadStyle', 'headtitle' => 'Zend\View\Helper\HeadTitle', 'htmlflash' => 'Zend\View\Helper\HtmlFlash', 'htmllist' => 'Zend\View\Helper\HtmlList', 'htmlobject' => 'Zend\View\Helper\HtmlObject', 'htmlpage' => 'Zend\View\Helper\HtmlPage', 'htmlquicktime' => 'Zend\View\Helper\HtmlQuicktime', 'inlinescript' => 'Zend\View\Helper\InlineScript', 'json' => 'Zend\View\Helper\Json', 'layout' => 'Zend\View\Helper\Layout', 'paginationcontrol' => 'Zend\View\Helper\PaginationControl', 'partialloop' => 'Zend\View\Helper\PartialLoop', 'partial' => 'Zend\View\Helper\Partial', 'placeholder' => 'Zend\View\Helper\Placeholder', 'renderchildmodel' => 'Zend\View\Helper\RenderChildModel', 'rendertoplaceholder' => 'Zend\View\Helper\RenderToPlaceholder', 'serverurl' => 'Zend\View\Helper\ServerUrl', 'viewmodel' => 'Zend\View\Helper\ViewModel', ); protected $renderer; public function __construct(ConfigInterface $configuration = null) { parent::__construct($configuration); $this->addInitializer(array($this, 'injectRenderer')) ->addInitializer(array($this, 'injectTranslator')); } public function setRenderer(Renderer\RendererInterface $renderer) { $this->renderer = $renderer; return $this; } public function getRenderer() { return $this->renderer; } public function injectRenderer($helper) { $renderer = $this->getRenderer(); if (null === $renderer) { return; } $helper->setView($renderer); } public function injectTranslator($helper) { if ($helper instanceof TranslatorAwareInterface) { $locator = $this->getServiceLocator(); if ($locator && $locator->has('MvcTranslator')) { $helper->setTranslator($locator->get('MvcTranslator')); } elseif ($locator && $locator->has('translator')) { $helper->setTranslator($locator->get('translator')); } } } public function validatePlugin($plugin) { if ($plugin instanceof Helper\HelperInterface) { return; } throw new Exception\InvalidHelperException(sprintf( 'Plugin of type %s is invalid; must implement %s\Helper\HelperInterface', (is_object($plugin) ? get_class($plugin) : gettype($plugin)), __NAMESPACE__ )); } } jsonpCallback = $callback; return $this; } public function serialize() { $variables = $this->getVariables(); if ($variables instanceof Traversable) { $variables = ArrayUtils::iteratorToArray($variables); } if (null !== $this->jsonpCallback) { return $this->jsonpCallback.'('.Json::encode($variables).');'; } return Json::encode($variables); } } feed instanceof Feed) { return $this->feed; } if (!$this->type) { $options = $this->getOptions(); if (isset($options['feed_type'])) { $this->type = $options['feed_type']; } } $variables = $this->getVariables(); $feed = FeedFactory::factory($variables); $this->setFeed($feed); return $this->feed; } public function setFeed(Feed $feed) { $this->feed = $feed; return $this; } public function getFeedType() { if ($this->type) { return $this->type; } $options = $this->getOptions(); if (isset($options['feed_type'])) { $this->type = $options['feed_type']; } return $this->type; } } setVariables($variables, true); if (null !== $options) { $this->setOptions($options); } } public function __set($name, $value) { $this->setVariable($name, $value); } public function __get($name) { if (!$this->__isset($name)) { return null; } $variables = $this->getVariables(); return $variables[$name]; } public function __isset($name) { $variables = $this->getVariables(); return isset($variables[$name]); } public function __unset($name) { if (!$this->__isset($name)) { return null; } unset($this->variables[$name]); } public function setOption($name, $value) { $this->options[(string) $name] = $value; return $this; } public function getOption($name, $default = null) { $name = (string) $name; return array_key_exists($name, $this->options) ? $this->options[$name] : $default; } public function setOptions($options) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } if (!is_array($options)) { throw new Exception\InvalidArgumentException(sprintf( '%s: expects an array, or Traversable argument; received "%s"', __METHOD__, (is_object($options) ? get_class($options) : gettype($options)) )); } $this->options = $options; return $this; } public function getOptions() { return $this->options; } public function clearOptions() { $this->options = array(); return $this; } public function getVariable($name, $default = null) { $name = (string) $name; if (array_key_exists($name, $this->variables)) { return $this->variables[$name]; } return $default; } public function setVariable($name, $value) { $this->variables[(string) $name] = $value; return $this; } public function setVariables($variables, $overwrite = false) { if (!is_array($variables) && !$variables instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '%s: expects an array, or Traversable argument; received "%s"', __METHOD__, (is_object($variables) ? get_class($variables) : gettype($variables)) )); } if ($overwrite) { if (is_object($variables) && !$variables instanceof ArrayAccess) { $variables = ArrayUtils::iteratorToArray($variables); } $this->variables = $variables; return $this; } foreach ($variables as $key => $value) { $this->setVariable($key, $value); } return $this; } public function getVariables() { return $this->variables; } public function clearVariables() { $this->variables = new ViewVariables(); return $this; } public function setTemplate($template) { $this->template = (string) $template; return $this; } public function getTemplate() { return $this->template; } public function addChild(ModelInterface $child, $captureTo = null, $append = null) { $this->children[] = $child; if (null !== $captureTo) { $child->setCaptureTo($captureTo); } if (null !== $append) { $child->setAppend($append); } return $this; } public function getChildren() { return $this->children; } public function hasChildren() { return (0 < count($this->children)); } public function clearChildren() { $this->children = array(); return $this; } public function setCaptureTo($capture) { $this->captureTo = (string) $capture; return $this; } public function captureTo() { return $this->captureTo; } public function setTerminal($terminate) { $this->terminate = (bool) $terminate; return $this; } public function terminate() { return $this->terminate; } public function setAppend($append) { $this->append = (bool) $append; return $this; } public function isAppend() { return $this->append; } public function count() { return count($this->children); } public function getIterator() { return new ArrayIterator($this->children); } } options['errorLevel'] = $errorLevel; } public function getErrorLevel() { if (array_key_exists('errorLevel', $this->options)) { return $this->options['errorLevel']; } } public function setResult($text) { $this->setVariable(self::RESULT, $text); return $this; } public function getResult() { return $this->getVariable(self::RESULT); } } renderer = $renderer; } public function attach(EventManagerInterface $events, $priority = 1) { $this->listeners[] = $events->attach(ViewEvent::EVENT_RENDERER, array($this, 'selectRenderer'), $priority); $this->listeners[] = $events->attach(ViewEvent::EVENT_RESPONSE, array($this, 'injectResponse'), $priority); } public function setCharset($charset) { $this->charset = (string) $charset; return $this; } public function getCharset() { return $this->charset; } public function selectRenderer(ViewEvent $e) { $model = $e->getModel(); if (!$model instanceof Model\JsonModel) { return; } return $this->renderer; } public function injectResponse(ViewEvent $e) { $renderer = $e->getRenderer(); if ($renderer !== $this->renderer) { return; } $result = $e->getResult(); if (!is_string($result)) { return; } $response = $e->getResponse(); $response->setContent($result); $headers = $response->getHeaders(); if ($this->renderer->hasJsonpCallback()) { $contentType = 'application/javascript'; } else { $contentType = 'application/json'; } $contentType .= '; charset=' . $this->charset; $headers->addHeaderLine('content-type', $contentType); if (in_array(strtoupper($this->charset), $this->multibyteCharsets)) { $headers->addHeaderLine('content-transfer-encoding', 'BINARY'); } } } renderer = $renderer; } public function attach(EventManagerInterface $events, $priority = 1) { $this->listeners[] = $events->attach(ViewEvent::EVENT_RENDERER, array($this, 'selectRenderer'), $priority); $this->listeners[] = $events->attach(ViewEvent::EVENT_RESPONSE, array($this, 'injectResponse'), $priority); } public function selectRenderer(ViewEvent $e) { $model = $e->getModel(); if (!$model instanceof Model\FeedModel) { return; } return $this->renderer; } public function injectResponse(ViewEvent $e) { $renderer = $e->getRenderer(); if ($renderer !== $this->renderer) { return; } $result = $e->getResult(); if (!is_string($result) && !$result instanceof Feed) { return; } if ($result instanceof Feed) { $result = $result->export($renderer->getFeedType()); } $feedType = $renderer->getFeedType(); $feedType = ('rss' == $feedType) ? 'application/rss+xml' : 'application/atom+xml'; $model = $e->getModel(); $charset = ''; if ($model instanceof Model\FeedModel) { $feed = $model->getFeed(); $charset = '; charset=' . $feed->getEncoding() . ';'; } $response = $e->getResponse(); $response->setContent($result); $headers = $response->getHeaders(); $headers->addHeaderLine('content-type', $feedType . $charset); } } renderer = $renderer; } public function getRenderer() { return $this->renderer; } public function setContentPlaceholders(array $contentPlaceholders) { $this->contentPlaceholders = $contentPlaceholders; return $this; } public function getContentPlaceholders() { return $this->contentPlaceholders; } public function attach(EventManagerInterface $events, $priority = 1) { $this->listeners[] = $events->attach(ViewEvent::EVENT_RENDERER, array($this, 'selectRenderer'), $priority); $this->listeners[] = $events->attach(ViewEvent::EVENT_RESPONSE, array($this, 'injectResponse'), $priority); } public function selectRenderer(ViewEvent $e) { return $this->renderer; } public function injectResponse(ViewEvent $e) { $renderer = $e->getRenderer(); if ($renderer !== $this->renderer) { return; } $result = $e->getResult(); $response = $e->getResponse(); if (empty($result)) { $placeholders = $renderer->plugin('placeholder'); foreach ($this->contentPlaceholders as $placeholder) { if ($placeholders->containerExists($placeholder)) { $result = (string) $placeholders->getContainer($placeholder); break; } } } $response->setContent($result); } } setOptions($options); } public function setOptions(array $options) { foreach ($options as $key => $value) { switch (strtolower($key)) { case 'strict_vars': $this->setStrictVars($value); break; default: $this[$key] = $value; break; } } return $this; } public function setStrictVars($flag) { $this->strictVars = (bool) $flag; return $this; } public function isStrict() { return $this->strictVars; } public function assign($spec) { if (is_object($spec)) { if (method_exists($spec, 'toArray')) { $spec = $spec->toArray(); } else { $spec = (array) $spec; } } if (!is_array($spec)) { throw new Exception\InvalidArgumentException(sprintf( 'assign() expects either an array or an object as an argument; received "%s"', gettype($spec) )); } foreach ($spec as $key => $value) { $this[$key] = $value; } return $this; } public function offsetGet($key) { if (!$this->offsetExists($key)) { if ($this->isStrict()) { trigger_error(sprintf( 'View variable "%s" does not exist', $key ), E_USER_NOTICE); } return null; } $return = parent::offsetGet($key); if (is_object($return) && is_callable($return)) { $return = call_user_func($return); } return $return; } public function clear() { $this->exchangeArray(array()); } } resolver = $resolver; } public function render($nameOrModel, $values = null) { if ($nameOrModel instanceof Model) { if (!$nameOrModel instanceof FeedModel) { $vars = $nameOrModel->getVariables(); $options = $nameOrModel->getOptions(); $type = $this->getFeedType(); if (isset($options['feed_type'])) { $type = $options['feed_type']; } else { $this->setFeedType($type); } $nameOrModel = new FeedModel($vars, array('feed_type' => $type)); } } elseif (is_string($nameOrModel)) { $nameOrModel = new FeedModel($values, (array) $nameOrModel); } else { throw new Exception\InvalidArgumentException(sprintf( '%s expects a ViewModel or a string feed type as the first argument; received "%s"', __METHOD__, (is_object($nameOrModel) ? get_class($nameOrModel) : gettype($nameOrModel)) )); } $feed = $nameOrModel->getFeed(); $type = $nameOrModel->getFeedType(); if (!$type) { $type = $this->getFeedType(); } else { $this->setFeedType($type); } return $feed->export($type); } public function setFeedType($feedType) { $feedType = strtolower($feedType); if (!in_array($feedType, array('rss', 'atom'))) { throw new Exception\InvalidArgumentException(sprintf( '%s expects a string of either "rss" or "atom"', __METHOD__ )); } $this->feedType = $feedType; return $this; } public function getFeedType() { return $this->feedType; } } resolver = $resolver; } public function setMergeUnnamedChildren($mergeUnnamedChildren) { $this->mergeUnnamedChildren = (bool) $mergeUnnamedChildren; return $this; } public function setJsonpCallback($callback) { $callback = (string) $callback; if (!empty($callback)) { $this->jsonpCallback = $callback; } return $this; } public function hasJsonpCallback() { return (null !== $this->jsonpCallback); } public function mergeUnnamedChildren() { return $this->mergeUnnamedChildren; } public function render($nameOrModel, $values = null) { if ($nameOrModel instanceof Model) { if ($nameOrModel instanceof JsonModel) { $children = $this->recurseModel($nameOrModel, false); $this->injectChildren($nameOrModel, $children); $values = $nameOrModel->serialize(); } else { $values = $this->recurseModel($nameOrModel); $values = Json::encode($values); } if ($this->hasJsonpCallback()) { $values = $this->jsonpCallback . '(' . $values . ');'; } return $values; } if (null === $values) { if (!is_object($nameOrModel) || $nameOrModel instanceof JsonSerializable) { $return = Json::encode($nameOrModel); } elseif ($nameOrModel instanceof Traversable) { $nameOrModel = ArrayUtils::iteratorToArray($nameOrModel); $return = Json::encode($nameOrModel); } else { $return = Json::encode(get_object_vars($nameOrModel)); } if ($this->hasJsonpCallback()) { $return = $this->jsonpCallback . '(' . $return . ');'; } return $return; } throw new Exception\DomainException(sprintf( '%s: Do not know how to handle operation when both $nameOrModel and $values are populated', __METHOD__ )); } public function canRenderTrees() { return true; } protected function recurseModel(Model $model, $mergeWithVariables = true) { $values = array(); if ($mergeWithVariables) { $values = $model->getVariables(); } if ($values instanceof Traversable) { $values = ArrayUtils::iteratorToArray($values); } if (!$model->hasChildren()) { return $values; } $mergeChildren = $this->mergeUnnamedChildren(); foreach ($model as $child) { $captureTo = $child->captureTo(); if (!$captureTo && !$mergeChildren) { continue; } $childValues = $this->recurseModel($child); if ($captureTo) { $values[$captureTo] = $childValues; } elseif ($mergeChildren) { $values = array_replace_recursive($values, $childValues); } } return $values; } protected function injectChildren(Model $model, array $children) { foreach ($children as $child => $value) { $model->setVariable($child, $value); } } } init(); } public function setResolver(ResolverInterface $resolver) { return $this; } public function getEngine() { return $this; } public function init() { } public function setFilterChain(FilterChain $filters) { $this->__filterChain = $filters; return $this; } public function getFilterChain() { if (null === $this->__filterChain) { $this->setFilterChain(new FilterChain()); } return $this->__filterChain; } public function render($model, $values = null) { if (!$model instanceof ModelInterface) { return ''; } $result = ''; $options = $model->getOptions(); foreach ($options as $setting => $value) { $method = 'set' . $setting; if (method_exists($this, $method)) { $this->$method($value); } unset($method, $setting, $value); } unset($options); $values = $model->getVariables(); if (isset($values['result'])) { $result .= $this->getFilterChain()->filter($values['result']); } if ($model->hasChildren()) { foreach ($model->getChildren() as $child) { $result .= $this->render($child, $values); } } return $result; } public function canRenderTrees() { return true; } } init(); } public function getEngine() { return $this; } public function init() { } public function setResolver(Resolver $resolver) { $this->__templateResolver = $resolver; return $this; } public function resolver($name = null) { if (null === $this->__templateResolver) { $this->setResolver(new TemplatePathStack()); } if (null !== $name) { return $this->__templateResolver->resolve($name, $this); } return $this->__templateResolver; } public function setVars($variables) { if (!is_array($variables) && !$variables instanceof ArrayAccess) { throw new Exception\InvalidArgumentException(sprintf( 'Expected array or ArrayAccess object; received "%s"', (is_object($variables) ? get_class($variables) : gettype($variables)) )); } if (!$variables instanceof Variables) { $variablesAsArray = array(); foreach ($variables as $key => $value) { $variablesAsArray[$key] = $value; } $variables = new Variables($variablesAsArray); } $this->__vars = $variables; return $this; } public function vars($key = null) { if (null === $this->__vars) { $this->setVars(new Variables()); } if (null === $key) { return $this->__vars; } return $this->__vars[$key]; } public function get($key) { if (null === $this->__vars) { $this->setVars(new Variables()); } return $this->__vars[$key]; } public function __get($name) { $vars = $this->vars(); return $vars[$name]; } public function __set($name, $value) { $vars = $this->vars(); $vars[$name] = $value; } public function __isset($name) { $vars = $this->vars(); return isset($vars[$name]); } public function __unset($name) { $vars = $this->vars(); if (!isset($vars[$name])) { return; } unset($vars[$name]); } public function setHelperPluginManager($helpers) { if (is_string($helpers)) { if (!class_exists($helpers)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid helper helpers class provided (%s)', $helpers )); } $helpers = new $helpers(); } if (!$helpers instanceof HelperPluginManager) { throw new Exception\InvalidArgumentException(sprintf( 'Helper helpers must extend Zend\View\HelperPluginManager; got type "%s" instead', (is_object($helpers) ? get_class($helpers) : gettype($helpers)) )); } $helpers->setRenderer($this); $this->__helpers = $helpers; return $this; } public function getHelperPluginManager() { if (null === $this->__helpers) { $this->setHelperPluginManager(new HelperPluginManager()); } return $this->__helpers; } public function plugin($name, array $options = null) { return $this->getHelperPluginManager()->get($name, $options); } public function __call($method, $argv) { if (!isset($this->__pluginCache[$method])) { $this->__pluginCache[$method] = $this->plugin($method); } if (is_callable($this->__pluginCache[$method])) { return call_user_func_array($this->__pluginCache[$method], $argv); } return $this->__pluginCache[$method]; } public function setFilterChain(FilterChain $filters) { $this->__filterChain = $filters; return $this; } public function getFilterChain() { if (null === $this->__filterChain) { $this->setFilterChain(new FilterChain()); } return $this->__filterChain; } public function render($nameOrModel, $values = null) { if ($nameOrModel instanceof Model) { $model = $nameOrModel; $nameOrModel = $model->getTemplate(); if (empty($nameOrModel)) { throw new Exception\DomainException(sprintf( '%s: received View Model argument, but template is empty', __METHOD__ )); } $options = $model->getOptions(); foreach ($options as $setting => $value) { $method = 'set' . $setting; if (method_exists($this, $method)) { $this->$method($value); } unset($method, $setting, $value); } unset($options); $helper = $this->plugin('view_model'); $helper->setCurrent($model); $values = $model->getVariables(); unset($model); } $this->addTemplate($nameOrModel); unset($nameOrModel); $this->__varsCache[] = $this->vars(); if (null !== $values) { $this->setVars($values); } unset($values); $__vars = $this->vars()->getArrayCopy(); if (array_key_exists('this', $__vars)) { unset($__vars['this']); } extract($__vars); unset($__vars); while ($this->__template = array_pop($this->__templates)) { $this->__file = $this->resolver($this->__template); if (!$this->__file) { throw new Exception\RuntimeException(sprintf( '%s: Unable to render template "%s"; resolver could not resolve to a file', __METHOD__, $this->__template )); } try { ob_start(); include $this->__file; $this->__content = ob_get_clean(); } catch (\Exception $ex) { ob_end_clean(); throw $ex; } } $this->setVars(array_pop($this->__varsCache)); return $this->getFilterChain()->filter($this->__content); } public function setCanRenderTrees($renderTrees) { $this->__renderTrees = (bool) $renderTrees; return $this; } public function canRenderTrees() { return $this->__renderTrees; } public function addTemplate($template) { $this->__templates[] = $template; return $this; } public function __clone() { $this->__vars = clone $this->vars(); } } queue = new PriorityQueue(); } public function count() { return $this->queue->count(); } public function getIterator() { return $this->queue; } public function attach(Resolver $resolver, $priority = 1) { $this->queue->insert($resolver, $priority); return $this; } public function resolve($name, Renderer $renderer = null) { $this->lastLookupFailure = false; $this->lastSuccessfulResolver = null; if (0 === count($this->queue)) { $this->lastLookupFailure = static::FAILURE_NO_RESOLVERS; return false; } foreach ($this->queue as $resolver) { $resource = $resolver->resolve($name, $renderer); if (!$resource) { continue; } $this->lastSuccessfulResolver = $resolver; return $resource; } $this->lastLookupFailure = static::FAILURE_NOT_FOUND; return false; } public function getLastSuccessfulResolver() { return $this->lastSuccessfulResolver; } public function getLastLookupFailure() { return $this->lastLookupFailure; } } useViewStream = (bool) ini_get('short_open_tag'); if ($this->useViewStream) { if (!in_array('zend.view', stream_get_wrappers())) { stream_wrapper_register('zend.view', 'Zend\View\Stream'); } } $this->paths = new SplStack; if (null !== $options) { $this->setOptions($options); } } public function setOptions($options) { if (!is_array($options) && !$options instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( 'Expected array or Traversable object; received "%s"', (is_object($options) ? get_class($options) : gettype($options)) )); } foreach ($options as $key => $value) { switch (strtolower($key)) { case 'lfi_protection': $this->setLfiProtection($value); break; case 'script_paths': $this->addPaths($value); break; case 'use_stream_wrapper': $this->setUseStreamWrapper($value); break; case 'default_suffix': $this->setDefaultSuffix($value); break; default: break; } } } public function setDefaultSuffix($defaultSuffix) { $this->defaultSuffix = (string) $defaultSuffix; $this->defaultSuffix = ltrim($this->defaultSuffix, '.'); return $this; } public function getDefaultSuffix() { return $this->defaultSuffix; } public function addPaths(array $paths) { foreach ($paths as $path) { $this->addPath($path); } return $this; } public function setPaths($paths) { if ($paths instanceof SplStack) { $this->paths = $paths; } elseif (is_array($paths)) { $this->clearPaths(); $this->addPaths($paths); } else { throw new Exception\InvalidArgumentException( "Invalid argument provided for \$paths, expecting either an array or SplStack object" ); } return $this; } public static function normalizePath($path) { $path = rtrim($path, '/'); $path = rtrim($path, '\\'); $path .= DIRECTORY_SEPARATOR; return $path; } public function addPath($path) { if (!is_string($path)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid path provided; must be a string, received %s', gettype($path) )); } $this->paths[] = static::normalizePath($path); return $this; } public function clearPaths() { $this->paths = new SplStack; } public function getPaths() { return $this->paths; } public function setLfiProtection($flag) { $this->lfiProtectionOn = (bool) $flag; return $this; } public function isLfiProtectionOn() { return $this->lfiProtectionOn; } public function setUseStreamWrapper($flag) { $this->useStreamWrapper = (bool) $flag; return $this; } public function useStreamWrapper() { return ($this->useViewStream && $this->useStreamWrapper); } public function resolve($name, Renderer $renderer = null) { $this->lastLookupFailure = false; if ($this->isLfiProtectionOn() && preg_match('#\.\.[\\\/]#', $name)) { throw new Exception\DomainException( 'Requested scripts may not include parent directory traversal ("../", "..\\" notation)' ); } if (!count($this->paths)) { $this->lastLookupFailure = static::FAILURE_NO_PATHS; return false; } $defaultSuffix = $this->getDefaultSuffix(); if (pathinfo($name, PATHINFO_EXTENSION) == '') { $name .= '.' . $defaultSuffix; } foreach ($this->paths as $path) { $file = new SplFileInfo($path . $name); if ($file->isReadable()) { if (($filePath = $file->getRealPath()) === false && substr($path, 0, 7) === 'phar://') { $filePath = $path . $name; if (!file_exists($filePath)) { break; } } if ($this->useStreamWrapper()) { $filePath = 'zend.view://' . $filePath; } return $filePath; } } $this->lastLookupFailure = static::FAILURE_NOT_FOUND; return false; } public function getLastLookupFailure() { return $this->lastLookupFailure; } } setMap($map); } public function getIterator() { return new ArrayIterator($this->map); } public function setMap($map) { if (!is_array($map) && !$map instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '%s: expects an array or Traversable, received "%s"', __METHOD__, (is_object($map) ? get_class($map) : gettype($map)) )); } if ($map instanceof Traversable) { $map = ArrayUtils::iteratorToArray($map); } $this->map = $map; return $this; } public function add($nameOrMap, $path = null) { if (is_array($nameOrMap) || $nameOrMap instanceof Traversable) { $this->merge($nameOrMap); return $this; } if (!is_string($nameOrMap)) { throw new Exception\InvalidArgumentException(sprintf( '%s: expects a string, array, or Traversable for the first argument; received "%s"', __METHOD__, (is_object($nameOrMap) ? get_class($nameOrMap) : gettype($nameOrMap)) )); } if (empty($path)) { if (isset($this->map[$nameOrMap])) { unset($this->map[$nameOrMap]); } return $this; } $this->map[$nameOrMap] = $path; return $this; } public function merge($map) { if (!is_array($map) && !$map instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '%s: expects an array or Traversable, received "%s"', __METHOD__, (is_object($map) ? get_class($map) : gettype($map)) )); } if ($map instanceof Traversable) { $map = ArrayUtils::iteratorToArray($map); } $this->map = array_replace_recursive($this->map, $map); return $this; } public function has($name) { return array_key_exists($name, $this->map); } public function get($name) { if (!$this->has($name)) { return false; } return $this->map[$name]; } public function getMap() { return $this->map; } public function resolve($name, Renderer $renderer = null) { return $this->get($name); } } request = $request; return $this; } public function setResponse(Response $response) { $this->response = $response; return $this; } public function getRequest() { return $this->request; } public function getResponse() { return $this->response; } public function setEventManager(EventManagerInterface $events) { $events->setIdentifiers(array( __CLASS__, get_class($this), )); $this->events = $events; return $this; } public function getEventManager() { if (!$this->events instanceof EventManagerInterface) { $this->setEventManager(new EventManager()); } return $this->events; } public function addRenderingStrategy($callable, $priority = 1) { $this->getEventManager()->attach(ViewEvent::EVENT_RENDERER, $callable, $priority); return $this; } public function addResponseStrategy($callable, $priority = 1) { $this->getEventManager()->attach(ViewEvent::EVENT_RESPONSE, $callable, $priority); return $this; } public function render(Model $model) { $event = $this->getEvent(); $event->setModel($model); $events = $this->getEventManager(); $results = $events->trigger(ViewEvent::EVENT_RENDERER, $event, function ($result) { return ($result instanceof Renderer); }); $renderer = $results->last(); if (!$renderer instanceof Renderer) { throw new Exception\RuntimeException(sprintf( '%s: no renderer selected!', __METHOD__ )); } $event->setRenderer($renderer); $results = $events->trigger(ViewEvent::EVENT_RENDERER_POST, $event); $model = $event->getModel(); if ($model->hasChildren() && (!$renderer instanceof TreeRendererInterface || !$renderer->canRenderTrees()) ) { $this->renderChildren($model); } $event->setModel($model); $event->setRenderer($renderer); $rendered = $renderer->render($model); $options = $model->getOptions(); if (array_key_exists('has_parent', $options) && $options['has_parent']) { return $rendered; } $event->setResult($rendered); $events->trigger(ViewEvent::EVENT_RESPONSE, $event); } protected function renderChildren(Model $model) { foreach ($model as $child) { if ($child->terminate()) { throw new Exception\DomainException('Inconsistent state; child view model is marked as terminal'); } $child->setOption('has_parent', true); $result = $this->render($child); $child->setOption('has_parent', null); $capture = $child->captureTo(); if (!empty($capture)) { if ($child->isAppend()) { $oldResult=$model->{$capture}; $model->setVariable($capture, $oldResult . $result); } else { $model->setVariable($capture, $result); } } } } protected function getEvent() { $event = new ViewEvent(); $event->setTarget($this); if (null !== ($request = $this->getRequest())) { $event->setRequest($request); } if (null !== ($response = $this->getResponse())) { $event->setResponse($response); } return $event; } } data = file_get_contents($path); if ($this->data === false) { $this->stat = stat($path); return false; } $this->data = preg_replace('/\<\?\=/', "data); $this->data = preg_replace('/<\?(?!xml|php)/s', 'data); $this->stat = stat($path); return true; } public function url_stat() { return $this->stat; } public function stream_read($count) { $ret = substr($this->data, $this->pos, $count); $this->pos += strlen($ret); return $ret; } public function stream_tell() { return $this->pos; } public function stream_eof() { return $this->pos >= strlen($this->data); } public function stream_stat() { return $this->stat; } public function stream_seek($offset, $whence) { switch ($whence) { case SEEK_SET: if ($offset < strlen($this->data) && $offset >= 0) { $this->pos = $offset; return true; } else { return false; } break; case SEEK_CUR: if ($offset >= 0) { $this->pos += $offset; return true; } else { return false; } break; case SEEK_END: if (strlen($this->data) + $offset >= 0) { $this->pos = strlen($this->data) + $offset; return true; } else { return false; } break; default: return false; } } } 'Zend\I18n\Filter\Alnum', 'alpha' => 'Zend\I18n\Filter\Alpha', 'basename' => 'Zend\Filter\BaseName', 'boolean' => 'Zend\Filter\Boolean', 'callback' => 'Zend\Filter\Callback', 'compress' => 'Zend\Filter\Compress', 'compressbz2' => 'Zend\Filter\Compress\Bz2', 'compressgz' => 'Zend\Filter\Compress\Gz', 'compresslzf' => 'Zend\Filter\Compress\Lzf', 'compressrar' => 'Zend\Filter\Compress\Rar', 'compresssnappy' => 'Zend\Filter\Compress\Snappy', 'compresstar' => 'Zend\Filter\Compress\Tar', 'compresszip' => 'Zend\Filter\Compress\Zip', 'datetimeformatter' => 'Zend\Filter\DateTimeFormatter', 'decompress' => 'Zend\Filter\Decompress', 'decrypt' => 'Zend\Filter\Decrypt', 'digits' => 'Zend\Filter\Digits', 'dir' => 'Zend\Filter\Dir', 'encrypt' => 'Zend\Filter\Encrypt', 'encryptblockcipher' => 'Zend\Filter\Encrypt\BlockCipher', 'encryptopenssl' => 'Zend\Filter\Encrypt\Openssl', 'filedecrypt' => 'Zend\Filter\File\Decrypt', 'fileencrypt' => 'Zend\Filter\File\Encrypt', 'filelowercase' => 'Zend\Filter\File\LowerCase', 'filerename' => 'Zend\Filter\File\Rename', 'filerenameupload' => 'Zend\Filter\File\RenameUpload', 'fileuppercase' => 'Zend\Filter\File\UpperCase', 'htmlentities' => 'Zend\Filter\HtmlEntities', 'inflector' => 'Zend\Filter\Inflector', 'int' => 'Zend\Filter\Int', 'null' => 'Zend\Filter\Null', 'numberformat' => 'Zend\I18n\Filter\NumberFormat', 'pregreplace' => 'Zend\Filter\PregReplace', 'realpath' => 'Zend\Filter\RealPath', 'stringtolower' => 'Zend\Filter\StringToLower', 'stringtoupper' => 'Zend\Filter\StringToUpper', 'stringtrim' => 'Zend\Filter\StringTrim', 'stripnewlines' => 'Zend\Filter\StripNewlines', 'striptags' => 'Zend\Filter\StripTags', 'urinormalize' => 'Zend\Filter\UriNormalize', 'wordcamelcasetodash' => 'Zend\Filter\Word\CamelCaseToDash', 'wordcamelcasetoseparator' => 'Zend\Filter\Word\CamelCaseToSeparator', 'wordcamelcasetounderscore' => 'Zend\Filter\Word\CamelCaseToUnderscore', 'worddashtocamelcase' => 'Zend\Filter\Word\DashToCamelCase', 'worddashtoseparator' => 'Zend\Filter\Word\DashToSeparator', 'worddashtounderscore' => 'Zend\Filter\Word\DashToUnderscore', 'wordseparatortocamelcase' => 'Zend\Filter\Word\SeparatorToCamelCase', 'wordseparatortodash' => 'Zend\Filter\Word\SeparatorToDash', 'wordseparatortoseparator' => 'Zend\Filter\Word\SeparatorToSeparator', 'wordunderscoretocamelcase' => 'Zend\Filter\Word\UnderscoreToCamelCase', 'wordunderscoretodash' => 'Zend\Filter\Word\UnderscoreToDash', 'wordunderscoretoseparator' => 'Zend\Filter\Word\UnderscoreToSeparator', ); protected $shareByDefault = false; public function validatePlugin($plugin) { if ($plugin instanceof FilterInterface) { return; } if (is_callable($plugin)) { return; } throw new Exception\RuntimeException(sprintf( 'Plugin of type %s is invalid; must implement %s\FilterInterface or be callable', (is_object($plugin) ? get_class($plugin) : gettype($plugin)), __NAMESPACE__ )); } } setQuoteStyle($options['quotestyle']); $this->setEncoding($options['encoding']); $this->setDoubleQuote($options['doublequote']); } public function getQuoteStyle() { return $this->quoteStyle; } public function setQuoteStyle($quoteStyle) { $this->quoteStyle = $quoteStyle; return $this; } public function getEncoding() { return $this->encoding; } public function setEncoding($value) { $this->encoding = (string) $value; return $this; } public function getCharSet() { return $this->getEncoding(); } public function setCharSet($charSet) { return $this->setEncoding($charSet); } public function getDoubleQuote() { return $this->doubleQuote; } public function setDoubleQuote($doubleQuote) { $this->doubleQuote = (bool) $doubleQuote; return $this; } public function filter($value) { if (null === $value) { return null; } if (!is_scalar($value)){ trigger_error( sprintf( '%s expects parameter to be scalar, "%s" given; cannot filter', __METHOD__, (is_object($value) ? get_class($value) : gettype($value)) ), E_USER_WARNING ); return $value; } $filtered = htmlentities((string) $value, $this->getQuoteStyle(), $this->getEncoding(), $this->getDoubleQuote()); if (strlen((string) $value) && !strlen($filtered)) { if (!function_exists('iconv')) { throw new Exception\DomainException('Encoding mismatch has resulted in htmlentities errors'); } $enc = $this->getEncoding(); $value = iconv('', $this->getEncoding() . '//IGNORE', (string) $value); $filtered = htmlentities($value, $this->getQuoteStyle(), $enc, $this->getDoubleQuote()); if (!strlen($filtered)) { throw new Exception\DomainException('Encoding mismatch has resulted in htmlentities errors'); } } return $filtered; } } 'boolean', self::TYPE_INTEGER => 'integer', self::TYPE_EMPTY_ARRAY => 'array', self::TYPE_STRING => 'string', self::TYPE_ZERO_STRING => 'zero', self::TYPE_FLOAT => 'float', self::TYPE_ALL => 'all', ); protected $options = array( 'type' => self::TYPE_ALL, ); public function __construct($typeOrOptions = null) { if ($typeOrOptions !== null) { if ($typeOrOptions instanceof Traversable) { $typeOrOptions = iterator_to_array($typeOrOptions); } if (is_array($typeOrOptions)) { if (isset($typeOrOptions['type'])) { $this->setOptions($typeOrOptions); } else { $this->setType($typeOrOptions); } } else { $this->setType($typeOrOptions); } } } public function setType($type = null) { if (is_array($type)) { $detected = 0; foreach ($type as $value) { if (is_int($value)) { $detected += $value; } elseif (in_array($value, $this->constants)) { $detected += array_search($value, $this->constants); } } $type = $detected; } elseif (is_string($type) && in_array($type, $this->constants)) { $type = array_search($type, $this->constants); } if (!is_int($type) || ($type < 0) || ($type > self::TYPE_ALL)) { throw new Exception\InvalidArgumentException(sprintf( 'Unknown type value "%s" (%s)', $type, gettype($type) )); } $this->options['type'] = $type; return $this; } public function getType() { return $this->options['type']; } public function filter($value) { $type = $this->getType(); if ($type >= self::TYPE_FLOAT) { $type -= self::TYPE_FLOAT; if (is_float($value) && ($value == 0.0)) { return null; } } if ($type >= self::TYPE_ZERO_STRING) { $type -= self::TYPE_ZERO_STRING; if (is_string($value) && ($value == '0')) { return null; } } if ($type >= self::TYPE_STRING) { $type -= self::TYPE_STRING; if (is_string($value) && ($value == '')) { return null; } } if ($type >= self::TYPE_EMPTY_ARRAY) { $type -= self::TYPE_EMPTY_ARRAY; if (is_array($value) && ($value == array())) { return null; } } if ($type >= self::TYPE_INTEGER) { $type -= self::TYPE_INTEGER; if (is_int($value) && ($value == 0)) { return null; } } if ($type >= self::TYPE_BOOLEAN) { $type -= self::TYPE_BOOLEAN; if (is_bool($value) && ($value == false)) { return null; } } return $value; } } null, 'callback_params' => array() ); public function __construct($callbackOrOptions, $callbackParams = array()) { if (is_callable($callbackOrOptions)) { $this->setCallback($callbackOrOptions); $this->setCallbackParams($callbackParams); } else { $this->setOptions($callbackOrOptions); } } public function setCallback($callback) { if (!is_callable($callback)) { throw new Exception\InvalidArgumentException( 'Invalid parameter for callback: must be callable' ); } $this->options['callback'] = $callback; return $this; } public function getCallback() { return $this->options['callback']; } public function setCallbackParams($params) { $this->options['callback_params'] = (array) $params; return $this; } public function getCallbackParams() { return $this->options['callback_params']; } public function filter($value) { $params = (array) $this->options['callback_params']; array_unshift($params, $value); return call_user_func_array($this->options['callback'], $params); } } null, ); public function __construct($charlistOrOptions = null) { if ($charlistOrOptions !== null) { if (!is_array($charlistOrOptions) && !$charlistOrOptions instanceof Traversable) { $this->setCharList($charlistOrOptions); } else { $this->setOptions($charlistOrOptions); } } } public function setCharList($charList) { if (empty($charList)) { $charList = null; } $this->options['charlist'] = $charList; return $this; } public function getCharList() { return $this->options['charlist']; } public function filter($value) { if (!is_string($value)) { return $value; } if (null === $this->options['charlist']) { return $this->unicodeTrim((string) $value); } return $this->unicodeTrim((string) $value, $this->options['charlist']); } protected function unicodeTrim($value, $charlist = '\\\\s') { $chars = preg_replace( array('/[\^\-\]\\\]/S', '/\\\{4}/S', '/\//'), array('\\\\\\0', '\\', '\/'), $charlist ); $pattern = '/^[' . $chars . ']+|[' . $chars . ']+$/usSD'; return preg_replace($pattern, '', $value); } } null, ); public function __construct($encodingOrOptions = null) { if ($encodingOrOptions !== null) { if (!static::isOptions($encodingOrOptions)) { $this->setEncoding($encodingOrOptions); } else { $this->setOptions($encodingOrOptions); } } } public function filter($value) { if (null === $value) { return null; } if (!is_scalar($value)){ trigger_error( sprintf( '%s expects parameter to be scalar, "%s" given; cannot filter', __METHOD__, (is_object($value) ? get_class($value) : gettype($value)) ), E_USER_WARNING ); return $value; } if ($this->options['encoding'] !== null) { return mb_strtoupper((string) $value, $this->options['encoding']); } return strtoupper((string) $value); } } setOptions($options); } } public function setDefaultScheme($defaultScheme) { $this->defaultScheme = $defaultScheme; return $this; } public function setEnforcedScheme($enforcedScheme) { $this->enforcedScheme = $enforcedScheme; return $this; } public function filter($value) { $defaultScheme = $this->defaultScheme ?: $this->enforcedScheme; if (!UriFactory::getRegisteredSchemeClass($defaultScheme)) { $defaultScheme = null; } try { $uri = UriFactory::factory($value, $defaultScheme); if ($this->enforcedScheme && (!$uri->getScheme())) { $this->enforceScheme($uri); } } catch (UriException $ex) { return $value; } $uri->normalize(); if (!$uri->isValid()) { return $value; } return $uri->toString(); } protected function enforceScheme(Uri $uri) { $path = $uri->getPath(); if (strpos($path, '/') !== false) { list($host, $path) = explode('/', $path, 2); $path = '/' . $path; } else { $host = $path; $path = ''; } if (!$host) { return; } $uri->setScheme($this->enforcedScheme) ->setHost($host) ->setPath($path); } } $value) { $setter = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))); if (method_exists($this, $setter)) { $this->{$setter}($value); } elseif (array_key_exists($key, $this->options)) { $this->options[$key] = $value; } else { throw new Exception\InvalidArgumentException(sprintf( 'The option "%s" does not have a matching %s setter method or options[%s] array key', $key, $setter, $key )); } } return $this; } public function getOptions() { return $this->options; } public function __invoke($value) { return $this->filter($value); } protected static function isOptions($options) { return (is_array($options) || $options instanceof Traversable); } } setOptions($options); } } public function setFormat($format) { $this->format = $format; return $this; } public function filter($value) { try { $result = $this->normalizeDateTime($value); } catch (\Exception $e) { throw new Exception\InvalidArgumentException('Invalid date string provided', $e->getCode(), $e); } return $result; } protected function normalizeDateTime($value) { if ($value === '' || $value === null) { return $value; } elseif (is_int($value)) { $value = new DateTime('@' . $value); } elseif (!$value instanceof DateTime) { $value = new DateTime($value); } return $value->format($this->format); } } array(), 'private' => array(), 'envelope' => array(), ); protected $passphrase; protected $compression; protected $package = false; public function __construct($options = array()) { if (!extension_loaded('openssl')) { throw new Exception\ExtensionNotLoadedException('This filter needs the openssl extension'); } if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } if (!is_array($options)) { $options = array('public' => $options); } if (array_key_exists('passphrase', $options)) { $this->setPassphrase($options['passphrase']); unset($options['passphrase']); } if (array_key_exists('compression', $options)) { $this->setCompression($options['compression']); unset($options['compress']); } if (array_key_exists('package', $options)) { $this->setPackage($options['package']); unset($options['package']); } $this->_setKeys($options); } protected function _setKeys($keys) { if (!is_array($keys)) { throw new Exception\InvalidArgumentException('Invalid options argument provided to filter'); } foreach ($keys as $type => $key) { if (is_file($key) and is_readable($key)) { $file = fopen($key, 'r'); $cert = fread($file, 8192); fclose($file); } else { $cert = $key; $key = count($this->keys[$type]); } switch ($type) { case 'public': $test = openssl_pkey_get_public($cert); if ($test === false) { throw new Exception\InvalidArgumentException("Public key '{$cert}' not valid"); } openssl_free_key($test); $this->keys['public'][$key] = $cert; break; case 'private': $test = openssl_pkey_get_private($cert, $this->passphrase); if ($test === false) { throw new Exception\InvalidArgumentException("Private key '{$cert}' not valid"); } openssl_free_key($test); $this->keys['private'][$key] = $cert; break; case 'envelope': $this->keys['envelope'][$key] = $cert; break; default: break; } } return $this; } public function getPublicKey() { $key = $this->keys['public']; return $key; } public function setPublicKey($key) { if (is_array($key)) { foreach ($key as $type => $option) { if ($type !== 'public') { $key['public'] = $option; unset($key[$type]); } } } else { $key = array('public' => $key); } return $this->_setKeys($key); } public function getPrivateKey() { $key = $this->keys['private']; return $key; } public function setPrivateKey($key, $passphrase = null) { if (is_array($key)) { foreach ($key as $type => $option) { if ($type !== 'private') { $key['private'] = $option; unset($key[$type]); } } } else { $key = array('private' => $key); } if ($passphrase !== null) { $this->setPassphrase($passphrase); } return $this->_setKeys($key); } public function getEnvelopeKey() { $key = $this->keys['envelope']; return $key; } public function setEnvelopeKey($key) { if (is_array($key)) { foreach ($key as $type => $option) { if ($type !== 'envelope') { $key['envelope'] = $option; unset($key[$type]); } } } else { $key = array('envelope' => $key); } return $this->_setKeys($key); } public function getPassphrase() { return $this->passphrase; } public function setPassphrase($passphrase) { $this->passphrase = $passphrase; return $this; } public function getCompression() { return $this->compression; } public function setCompression($compression) { if (is_string($this->compression)) { $compression = array('adapter' => $compression); } $this->compression = $compression; return $this; } public function getPackage() { return $this->package; } public function setPackage($package) { $this->package = (bool) $package; return $this; } public function encrypt($value) { $encrypted = array(); $encryptedkeys = array(); if (count($this->keys['public']) == 0) { throw new Exception\RuntimeException('Openssl can not encrypt without public keys'); } $keys = array(); $fingerprints = array(); $count = -1; foreach ($this->keys['public'] as $key => $cert) { $keys[$key] = openssl_pkey_get_public($cert); if ($this->package) { $details = openssl_pkey_get_details($keys[$key]); if ($details === false) { $details = array('key' => 'ZendFramework'); } ++$count; $fingerprints[$count] = md5($details['key']); } } if (!empty($this->compression)) { $compress = new Compress($this->compression); $value = $compress($value); } $crypt = openssl_seal($value, $encrypted, $encryptedkeys, $keys); foreach ($keys as $key) { openssl_free_key($key); } if ($crypt === false) { throw new Exception\RuntimeException('Openssl was not able to encrypt your content with the given options'); } $this->keys['envelope'] = $encryptedkeys; if ($this->package) { $header = pack('n', count($this->keys['envelope'])); foreach ($this->keys['envelope'] as $key => $envKey) { $header .= pack('H32n', $fingerprints[$key], strlen($envKey)) . $envKey; } $encrypted = $header . $encrypted; } return $encrypted; } public function decrypt($value) { $decrypted = ""; $envelope = current($this->getEnvelopeKey()); if (count($this->keys['private']) !== 1) { throw new Exception\RuntimeException('Please give a private key for decryption with Openssl'); } if (!$this->package && empty($envelope)) { throw new Exception\RuntimeException('Please give an envelope key for decryption with Openssl'); } foreach ($this->keys['private'] as $cert) { $keys = openssl_pkey_get_private($cert, $this->getPassphrase()); } if ($this->package) { $details = openssl_pkey_get_details($keys); if ($details !== false) { $fingerprint = md5($details['key']); } else { $fingerprint = md5("ZendFramework"); } $count = unpack('ncount', $value); $count = $count['count']; $length = 2; for ($i = $count; $i > 0; --$i) { $header = unpack('H32print/nsize', substr($value, $length, 18)); $length += 18; if ($header['print'] == $fingerprint) { $envelope = substr($value, $length, $header['size']); } $length += $header['size']; } $value = substr($value, $length); } $crypt = openssl_open($value, $decrypted, $envelope, $keys); openssl_free_key($keys); if ($crypt === false) { throw new Exception\RuntimeException('Openssl was not able to decrypt you content with the given options'); } if (!empty($this->compression)) { $decompress = new Decompress($this->compression); $decrypted = $decompress($decrypted); } return $decrypted; } public function toString() { return 'Openssl'; } } 5000, 'algorithm' => 'aes', 'hash' => 'sha256', ); protected $blockCipher; protected $compression; public function __construct($options) { try { $this->blockCipher = CryptBlockCipher::factory('mcrypt', $this->encryption); } catch (SymmetricException\RuntimeException $e) { throw new Exception\RuntimeException('The BlockCipher cannot be used without the Mcrypt extension'); } if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (is_string($options)) { $options = array('key' => $options); } elseif (!is_array($options)) { throw new Exception\InvalidArgumentException('Invalid options argument provided to filter'); } if (array_key_exists('compression', $options)) { $this->setCompression($options['compression']); unset($options['compress']); } $this->setEncryption($options); } public function getEncryption() { return $this->encryption; } public function setEncryption($options) { if (is_string($options)) { $this->blockCipher->setKey($options); $this->encryption['key'] = $options; return $this; } if (!is_array($options)) { throw new Exception\InvalidArgumentException('Invalid options argument provided to filter'); } $options = $options + $this->encryption; if (isset($options['key'])) { $this->blockCipher->setKey($options['key']); } if (isset($options['algorithm'])) { try { $this->blockCipher->setCipherAlgorithm($options['algorithm']); } catch (CryptException\InvalidArgumentException $e) { throw new Exception\InvalidArgumentException("The algorithm '{$options['algorithm']}' is not supported"); } } if (isset($options['hash'])) { try { $this->blockCipher->setHashAlgorithm($options['hash']); } catch (CryptException\InvalidArgumentException $e) { throw new Exception\InvalidArgumentException("The algorithm '{$options['hash']}' is not supported"); } } if (isset($options['vector'])) { $this->setVector($options['vector']); } if (isset($options['key_iteration'])) { $this->blockCipher->setKeyIteration($options['key_iteration']); } $this->encryption = $options; return $this; } public function getVector() { return $this->encryption['vector']; } public function setVector($vector) { try { $this->blockCipher->setSalt($vector); } catch (CryptException\InvalidArgumentException $e) { throw new Exception\InvalidArgumentException($e->getMessage()); } $this->encryption['vector'] = $vector; return $this; } public function setKey($key) { try { $this->blockCipher->setKey($key); } catch (CryptException\InvalidArgumentException $e) { throw new Exception\InvalidArgumentException($e->getMessage()); } $this->encryption['key'] = $key; return $this; } public function getKey() { return $this->encryption['key']; } public function getCompression() { return $this->compression; } public function setCompression($compression) { if (is_string($this->compression)) { $compression = array('adapter' => $compression); } $this->compression = $compression; return $this; } public function encrypt($value) { if (!empty($this->compression)) { $compress = new Compress($this->compression); $value = $compress($value); } try { $encrypted = $this->blockCipher->encrypt($value); } catch (CryptException\InvalidArgumentException $e) { throw new Exception\InvalidArgumentException($e->getMessage()); } return $encrypted; } public function decrypt($value) { $decrypted = $this->blockCipher->decrypt($value); if (!empty($this->compression)) { $decompress = new Decompress($this->compression); $decrypted = $decompress($decrypted); } return $decrypted; } public function toString() { return 'BlockCipher'; } } setAdapter($options); } elseif ($options instanceof Compress\CompressionAlgorithmInterface) { $this->setAdapter($options); } elseif (is_array($options)) { $this->setOptions($options); } } public function setOptions($options) { if (!is_array($options) && !$options instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '"%s" expects an array or Traversable; received "%s"', __METHOD__, (is_object($options) ? get_class($options) : gettype($options)) )); } foreach ($options as $key => $value) { if ($key == 'options') { $key = 'adapterOptions'; } $method = 'set' . ucfirst($key); if (method_exists($this, $method)) { $this->$method($value); } } return $this; } public function getAdapter() { if ($this->adapter instanceof Compress\CompressionAlgorithmInterface) { return $this->adapter; } $adapter = $this->adapter; $options = $this->getAdapterOptions(); if (!class_exists($adapter)) { $adapter = 'Zend\\Filter\\Compress\\' . ucfirst($adapter); if (!class_exists($adapter)) { throw new Exception\RuntimeException(sprintf( '%s unable to load adapter; class "%s" not found', __METHOD__, $this->adapter )); } } $this->adapter = new $adapter($options); if (!$this->adapter instanceof Compress\CompressionAlgorithmInterface) { throw new Exception\InvalidArgumentException("Compression adapter '" . $adapter . "' does not implement Zend\\Filter\\Compress\\CompressionAlgorithmInterface"); } return $this->adapter; } public function getAdapterName() { return $this->getAdapter()->toString(); } public function setAdapter($adapter) { if ($adapter instanceof Compress\CompressionAlgorithmInterface) { $this->adapter = $adapter; return $this; } if (!is_string($adapter)) { throw new Exception\InvalidArgumentException('Invalid adapter provided; must be string or instance of Zend\\Filter\\Compress\\CompressionAlgorithmInterface'); } $this->adapter = $adapter; return $this; } public function getAdapterOptions() { return $this->adapterOptions; } public function setAdapterOptions(array $options) { $this->adapterOptions = $options; return $this; } public function getOptions($option = null) { $adapter = $this->getAdapter(); return $adapter->getOptions($option); } public function __call($method, $options) { $adapter = $this->getAdapter(); if (!method_exists($adapter, $method)) { throw new Exception\BadMethodCallException("Unknown method '{$method}'"); } return call_user_func_array(array($adapter, $method), $options); } public function filter($value) { return $this->getAdapter()->compress($value); } } setTagsAllowed($options['allowTags']); } if (array_key_exists('allowAttribs', $options)) { $this->setAttributesAllowed($options['allowAttribs']); } } public function getTagsAllowed() { return $this->tagsAllowed; } public function setTagsAllowed($tagsAllowed) { if (!is_array($tagsAllowed)) { $tagsAllowed = array($tagsAllowed); } foreach ($tagsAllowed as $index => $element) { if (is_int($index) && is_string($element)) { $tagName = strtolower($element); $this->tagsAllowed[$tagName] = array(); } elseif (is_string($index) && (is_array($element) || is_string($element))) { $tagName = strtolower($index); if (is_string($element)) { $element = array($element); } $this->tagsAllowed[$tagName] = array(); foreach ($element as $attribute) { if (is_string($attribute)) { $attributeName = strtolower($attribute); $this->tagsAllowed[$tagName][$attributeName] = null; } } } } return $this; } public function getAttributesAllowed() { return $this->attributesAllowed; } public function setAttributesAllowed($attributesAllowed) { if (!is_array($attributesAllowed)) { $attributesAllowed = array($attributesAllowed); } foreach ($attributesAllowed as $attribute) { if (is_string($attribute)) { $attributeName = strtolower($attribute); $this->attributesAllowed[$attributeName] = null; } } return $this; } public function filter($value) { if (null === $value) { return null; } if (!is_scalar($value)){ trigger_error( sprintf( '%s expects parameter to be scalar, "%s" given; cannot filter', __METHOD__, (is_object($value) ? get_class($value) : gettype($value)) ), E_USER_WARNING ); return $value; } $value = (string) $value; while (strpos($value, '