Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Mvc / Router / Http / TranslatorAwareTreeRouteStack.php
blob35326718bc8b6946e8ded0e0af657469bf645e49
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Mvc\Router\Http;
12 use Zend\I18n\Translator\Translator;
13 use Zend\I18n\Translator\TranslatorAwareInterface;
14 use Zend\Stdlib\RequestInterface as Request;
16 /**
17 * Translator aware tree route stack.
19 class TranslatorAwareTreeRouteStack extends TreeRouteStack implements TranslatorAwareInterface
21 /**
22 * Translator used for translatable segments.
24 * @var Translator
26 protected $translator;
28 /**
29 * Whether the translator is enabled.
31 * @var bool
33 protected $translatorEnabled = true;
35 /**
36 * Translator text domain to use.
38 * @var string
40 protected $translatorTextDomain = 'default';
42 /**
43 * match(): defined by \Zend\Mvc\Router\RouteInterface
45 * @see \Zend\Mvc\Router\RouteInterface::match()
46 * @param Request $request
47 * @param integer|null $pathOffset
48 * @param array $options
49 * @return RouteMatch|null
51 public function match(Request $request, $pathOffset = null, array $options = array())
53 if ($this->hasTranslator() && $this->isTranslatorEnabled() && !isset($options['translator'])) {
54 $options['translator'] = $this->getTranslator();
57 if (!isset($options['text_domain'])) {
58 $options['text_domain'] = $this->getTranslatorTextDomain();
61 return parent::match($request, $pathOffset, $options);
64 /**
65 * assemble(): defined by \Zend\Mvc\Router\RouteInterface interface.
67 * @see \Zend\Mvc\Router\RouteInterface::assemble()
68 * @param array $params
69 * @param array $options
70 * @return mixed
71 * @throws Exception\InvalidArgumentException
72 * @throws Exception\RuntimeException
74 public function assemble(array $params = array(), array $options = array())
76 if ($this->hasTranslator() && $this->isTranslatorEnabled() && !isset($options['translator'])) {
77 $options['translator'] = $this->getTranslator();
80 if (!isset($options['text_domain'])) {
81 $options['text_domain'] = $this->getTranslatorTextDomain();
84 return parent::assemble($params, $options);
87 /**
88 * setTranslator(): defined by TranslatorAwareInterface.
90 * @see TranslatorAwareInterface::setTranslator()
91 * @param Translator $translator
92 * @param string $textDomain
93 * @return TreeRouteStack
95 public function setTranslator(Translator $translator = null, $textDomain = null)
97 $this->translator = $translator;
99 if ($textDomain !== null) {
100 $this->setTranslatorTextDomain($textDomain);
103 return $this;
107 * getTranslator(): defined by TranslatorAwareInterface.
109 * @see TranslatorAwareInterface::getTranslator()
110 * @return Translator
112 public function getTranslator()
114 return $this->translator;
118 * hasTranslator(): defined by TranslatorAwareInterface.
120 * @see TranslatorAwareInterface::hasTranslator()
121 * @return bool
123 public function hasTranslator()
125 return $this->translator !== null;
129 * setTranslatorEnabled(): defined by TranslatorAwareInterface.
131 * @see TranslatorAwareInterface::setTranslatorEnabled()
132 * @param bool $enabled
133 * @return TreeRouteStack
135 public function setTranslatorEnabled($enabled = true)
137 $this->translatorEnabled = $enabled;
138 return $this;
142 * isTranslatorEnabled(): defined by TranslatorAwareInterface.
144 * @see TranslatorAwareInterface::isTranslatorEnabled()
145 * @return bool
147 public function isTranslatorEnabled()
149 return $this->translatorEnabled;
153 * setTranslatorTextDomain(): defined by TranslatorAwareInterface.
155 * @see TranslatorAwareInterface::setTranslatorTextDomain()
156 * @param string $textDomain
157 * @return mixed
159 public function setTranslatorTextDomain($textDomain = 'default')
161 $this->translatorTextDomain = $textDomain;
163 return $this;
167 * getTranslatorTextDomain(): defined by TranslatorAwareInterface.
169 * @see TranslatorAwareInterface::getTranslatorTextDomain()
170 * @return string
172 public function getTranslatorTextDomain()
174 return $this->translatorTextDomain;