PageRenderTime 71ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 2ms

/app/cache/dev/classes.php

https://github.com/lenybernard/anakin
PHP | 9593 lines | 6799 code | 1561 blank | 1233 comment | 704 complexity | b093d1e167afc32d09e6473ba742af38 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. namespace Symfony\Bundle\FrameworkBundle\EventListener
  3. {
  4. use Symfony\Component\DependencyInjection\ContainerInterface;
  5. use Symfony\Component\HttpKernel\HttpKernelInterface;
  6. use Symfony\Component\HttpKernel\Event\GetResponseEvent;
  7. class SessionListener
  8. {
  9. private $container;
  10. private $autoStart;
  11. public function __construct(ContainerInterface $container, $autoStart = false)
  12. {
  13. $this->container = $container;
  14. $this->autoStart = $autoStart;
  15. }
  16. public function onKernelRequest(GetResponseEvent $event)
  17. {
  18. if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
  19. return;
  20. }
  21. if (!$this->container->has('session')) {
  22. return;
  23. }
  24. $request = $event->getRequest();
  25. if ($request->hasSession()) {
  26. return;
  27. }
  28. $request->setSession($session = $this->container->get('session'));
  29. if ($this->autoStart || $request->hasPreviousSession()) {
  30. $session->start();
  31. }
  32. }
  33. }
  34. }
  35. namespace Symfony\Component\HttpFoundation\SessionStorage
  36. {
  37. interface SessionStorageInterface
  38. {
  39. public function start();
  40. public function getId();
  41. public function read($key);
  42. public function remove($key);
  43. public function write($key, $data);
  44. public function regenerate($destroy = false);
  45. }
  46. }
  47. namespace Symfony\Component\HttpFoundation
  48. {
  49. use Symfony\Component\HttpFoundation\SessionStorage\SessionStorageInterface;
  50. class Session implements \Serializable
  51. {
  52. protected $storage;
  53. protected $started;
  54. protected $attributes;
  55. protected $flashes;
  56. protected $oldFlashes;
  57. protected $locale;
  58. protected $defaultLocale;
  59. protected $closed;
  60. public function __construct(SessionStorageInterface $storage, $defaultLocale = 'en')
  61. {
  62. $this->storage = $storage;
  63. $this->defaultLocale = $defaultLocale;
  64. $this->locale = $defaultLocale;
  65. $this->flashes = array();
  66. $this->oldFlashes = array();
  67. $this->attributes = array();
  68. $this->setPhpDefaultLocale($this->defaultLocale);
  69. $this->started = false;
  70. $this->closed = false;
  71. }
  72. public function start()
  73. {
  74. if (true === $this->started) {
  75. return;
  76. }
  77. $this->storage->start();
  78. $attributes = $this->storage->read('_symfony2');
  79. if (isset($attributes['attributes'])) {
  80. $this->attributes = $attributes['attributes'];
  81. $this->flashes = $attributes['flashes'];
  82. $this->locale = $attributes['locale'];
  83. $this->setPhpDefaultLocale($this->locale);
  84. $this->oldFlashes = $this->flashes;
  85. }
  86. $this->started = true;
  87. }
  88. public function has($name)
  89. {
  90. return array_key_exists($name, $this->attributes);
  91. }
  92. public function get($name, $default = null)
  93. {
  94. return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
  95. }
  96. public function set($name, $value)
  97. {
  98. if (false === $this->started) {
  99. $this->start();
  100. }
  101. $this->attributes[$name] = $value;
  102. }
  103. public function all()
  104. {
  105. return $this->attributes;
  106. }
  107. public function replace(array $attributes)
  108. {
  109. if (false === $this->started) {
  110. $this->start();
  111. }
  112. $this->attributes = $attributes;
  113. }
  114. public function remove($name)
  115. {
  116. if (false === $this->started) {
  117. $this->start();
  118. }
  119. if (array_key_exists($name, $this->attributes)) {
  120. unset($this->attributes[$name]);
  121. }
  122. }
  123. public function clear()
  124. {
  125. if (false === $this->started) {
  126. $this->start();
  127. }
  128. $this->attributes = array();
  129. $this->flashes = array();
  130. $this->setPhpDefaultLocale($this->locale = $this->defaultLocale);
  131. }
  132. public function invalidate()
  133. {
  134. $this->clear();
  135. $this->storage->regenerate(true);
  136. }
  137. public function migrate()
  138. {
  139. $this->storage->regenerate();
  140. }
  141. public function getId()
  142. {
  143. if (false === $this->started) {
  144. $this->start();
  145. }
  146. return $this->storage->getId();
  147. }
  148. public function getLocale()
  149. {
  150. return $this->locale;
  151. }
  152. public function setLocale($locale)
  153. {
  154. if (false === $this->started) {
  155. $this->start();
  156. }
  157. $this->setPhpDefaultLocale($this->locale = $locale);
  158. }
  159. public function getFlashes()
  160. {
  161. return $this->flashes;
  162. }
  163. public function setFlashes($values)
  164. {
  165. if (false === $this->started) {
  166. $this->start();
  167. }
  168. $this->flashes = $values;
  169. $this->oldFlashes = array();
  170. }
  171. public function getFlash($name, $default = null)
  172. {
  173. return array_key_exists($name, $this->flashes) ? $this->flashes[$name] : $default;
  174. }
  175. public function setFlash($name, $value)
  176. {
  177. if (false === $this->started) {
  178. $this->start();
  179. }
  180. $this->flashes[$name] = $value;
  181. unset($this->oldFlashes[$name]);
  182. }
  183. public function hasFlash($name)
  184. {
  185. if (false === $this->started) {
  186. $this->start();
  187. }
  188. return array_key_exists($name, $this->flashes);
  189. }
  190. public function removeFlash($name)
  191. {
  192. if (false === $this->started) {
  193. $this->start();
  194. }
  195. unset($this->flashes[$name]);
  196. }
  197. public function clearFlashes()
  198. {
  199. if (false === $this->started) {
  200. $this->start();
  201. }
  202. $this->flashes = array();
  203. $this->oldFlashes = array();
  204. }
  205. public function save()
  206. {
  207. if (false === $this->started) {
  208. $this->start();
  209. }
  210. $this->flashes = array_diff_key($this->flashes, $this->oldFlashes);
  211. $this->storage->write('_symfony2', array(
  212. 'attributes' => $this->attributes,
  213. 'flashes' => $this->flashes,
  214. 'locale' => $this->locale,
  215. ));
  216. }
  217. public function close()
  218. {
  219. $this->closed = true;
  220. }
  221. public function __destruct()
  222. {
  223. if (true === $this->started && !$this->closed) {
  224. $this->save();
  225. }
  226. }
  227. public function serialize()
  228. {
  229. return serialize(array($this->storage, $this->defaultLocale));
  230. }
  231. public function unserialize($serialized)
  232. {
  233. list($this->storage, $this->defaultLocale) = unserialize($serialized);
  234. $this->attributes = array();
  235. $this->started = false;
  236. }
  237. private function setPhpDefaultLocale($locale)
  238. {
  239. try {
  240. if (class_exists('Locale', false)) {
  241. \Locale::setDefault($locale);
  242. }
  243. } catch (\Exception $e) {
  244. }
  245. }
  246. }
  247. }
  248. namespace Symfony\Component\HttpFoundation\SessionStorage
  249. {
  250. class NativeSessionStorage implements SessionStorageInterface
  251. {
  252. protected static $sessionIdRegenerated = false;
  253. protected static $sessionStarted = false;
  254. protected $options;
  255. public function __construct(array $options = array())
  256. {
  257. $cookieDefaults = session_get_cookie_params();
  258. $this->options = array_merge(array(
  259. 'lifetime' => $cookieDefaults['lifetime'],
  260. 'path' => $cookieDefaults['path'],
  261. 'domain' => $cookieDefaults['domain'],
  262. 'secure' => $cookieDefaults['secure'],
  263. 'httponly' => isset($cookieDefaults['httponly']) ? $cookieDefaults['httponly'] : false,
  264. ), $options);
  265. if (isset($this->options['name'])) {
  266. session_name($this->options['name']);
  267. }
  268. }
  269. public function start()
  270. {
  271. if (self::$sessionStarted) {
  272. return;
  273. }
  274. session_set_cookie_params(
  275. $this->options['lifetime'],
  276. $this->options['path'],
  277. $this->options['domain'],
  278. $this->options['secure'],
  279. $this->options['httponly']
  280. );
  281. session_cache_limiter(false);
  282. if (!ini_get('session.use_cookies') && isset($this->options['id']) && $this->options['id'] && $this->options['id'] != session_id()) {
  283. session_id($this->options['id']);
  284. }
  285. session_start();
  286. self::$sessionStarted = true;
  287. }
  288. public function getId()
  289. {
  290. if (!self::$sessionStarted) {
  291. throw new \RuntimeException('The session must be started before reading its ID');
  292. }
  293. return session_id();
  294. }
  295. public function read($key, $default = null)
  296. {
  297. return array_key_exists($key, $_SESSION) ? $_SESSION[$key] : $default;
  298. }
  299. public function remove($key)
  300. {
  301. $retval = null;
  302. if (isset($_SESSION[$key])) {
  303. $retval = $_SESSION[$key];
  304. unset($_SESSION[$key]);
  305. }
  306. return $retval;
  307. }
  308. public function write($key, $data)
  309. {
  310. $_SESSION[$key] = $data;
  311. }
  312. public function regenerate($destroy = false)
  313. {
  314. if (self::$sessionIdRegenerated) {
  315. return;
  316. }
  317. session_regenerate_id($destroy);
  318. self::$sessionIdRegenerated = true;
  319. }
  320. }
  321. }
  322. namespace Symfony\Component\Routing\Matcher
  323. {
  324. use Symfony\Component\Routing\RequestContextAwareInterface;
  325. interface UrlMatcherInterface extends RequestContextAwareInterface
  326. {
  327. public function match($pathinfo);
  328. }
  329. }
  330. namespace Symfony\Component\Routing\Generator
  331. {
  332. use Symfony\Component\Routing\RequestContextAwareInterface;
  333. interface UrlGeneratorInterface extends RequestContextAwareInterface
  334. {
  335. public function generate($name, $parameters = array(), $absolute = false);
  336. }
  337. }
  338. namespace Symfony\Component\Routing
  339. {
  340. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  341. use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
  342. interface RouterInterface extends UrlMatcherInterface, UrlGeneratorInterface
  343. {
  344. }
  345. }
  346. namespace Symfony\Component\Routing\Matcher
  347. {
  348. use Symfony\Component\Routing\Exception\MethodNotAllowedException;
  349. use Symfony\Component\Routing\Exception\ResourceNotFoundException;
  350. use Symfony\Component\Routing\RouteCollection;
  351. use Symfony\Component\Routing\RequestContext;
  352. class UrlMatcher implements UrlMatcherInterface
  353. {
  354. protected $context;
  355. protected $allow;
  356. private $routes;
  357. public function __construct(RouteCollection $routes, RequestContext $context)
  358. {
  359. $this->routes = $routes;
  360. $this->context = $context;
  361. }
  362. public function setContext(RequestContext $context)
  363. {
  364. $this->context = $context;
  365. }
  366. public function getContext()
  367. {
  368. return $this->context;
  369. }
  370. public function match($pathinfo)
  371. {
  372. $this->allow = array();
  373. if ($ret = $this->matchCollection($pathinfo, $this->routes)) {
  374. return $ret;
  375. }
  376. throw 0 < count($this->allow)
  377. ? new MethodNotAllowedException(array_unique(array_map('strtoupper', $this->allow)))
  378. : new ResourceNotFoundException();
  379. }
  380. protected function matchCollection($pathinfo, RouteCollection $routes)
  381. {
  382. $pathinfo = urldecode($pathinfo);
  383. foreach ($routes as $name => $route) {
  384. if ($route instanceof RouteCollection) {
  385. if (false === strpos($route->getPrefix(), '{') && $route->getPrefix() !== substr($pathinfo, 0, strlen($route->getPrefix()))) {
  386. continue;
  387. }
  388. if (!$ret = $this->matchCollection($pathinfo, $route)) {
  389. continue;
  390. }
  391. return $ret;
  392. }
  393. $compiledRoute = $route->compile();
  394. if ('' !== $compiledRoute->getStaticPrefix() && 0 !== strpos($pathinfo, $compiledRoute->getStaticPrefix())) {
  395. continue;
  396. }
  397. if (!preg_match($compiledRoute->getRegex(), $pathinfo, $matches)) {
  398. continue;
  399. }
  400. if ($req = $route->getRequirement('_method')) {
  401. if ('HEAD' === $method = $this->context->getMethod()) {
  402. $method = 'GET';
  403. }
  404. if (!in_array($method, $req = explode('|', strtoupper($req)))) {
  405. $this->allow = array_merge($this->allow, $req);
  406. continue;
  407. }
  408. }
  409. return array_merge($this->mergeDefaults($matches, $route->getDefaults()), array('_route' => $name));
  410. }
  411. }
  412. protected function mergeDefaults($params, $defaults)
  413. {
  414. $parameters = $defaults;
  415. foreach ($params as $key => $value) {
  416. if (!is_int($key)) {
  417. $parameters[$key] = rawurldecode($value);
  418. }
  419. }
  420. return $parameters;
  421. }
  422. }
  423. }
  424. namespace Symfony\Component\Routing\Generator
  425. {
  426. use Symfony\Component\Routing\Route;
  427. use Symfony\Component\Routing\RouteCollection;
  428. use Symfony\Component\Routing\RequestContext;
  429. use Symfony\Component\Routing\Exception\InvalidParameterException;
  430. use Symfony\Component\Routing\Exception\RouteNotFoundException;
  431. use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
  432. class UrlGenerator implements UrlGeneratorInterface
  433. {
  434. protected $context;
  435. protected $decodedChars = array(
  436. '%2F' => '/',
  437. );
  438. protected $routes;
  439. protected $cache;
  440. public function __construct(RouteCollection $routes, RequestContext $context)
  441. {
  442. $this->routes = $routes;
  443. $this->context = $context;
  444. $this->cache = array();
  445. }
  446. public function setContext(RequestContext $context)
  447. {
  448. $this->context = $context;
  449. }
  450. public function getContext()
  451. {
  452. return $this->context;
  453. }
  454. public function generate($name, $parameters = array(), $absolute = false)
  455. {
  456. if (null === $route = $this->routes->get($name)) {
  457. throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name));
  458. }
  459. if (!isset($this->cache[$name])) {
  460. $this->cache[$name] = $route->compile();
  461. }
  462. return $this->doGenerate($this->cache[$name]->getVariables(), $route->getDefaults(), $route->getRequirements(), $this->cache[$name]->getTokens(), $parameters, $name, $absolute);
  463. }
  464. protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $absolute)
  465. {
  466. $variables = array_flip($variables);
  467. $originParameters = $parameters;
  468. $parameters = array_replace($this->context->getParameters(), $parameters);
  469. $tparams = array_replace($defaults, $parameters);
  470. if ($diff = array_diff_key($variables, $tparams)) {
  471. throw new MissingMandatoryParametersException(sprintf('The "%s" route has some missing mandatory parameters ("%s").', $name, implode('", "', array_keys($diff))));
  472. }
  473. $url = '';
  474. $optional = true;
  475. foreach ($tokens as $token) {
  476. if ('variable' === $token[0]) {
  477. if (false === $optional || !array_key_exists($token[3], $defaults) || (isset($parameters[$token[3]]) && (string) $parameters[$token[3]] != (string) $defaults[$token[3]])) {
  478. if (!$isEmpty = in_array($tparams[$token[3]], array(null, '', false), true)) {
  479. if ($tparams[$token[3]] && !preg_match('#^'.$token[2].'$#', $tparams[$token[3]])) {
  480. throw new InvalidParameterException(sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given).', $token[3], $name, $token[2], $tparams[$token[3]]));
  481. }
  482. }
  483. if (!$isEmpty || !$optional) {
  484. $url = $token[1].strtr(rawurlencode($tparams[$token[3]]), $this->decodedChars).$url;
  485. }
  486. $optional = false;
  487. }
  488. } elseif ('text' === $token[0]) {
  489. $url = $token[1].$url;
  490. $optional = false;
  491. }
  492. }
  493. if (!$url) {
  494. $url = '/';
  495. }
  496. $extra = array_diff_key($originParameters, $variables, $defaults);
  497. if ($extra && $query = http_build_query($extra, '', '&')) {
  498. $url .= '?'.$query;
  499. }
  500. $url = $this->context->getBaseUrl().$url;
  501. if ($this->context->getHost()) {
  502. $scheme = $this->context->getScheme();
  503. if (isset($requirements['_scheme']) && ($req = strtolower($requirements['_scheme'])) && $scheme != $req) {
  504. $absolute = true;
  505. $scheme = $req;
  506. }
  507. if ($absolute) {
  508. $port = '';
  509. if ('http' === $scheme && 80 != $this->context->getHttpPort()) {
  510. $port = ':'.$this->context->getHttpPort();
  511. } elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) {
  512. $port = ':'.$this->context->getHttpsPort();
  513. }
  514. $url = $scheme.'://'.$this->context->getHost().$port.$url;
  515. }
  516. }
  517. return $url;
  518. }
  519. }
  520. }
  521. namespace Symfony\Component\Routing\Matcher
  522. {
  523. interface RedirectableUrlMatcherInterface
  524. {
  525. public function redirect($path, $route, $scheme = null);
  526. }
  527. }
  528. namespace Symfony\Component\Routing
  529. {
  530. interface RequestContextAwareInterface
  531. {
  532. public function setContext(RequestContext $context);
  533. }
  534. }
  535. namespace Symfony\Component\Routing
  536. {
  537. class RequestContext
  538. {
  539. private $baseUrl;
  540. private $method;
  541. private $host;
  542. private $scheme;
  543. private $httpPort;
  544. private $httpsPort;
  545. private $parameters;
  546. public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $scheme = 'http', $httpPort = 80, $httpsPort = 443)
  547. {
  548. $this->baseUrl = $baseUrl;
  549. $this->method = strtoupper($method);
  550. $this->host = $host;
  551. $this->scheme = strtolower($scheme);
  552. $this->httpPort = $httpPort;
  553. $this->httpsPort = $httpsPort;
  554. $this->parameters = array();
  555. }
  556. public function getBaseUrl()
  557. {
  558. return $this->baseUrl;
  559. }
  560. public function setBaseUrl($baseUrl)
  561. {
  562. $this->baseUrl = $baseUrl;
  563. }
  564. public function getMethod()
  565. {
  566. return $this->method;
  567. }
  568. public function setMethod($method)
  569. {
  570. $this->method = strtoupper($method);
  571. }
  572. public function getHost()
  573. {
  574. return $this->host;
  575. }
  576. public function setHost($host)
  577. {
  578. $this->host = $host;
  579. }
  580. public function getScheme()
  581. {
  582. return $this->scheme;
  583. }
  584. public function setScheme($scheme)
  585. {
  586. $this->scheme = strtolower($scheme);
  587. }
  588. public function getHttpPort()
  589. {
  590. return $this->httpPort;
  591. }
  592. public function setHttpPort($httpPort)
  593. {
  594. $this->httpPort = $httpPort;
  595. }
  596. public function getHttpsPort()
  597. {
  598. return $this->httpsPort;
  599. }
  600. public function setHttpsPort($httpsPort)
  601. {
  602. $this->httpsPort = $httpsPort;
  603. }
  604. public function getParameters()
  605. {
  606. return $this->parameters;
  607. }
  608. public function setParameters(array $parameters)
  609. {
  610. $this->parameters = $parameters;
  611. return $this;
  612. }
  613. public function getParameter($name)
  614. {
  615. return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
  616. }
  617. public function hasParameter($name)
  618. {
  619. return array_key_exists($name, $this->parameters);
  620. }
  621. public function setParameter($name, $parameter)
  622. {
  623. $this->parameters[$name] = $parameter;
  624. }
  625. }
  626. }
  627. namespace Symfony\Component\Routing
  628. {
  629. use Symfony\Component\Config\Loader\LoaderInterface;
  630. use Symfony\Component\Config\ConfigCache;
  631. class Router implements RouterInterface
  632. {
  633. protected $matcher;
  634. protected $generator;
  635. protected $defaults;
  636. protected $context;
  637. protected $loader;
  638. protected $collection;
  639. protected $resource;
  640. protected $options;
  641. public function __construct(LoaderInterface $loader, $resource, array $options = array(), RequestContext $context = null, array $defaults = array())
  642. {
  643. $this->loader = $loader;
  644. $this->resource = $resource;
  645. $this->context = null === $context ? new RequestContext() : $context;
  646. $this->defaults = $defaults;
  647. $this->setOptions($options);
  648. }
  649. public function setOptions(array $options)
  650. {
  651. $this->options = array(
  652. 'cache_dir' => null,
  653. 'debug' => false,
  654. 'generator_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
  655. 'generator_base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
  656. 'generator_dumper_class' => 'Symfony\\Component\\Routing\\Generator\\Dumper\\PhpGeneratorDumper',
  657. 'generator_cache_class' => 'ProjectUrlGenerator',
  658. 'matcher_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher',
  659. 'matcher_base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher',
  660. 'matcher_dumper_class' => 'Symfony\\Component\\Routing\\Matcher\\Dumper\\PhpMatcherDumper',
  661. 'matcher_cache_class' => 'ProjectUrlMatcher',
  662. 'resource_type' => null,
  663. );
  664. $invalid = array();
  665. $isInvalid = false;
  666. foreach ($options as $key => $value) {
  667. if (array_key_exists($key, $this->options)) {
  668. $this->options[$key] = $value;
  669. } else {
  670. $isInvalid = true;
  671. $invalid[] = $key;
  672. }
  673. }
  674. if ($isInvalid) {
  675. throw new \InvalidArgumentException(sprintf('The Router does not support the following options: "%s".', implode('\', \'', $invalid)));
  676. }
  677. }
  678. public function setOption($key, $value)
  679. {
  680. if (!array_key_exists($key, $this->options)) {
  681. throw new \InvalidArgumentException(sprintf('The Router does not support the "%s" option.', $key));
  682. }
  683. $this->options[$key] = $value;
  684. }
  685. public function getOption($key)
  686. {
  687. if (!array_key_exists($key, $this->options)) {
  688. throw new \InvalidArgumentException(sprintf('The Router does not support the "%s" option.', $key));
  689. }
  690. return $this->options[$key];
  691. }
  692. public function getRouteCollection()
  693. {
  694. if (null === $this->collection) {
  695. $this->collection = $this->loader->load($this->resource, $this->options['resource_type']);
  696. }
  697. return $this->collection;
  698. }
  699. public function setContext(RequestContext $context)
  700. {
  701. $this->context = $context;
  702. $this->getMatcher()->setContext($context);
  703. $this->getGenerator()->setContext($context);
  704. }
  705. public function getContext()
  706. {
  707. return $this->context;
  708. }
  709. public function generate($name, $parameters = array(), $absolute = false)
  710. {
  711. return $this->getGenerator()->generate($name, $parameters, $absolute);
  712. }
  713. public function match($url)
  714. {
  715. return $this->getMatcher()->match($url);
  716. }
  717. public function getMatcher()
  718. {
  719. if (null !== $this->matcher) {
  720. return $this->matcher;
  721. }
  722. if (null === $this->options['cache_dir'] || null === $this->options['matcher_cache_class']) {
  723. return $this->matcher = new $this->options['matcher_class']($this->getRouteCollection(), $this->context, $this->defaults);
  724. }
  725. $class = $this->options['matcher_cache_class'];
  726. $cache = new ConfigCache($this->options['cache_dir'].'/'.$class.'.php', $this->options['debug']);
  727. if (!$cache->isFresh($class)) {
  728. $dumper = new $this->options['matcher_dumper_class']($this->getRouteCollection());
  729. $options = array(
  730. 'class' => $class,
  731. 'base_class' => $this->options['matcher_base_class'],
  732. );
  733. $cache->write($dumper->dump($options), $this->getRouteCollection()->getResources());
  734. }
  735. require_once $cache;
  736. return $this->matcher = new $class($this->context, $this->defaults);
  737. }
  738. public function getGenerator()
  739. {
  740. if (null !== $this->generator) {
  741. return $this->generator;
  742. }
  743. if (null === $this->options['cache_dir'] || null === $this->options['generator_cache_class']) {
  744. return $this->generator = new $this->options['generator_class']($this->getRouteCollection(), $this->context, $this->defaults);
  745. }
  746. $class = $this->options['generator_cache_class'];
  747. $cache = new ConfigCache($this->options['cache_dir'].'/'.$class.'.php', $this->options['debug']);
  748. if (!$cache->isFresh($class)) {
  749. $dumper = new $this->options['generator_dumper_class']($this->getRouteCollection());
  750. $options = array(
  751. 'class' => $class,
  752. 'base_class' => $this->options['generator_base_class'],
  753. );
  754. $cache->write($dumper->dump($options), $this->getRouteCollection()->getResources());
  755. }
  756. require_once $cache;
  757. return $this->generator = new $class($this->context, $this->defaults);
  758. }
  759. }
  760. }
  761. namespace Symfony\Bundle\FrameworkBundle\Routing
  762. {
  763. use Symfony\Component\Routing\Matcher\RedirectableUrlMatcher as BaseMatcher;
  764. class RedirectableUrlMatcher extends BaseMatcher
  765. {
  766. public function redirect($path, $route, $scheme = null)
  767. {
  768. return array(
  769. '_controller' => 'Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController::urlRedirectAction',
  770. 'path' => $path,
  771. 'permanent' => true,
  772. 'scheme' => $scheme,
  773. 'httpPort' => $this->context->getHttpPort(),
  774. 'httpsPort' => $this->context->getHttpsPort(),
  775. '_route' => $route,
  776. );
  777. }
  778. }
  779. }
  780. namespace Symfony\Bundle\FrameworkBundle\Routing
  781. {
  782. use Symfony\Component\Routing\Router as BaseRouter;
  783. use Symfony\Component\Routing\RequestContext;
  784. use Symfony\Component\DependencyInjection\ContainerInterface;
  785. class Router extends BaseRouter
  786. {
  787. private $container;
  788. public function __construct(ContainerInterface $container, $resource, array $options = array(), RequestContext $context = null, array $defaults = array())
  789. {
  790. $this->container = $container;
  791. $this->resource = $resource;
  792. $this->context = null === $context ? new RequestContext() : $context;
  793. $this->defaults = $defaults;
  794. $this->setOptions($options);
  795. }
  796. public function getRouteCollection()
  797. {
  798. if (null === $this->collection) {
  799. $this->collection = $this->container->get('routing.loader')->load($this->resource, $this->options['resource_type']);
  800. }
  801. return $this->collection;
  802. }
  803. }
  804. }
  805. namespace Symfony\Bundle\FrameworkBundle\Templating
  806. {
  807. use Symfony\Component\DependencyInjection\ContainerInterface;
  808. class GlobalVariables
  809. {
  810. protected $container;
  811. public function __construct(ContainerInterface $container)
  812. {
  813. $this->container = $container;
  814. }
  815. public function getSecurity()
  816. {
  817. if ($this->container->has('security.context')) {
  818. return $this->container->get('security.context');
  819. }
  820. }
  821. public function getUser()
  822. {
  823. if (!$security = $this->getSecurity()) {
  824. return;
  825. }
  826. if (!$token = $security->getToken()) {
  827. return;
  828. }
  829. $user = $token->getUser();
  830. if (!is_object($user)) {
  831. return;
  832. }
  833. return $user;
  834. }
  835. public function getRequest()
  836. {
  837. if ($this->container->has('request') && $request = $this->container->get('request')) {
  838. return $request;
  839. }
  840. }
  841. public function getSession()
  842. {
  843. if ($request = $this->getRequest()) {
  844. return $request->getSession();
  845. }
  846. }
  847. public function getEnvironment()
  848. {
  849. return $this->container->getParameter('kernel.environment');
  850. }
  851. public function getDebug()
  852. {
  853. return (Boolean) $this->container->getParameter('kernel.debug');
  854. }
  855. }
  856. }
  857. namespace Symfony\Bundle\FrameworkBundle\Templating
  858. {
  859. use Symfony\Component\Templating\EngineInterface as BaseEngineInterface;
  860. use Symfony\Component\HttpFoundation\Response;
  861. interface EngineInterface extends BaseEngineInterface
  862. {
  863. public function renderResponse($view, array $parameters = array(), Response $response = null);
  864. }
  865. }
  866. namespace Symfony\Component\Templating
  867. {
  868. interface TemplateNameParserInterface
  869. {
  870. public function parse($name);
  871. }
  872. }
  873. namespace Symfony\Component\Templating
  874. {
  875. use Symfony\Component\Templating\TemplateReferenceInterface;
  876. use Symfony\Component\Templating\TemplateReference;
  877. class TemplateNameParser implements TemplateNameParserInterface
  878. {
  879. public function parse($name)
  880. {
  881. if ($name instanceof TemplateReferenceInterface) {
  882. return $name;
  883. }
  884. $engine = null;
  885. if (false !== $pos = strrpos($name, '.')) {
  886. $engine = substr($name, $pos + 1);
  887. }
  888. return new TemplateReference($name, $engine);
  889. }
  890. }
  891. }
  892. namespace Symfony\Component\Templating
  893. {
  894. interface EngineInterface
  895. {
  896. public function render($name, array $parameters = array());
  897. public function exists($name);
  898. public function supports($name);
  899. }
  900. }
  901. namespace Symfony\Component\Config
  902. {
  903. interface FileLocatorInterface
  904. {
  905. public function locate($name, $currentPath = null, $first = true);
  906. }
  907. }
  908. namespace Symfony\Component\Templating
  909. {
  910. interface TemplateReferenceInterface
  911. {
  912. public function all();
  913. public function set($name, $value);
  914. public function get($name);
  915. public function getPath();
  916. public function getLogicalName();
  917. }
  918. }
  919. namespace Symfony\Component\Templating
  920. {
  921. class TemplateReference implements TemplateReferenceInterface
  922. {
  923. protected $parameters;
  924. public function __construct($name = null, $engine = null)
  925. {
  926. $this->parameters = array(
  927. 'name' => $name,
  928. 'engine' => $engine,
  929. );
  930. }
  931. public function __toString()
  932. {
  933. return $this->getLogicalName();
  934. }
  935. public function set($name, $value)
  936. {
  937. if (array_key_exists($name, $this->parameters)) {
  938. $this->parameters[$name] = $value;
  939. } else {
  940. throw new \InvalidArgumentException(sprintf('The template does not support the "%s" parameter.', $name));
  941. }
  942. return $this;
  943. }
  944. public function get($name)
  945. {
  946. if (array_key_exists($name, $this->parameters)) {
  947. return $this->parameters[$name];
  948. }
  949. throw new \InvalidArgumentException(sprintf('The template does not support the "%s" parameter.', $name));
  950. }
  951. public function all()
  952. {
  953. return $this->parameters;
  954. }
  955. public function getPath()
  956. {
  957. return $this->parameters['name'];
  958. }
  959. public function getLogicalName()
  960. {
  961. return $this->parameters['name'];
  962. }
  963. }
  964. }
  965. namespace Symfony\Bundle\FrameworkBundle\Templating
  966. {
  967. use Symfony\Component\Templating\TemplateReference as BaseTemplateReference;
  968. class TemplateReference extends BaseTemplateReference
  969. {
  970. public function __construct($bundle = null, $controller = null, $name = null, $format = null, $engine = null)
  971. {
  972. $this->parameters = array(
  973. 'bundle' => $bundle,
  974. 'controller' => $controller,
  975. 'name' => $name,
  976. 'format' => $format,
  977. 'engine' => $engine,
  978. );
  979. }
  980. public function getPath()
  981. {
  982. $controller = str_replace('\\', '/', $this->get('controller'));
  983. $path = (empty($controller) ? '' : $controller.'/').$this->get('name').'.'.$this->get('format').'.'.$this->get('engine');
  984. return empty($this->parameters['bundle']) ? 'views/'.$path : '@'.$this->get('bundle').'/Resources/views/'.$path;
  985. }
  986. public function getLogicalName()
  987. {
  988. return sprintf('%s:%s:%s.%s.%s', $this->parameters['bundle'], $this->parameters['controller'], $this->parameters['name'], $this->parameters['format'], $this->parameters['engine']);
  989. }
  990. }
  991. }
  992. namespace Symfony\Bundle\FrameworkBundle\Templating
  993. {
  994. use Symfony\Component\Templating\TemplateNameParser as BaseTemplateNameParser;
  995. use Symfony\Component\Templating\TemplateReferenceInterface;
  996. use Symfony\Component\HttpKernel\KernelInterface;
  997. class TemplateNameParser extends BaseTemplateNameParser
  998. {
  999. protected $kernel;
  1000. protected $cache;
  1001. public function __construct(KernelInterface $kernel)
  1002. {
  1003. $this->kernel = $kernel;
  1004. $this->cache = array();
  1005. }
  1006. public function parse($name)
  1007. {
  1008. if ($name instanceof TemplateReferenceInterface) {
  1009. return $name;
  1010. } elseif (isset($this->cache[$name])) {
  1011. return $this->cache[$name];
  1012. }
  1013. $name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')));
  1014. if (false !== strpos($name, '..')) {
  1015. throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name));
  1016. }
  1017. $parts = explode(':', $name);
  1018. if (3 !== count($parts)) {
  1019. throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid (format is "bundle:section:template.format.engine").', $name));
  1020. }
  1021. $elements = explode('.', $parts[2]);
  1022. if (3 > count($elements)) {
  1023. throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid (format is "bundle:section:template.format.engine").', $name));
  1024. }
  1025. $engine = array_pop($elements);
  1026. $format = array_pop($elements);
  1027. $template = new TemplateReference($parts[0], $parts[1], implode('.', $elements), $format, $engine);
  1028. if ($template->get('bundle')) {
  1029. try {
  1030. $this->kernel->getBundle($template->get('bundle'));
  1031. } catch (\Exception $e) {
  1032. throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid.', $name), 0, $e);
  1033. }
  1034. }
  1035. return $this->cache[$name] = $template;
  1036. }
  1037. public function parseFromFilename($file)
  1038. {
  1039. $parts = explode('/', strtr($file, '\\', '/'));
  1040. $elements = explode('.', array_pop($parts));
  1041. if (3 > count($elements)) {
  1042. return false;
  1043. }
  1044. $engine = array_pop($elements);
  1045. $format = array_pop($elements);
  1046. return new TemplateReference('', implode('/', $parts), implode('.', $elements), $format, $engine);
  1047. }
  1048. }
  1049. }
  1050. namespace Symfony\Bundle\FrameworkBundle\Templating\Loader
  1051. {
  1052. use Symfony\Component\Config\FileLocatorInterface;
  1053. use Symfony\Component\Templating\TemplateReferenceInterface;
  1054. class TemplateLocator implements FileLocatorInterface
  1055. {
  1056. protected $locator;
  1057. protected $cache;
  1058. public function __construct(FileLocatorInterface $locator, $cacheDir = null)
  1059. {
  1060. if (null !== $cacheDir && file_exists($cache = $cacheDir.'/templates.php')) {
  1061. $this->cache = require $cache;
  1062. }
  1063. $this->locator = $locator;
  1064. }
  1065. public function locate($template, $currentPath = null, $first = true)
  1066. {
  1067. if (!$template instanceof TemplateReferenceInterface) {
  1068. throw new \InvalidArgumentException("The template must be an instance of TemplateReferenceInterface.");
  1069. }
  1070. $key = $template->getLogicalName();
  1071. if (isset($this->cache[$key])) {
  1072. return $this->cache[$key];
  1073. }
  1074. try {
  1075. return $this->cache[$key] = $this->locator->locate($template->getPath(), $currentPath);
  1076. } catch (\InvalidArgumentException $e) {
  1077. throw new \InvalidArgumentException(sprintf('Unable to find template "%s" : "%s".', $template, $e->getMessage()), 0, $e);
  1078. }
  1079. }
  1080. }
  1081. }
  1082. namespace Symfony\Component\HttpFoundation
  1083. {
  1084. class ParameterBag
  1085. {
  1086. protected $parameters;
  1087. public function __construct(array $parameters = array())
  1088. {
  1089. $this->parameters = $parameters;
  1090. }
  1091. public function all()
  1092. {
  1093. return $this->parameters;
  1094. }
  1095. public function keys()
  1096. {
  1097. return array_keys($this->parameters);
  1098. }
  1099. public function replace(array $parameters = array())
  1100. {
  1101. $this->parameters = $parameters;
  1102. }
  1103. public function add(array $parameters = array())
  1104. {
  1105. $this->parameters = array_replace($this->parameters, $parameters);
  1106. }
  1107. public function get($path, $default = null, $deep = false)
  1108. {
  1109. if (!$deep || false === $pos = strpos($path, '[')) {
  1110. return array_key_exists($path, $this->parameters) ? $this->parameters[$path] : $default;
  1111. }
  1112. $root = substr($path, 0, $pos);
  1113. if (!array_key_exists($root, $this->parameters)) {
  1114. return $default;
  1115. }
  1116. $value = $this->parameters[$root];
  1117. $currentKey = null;
  1118. for ($i = $pos, $c = strlen($path); $i < $c; $i++) {
  1119. $char = $path[$i];
  1120. if ('[' === $char) {
  1121. if (null !== $currentKey) {
  1122. throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "[" at position %d.', $i));
  1123. }
  1124. $currentKey = '';
  1125. } elseif (']' === $char) {
  1126. if (null === $currentKey) {
  1127. throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "]" at position %d.', $i));
  1128. }
  1129. if (!is_array($value) || !array_key_exists($currentKey, $value)) {
  1130. return $default;
  1131. }
  1132. $value = $value[$currentKey];
  1133. $currentKey = null;
  1134. } else {
  1135. if (null === $currentKey) {
  1136. throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "%s" at position %d.', $char, $i));
  1137. }
  1138. $currentKey .= $char;
  1139. }
  1140. }
  1141. if (null !== $currentKey) {
  1142. throw new \InvalidArgumentException(sprintf('Malformed path. Path must end with "]".'));
  1143. }
  1144. return $value;
  1145. }
  1146. public function set($key, $value)
  1147. {
  1148. $this->parameters[$key] = $value;
  1149. }
  1150. public function has($key)
  1151. {
  1152. return array_key_exists($key, $this->parameters);
  1153. }
  1154. public function remove($key)
  1155. {
  1156. unset($this->parameters[$key]);
  1157. }
  1158. public function getAlpha($key, $default = '', $deep = false)
  1159. {
  1160. return preg_replace('/[^[:alpha:]]/', '', $this->get($key, $default, $deep));
  1161. }
  1162. public function getAlnum($key, $default = '', $deep = false)
  1163. {
  1164. return preg_replace('/[^[:alnum:]]/', '', $this->get($key, $default, $deep));
  1165. }
  1166. public function getDigits($key, $default = '', $deep = false)
  1167. {
  1168. return preg_replace('/[^[:digit:]]/', '', $this->get($key, $default, $deep));
  1169. }
  1170. public function getInt($key, $default = 0, $deep = false)
  1171. {
  1172. return (int) $this->get($key, $default, $deep);
  1173. }
  1174. }
  1175. }
  1176. namespace Symfony\Component\HttpFoundation
  1177. {
  1178. class HeaderBag
  1179. {
  1180. protected $headers;
  1181. protected $cacheControl;
  1182. public function __construct(array $headers = array())
  1183. {
  1184. $this->cacheControl = array();
  1185. $this->headers = array();
  1186. foreach ($headers as $key => $values) {
  1187. $this->set($key, $values);
  1188. }
  1189. }
  1190. public function __toString()
  1191. {
  1192. if (!$this->headers) {
  1193. return '';
  1194. }
  1195. $beautifier = function ($name) {
  1196. return preg_replace_callback('/\-(.)/', function ($match) { return '-'.strtoupper($match[1]); }, ucfirst($name));
  1197. };
  1198. $max = max(array_map('strlen', array_keys($this->headers))) + 1;
  1199. $content = '';
  1200. ksort($this->headers);
  1201. foreach ($this->headers as $name => $values) {
  1202. foreach ($values as $value) {
  1203. $content .= sprintf("%-{$max}s %s\r\n", $beautifier($name).':', $value);
  1204. }
  1205. }
  1206. return $content;
  1207. }
  1208. public function all()
  1209. {
  1210. return $this->headers;
  1211. }
  1212. public function keys()
  1213. {
  1214. return array_keys($this->headers);
  1215. }
  1216. public function replace(array $headers = array())
  1217. {
  1218. $this->headers = array();
  1219. $this->add($headers);
  1220. }
  1221. public function add(array $headers)
  1222. {
  1223. foreach ($headers as $key => $values) {
  1224. $this->set($key, $values);
  1225. }
  1226. }
  1227. public function get($key, $default = null, $first = true)
  1228. {
  1229. $key = strtr(strtolower($key), '_', '-');
  1230. if (!array_key_exists($key, $this->headers)) {
  1231. if (null === $default) {
  1232. return $first ? null : array();
  1233. }
  1234. return $first ? $default : array($default);
  1235. }
  1236. if ($first) {
  1237. return count($this->headers[$key]) ? $this->headers[$key][0] : $default;
  1238. }
  1239. return $this->headers[$key];
  1240. }
  1241. public function set($key, $values, $replace = true)
  1242. {
  1243. $key = strtr(strtolower($key), '_', '-');
  1244. $values = (array) $values;
  1245. if (true === $replace || !isset($this->headers[$key])) {
  1246. $this->headers[$key] = $values;
  1247. } else {
  1248. $this->headers[$key] = array_merge($this->headers[$key], $values);
  1249. }
  1250. if ('cache-control' === $key) {
  1251. $this->cacheControl = $this->parseCacheControl($values[0]);
  1252. }
  1253. }
  1254. public function has($key)
  1255. {
  1256. return array_key_exists(strtr(strtolower($key), '_', '-'), $this->headers);
  1257. }
  1258. public function contains($key, $value)
  1259. {
  1260. return in_array($value, $this->get($key, null, false));
  1261. }
  1262. public function remove($key)
  1263. {
  1264. $key = strtr(strtolower($key), '_', '-');
  1265. unset($this->headers[$key]);
  1266. if ('cache-control' === $key) {
  1267. $this->cacheControl = array();
  1268. }
  1269. }
  1270. public function getDate($key, \DateTime $default = null)
  1271. {
  1272. if (null === $value = $this->get($key)) {
  1273. return $default;
  1274. }
  1275. if (false === $date = \DateTime::createFromFormat(DATE_RFC2822, $value)) {
  1276. throw new \RuntimeException(sprintf('The %s HTTP header is not parseable (%s).', $key, $value));
  1277. }
  1278. return $date;
  1279. }
  1280. public function addCacheControlDirective($key, $value = true)
  1281. {
  1282. $this->cacheControl[$key] = $value;
  1283. $this->set('Cache-Control', $this->getCacheControlHeader());
  1284. }
  1285. public function hasCacheControlDirective($key)
  1286. {
  1287. return array_key_exists($key, $this->cacheControl);
  1288. }
  1289. public function getCacheControlDirective($key)
  1290. {
  1291. return array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null;
  1292. }
  1293. public function removeCacheControlDirective($key)
  1294. {
  1295. unset($this->cacheControl[$key]);
  1296. $this->set('Cache-Control', $this->getCacheControlHeader());
  1297. }
  1298. protected function getCacheControlHeader()
  1299. {
  1300. $parts = array();
  1301. ksort($this->cacheControl);
  1302. foreach ($this->cacheControl as $key => $value) {
  1303. if (true === $value) {
  1304. $parts[] = $key;
  1305. } else {
  1306. if (preg_match('#[^a-zA-Z0-9._-]#', $value)) {
  1307. $value = '"'.$value.'"';
  1308. }
  1309. $parts[] = "$key=$value";
  1310. }
  1311. }
  1312. return implode(', ', $parts);
  1313. }
  1314. protected function parseCacheControl($header)
  1315. {
  1316. $cacheControl = array();
  1317. preg_match_all('#([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?#', $header, $matches, PREG_SET_ORDER);
  1318. foreach ($matches as $match) {
  1319. $cacheControl[strtolower($match[1])] = isset($match[2]) && $match[2] ? $match[2] : (isset($match[3]) ? $match[3] : true);
  1320. }
  1321. return $cacheControl;
  1322. }
  1323. }
  1324. }
  1325. namespace Symfony\Component\HttpFoundation
  1326. {
  1327. use Symfony\Component\HttpFoundation\File\UploadedFile;
  1328. class FileBag extends ParameterBag
  1329. {
  1330. private static $fileKeys = array('error', 'name', 'size', 'tmp_name', 'type');
  1331. public function __construct(array $parameters = array())
  1332. {
  1333. $this->replace($parameters);
  1334. }
  1335. public function replace(array $files = array())
  1336. {
  1337. $this->parameters = array();
  1338. $this->add($files);
  1339. }
  1340. public function set($key, $value)
  1341. {
  1342. if (is_array($value) || $value instanceof UploadedFile) {
  1343. parent::set($key, $this->convertFileInformation($value));
  1344. } else {
  1345. throw new \InvalidArgumentException('An uploaded file must be an array or an instance of UploadedFile.');
  1346. }
  1347. }
  1348. public function add(array $files = array())
  1349. {
  1350. foreach ($files as $key => $file) {
  1351. $this->set($key, $file);
  1352. }
  1353. }
  1354. protected function convertFileInformation($file)
  1355. {
  1356. if ($file instanceof UploadedFile) {
  1357. return $file;
  1358. }
  1359. $file = $this->fixPhpFilesArray($file);
  1360. if (is_array($file)) {
  1361. $keys = array_keys($file);
  1362. sort($keys);
  1363. if ($keys == self::$fileKeys) {
  1364. if (UPLOAD_ERR_NO_FILE == $file['error']) {
  1365. $file = null;
  1366. } else {
  1367. $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error']);
  1368. }
  1369. } else {
  1370. $file = array_map(array($this, 'convertFileInformation'), $file);
  1371. }
  1372. }
  1373. return $file;
  1374. }
  1375. protected function fixPhpFilesArray($data)
  1376. {
  1377. if (!is_array($data)) {
  1378. return $data;
  1379. }
  1380. $keys = array_keys($data);
  1381. sort($keys);
  1382. if (self::$fileKeys != $keys || !isset($data['name']) || !is_array($data['name'])) {
  1383. return $data;
  1384. }
  1385. $files = $data;
  1386. foreach (self::$fileKeys as $k) {
  1387. unset($files[$k]);
  1388. }
  1389. foreach (array_keys($data['name']) as $key) {
  1390. $files[$key] = $this->fixPhpFilesArray(array(
  1391. 'error' => $data['error'][$key],
  1392. 'name' => $data['name'][$key],
  1393. 'type' => $data['type'][$key],
  1394. 'tmp_name' => $data['tmp_name'][$key],
  1395. 'size' => $data['size'][$key]
  1396. ));
  1397. }
  1398. return $files;
  1399. }
  1400. }
  1401. }
  1402. namespace Symfony\Component\HttpFoundation
  1403. {
  1404. class ServerBag extends ParameterBag
  1405. {
  1406. public function getHeaders()
  1407. {
  1408. $headers = array();
  1409. foreach ($this->parameters as $key => $value) {
  1410. if (0 === strpos($key, 'HTTP_')) {
  1411. $headers[substr($key, 5)] = $value;
  1412. }
  1413. elseif (in_array($key, array('CONTENT_LENGTH', 'CONTENT_MD5', 'CONTENT_TYPE'))) {
  1414. $headers[$key] = $value;
  1415. }
  1416. }
  1417. if (isset($this->parameters['PHP_AUTH_USER'])) {
  1418. $headers['PHP_AUTH_USER'] = $this->parameters['PHP_AUTH_USER'];
  1419. $headers['PHP_AUTH_PW'] = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] : '';
  1420. } else {
  1421. $authorizationHeader = null;
  1422. if (isset($this->parameters['HTTP_AUTHORIZATION'])) {
  1423. $authorizationHeader = $this->parameters['HTTP_AUTHORIZATION'];
  1424. } elseif (isset($this->parameters['REDIRECT_HTTP_AUTHORIZATION'])) {
  1425. $authorizationHeader = $this->parameters['REDIRECT_HTTP_AUTHORIZATION'];
  1426. }
  1427. if ((null !== $authorizationHeader) && (0 === stripos($authorizationHeader, 'basic'))) {
  1428. $exploded = explode(':', base64_decode(substr($authorizationHeader, 6)));
  1429. if (count($exploded) == 2) {
  1430. list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded;
  1431. }
  1432. }
  1433. }
  1434. if (isset($headers['PHP_AUTH_USER'])) {
  1435. $headers['AUTHORIZATION'] = 'Basic '.base64_encode($headers['PHP_AUTH_USER'].':'.$headers['PHP_AUTH_PW']);
  1436. }
  1437. return $headers;
  1438. }
  1439. }
  1440. }
  1441. namespace Symfony\Component\HttpFoundation
  1442. {
  1443. class Request
  1444. {
  1445. protected static $trustProxy = false;
  1446. public $attributes;
  1447. public $request;
  1448. public $query;
  1449. public $server;
  1450. public $files;
  1451. public $cookies;
  1452. public $headers;
  1453. protected $content;
  1454. protected $languages;
  1455. protected $charsets;
  1456. protected $acceptableContentTypes;

Large files files are truncated, but you can click here to view the full file