PageRenderTime 65ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 1ms

/app/cache/dev/classes.php

https://bitbucket.org/duncanheron/symfony-tutorial
PHP | 8822 lines | 6229 code | 1521 blank | 1072 comment | 595 complexity | 0d2bb55f7db890eff0eb137afe702290 MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0, LGPL-2.1, LGPL-3.0

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. function start();
  40. function getId();
  41. function read($key);
  42. function remove($key);
  43. function write($key, $data);
  44. 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. static protected $sessionIdRegenerated = false;
  253. static protected $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. 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. 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\Route;
  351. use Symfony\Component\Routing\RouteCollection;
  352. use Symfony\Component\Routing\RequestContext;
  353. class UrlMatcher implements UrlMatcherInterface
  354. {
  355. protected $context;
  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. function redirect($path, $route, $scheme = null);
  526. }
  527. }
  528. namespace Symfony\Component\Routing
  529. {
  530. interface RequestContextAwareInterface
  531. {
  532. 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\UrlMatcher;
  764. use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface;
  765. class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface
  766. {
  767. public function redirect($path, $route, $scheme = null)
  768. {
  769. return array(
  770. '_controller' => 'Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController::urlRedirectAction',
  771. 'path' => $path,
  772. 'permanent' => true,
  773. 'scheme' => $scheme,
  774. 'httpPort' => $this->context->getHttpPort(),
  775. 'httpsPort' => $this->context->getHttpsPort(),
  776. '_route' => $route,
  777. );
  778. }
  779. }
  780. }
  781. namespace Symfony\Bundle\FrameworkBundle\Routing
  782. {
  783. use Symfony\Component\Routing\Router as BaseRouter;
  784. use Symfony\Component\Routing\RequestContext;
  785. use Symfony\Component\DependencyInjection\ContainerInterface;
  786. class Router extends BaseRouter
  787. {
  788. private $container;
  789. public function __construct(ContainerInterface $container, $resource, array $options = array(), RequestContext $context = null, array $defaults = array())
  790. {
  791. $this->container = $container;
  792. $this->resource = $resource;
  793. $this->context = null === $context ? new RequestContext() : $context;
  794. $this->defaults = $defaults;
  795. $this->setOptions($options);
  796. }
  797. public function getRouteCollection()
  798. {
  799. if (null === $this->collection) {
  800. $this->collection = $this->container->get('routing.loader')->load($this->resource, $this->options['resource_type']);
  801. }
  802. return $this->collection;
  803. }
  804. }
  805. }
  806. namespace Symfony\Bundle\FrameworkBundle\Templating
  807. {
  808. use Symfony\Component\DependencyInjection\ContainerInterface;
  809. class GlobalVariables
  810. {
  811. protected $container;
  812. public function __construct(ContainerInterface $container)
  813. {
  814. $this->container = $container;
  815. }
  816. public function getSecurity()
  817. {
  818. if ($this->container->has('security.context')) {
  819. return $this->container->get('security.context');
  820. }
  821. }
  822. public function getUser()
  823. {
  824. if (!$security = $this->getSecurity()) {
  825. return;
  826. }
  827. if (!$token = $security->getToken()) {
  828. return;
  829. }
  830. $user = $token->getUser();
  831. if (!is_object($user)) {
  832. return;
  833. }
  834. return $user;
  835. }
  836. public function getRequest()
  837. {
  838. if ($this->container->has('request') && $request = $this->container->get('request')) {
  839. return $request;
  840. }
  841. }
  842. public function getSession()
  843. {
  844. if ($request = $this->getRequest()) {
  845. return $request->getSession();
  846. }
  847. }
  848. public function getEnvironment()
  849. {
  850. return $this->container->getParameter('kernel.environment');
  851. }
  852. public function getDebug()
  853. {
  854. return (Boolean) $this->container->getParameter('kernel.debug');
  855. }
  856. }
  857. }
  858. namespace Symfony\Bundle\FrameworkBundle\Templating
  859. {
  860. use Symfony\Component\Templating\EngineInterface as BaseEngineInterface;
  861. use Symfony\Component\HttpFoundation\Response;
  862. interface EngineInterface extends BaseEngineInterface
  863. {
  864. function renderResponse($view, array $parameters = array(), Response $response = null);
  865. }
  866. }
  867. namespace Symfony\Component\Templating
  868. {
  869. interface TemplateNameParserInterface
  870. {
  871. function parse($name);
  872. }
  873. }
  874. namespace Symfony\Component\Templating
  875. {
  876. use Symfony\Component\Templating\TemplateReferenceInterface;
  877. use Symfony\Component\Templating\TemplateReference;
  878. class TemplateNameParser implements TemplateNameParserInterface
  879. {
  880. public function parse($name)
  881. {
  882. if ($name instanceof TemplateReferenceInterface) {
  883. return $name;
  884. }
  885. $engine = null;
  886. if (false !== $pos = strrpos($name, '.')) {
  887. $engine = substr($name, $pos + 1);
  888. }
  889. return new TemplateReference($name, $engine);
  890. }
  891. }
  892. }
  893. namespace Symfony\Component\Templating
  894. {
  895. interface EngineInterface
  896. {
  897. function render($name, array $parameters = array());
  898. function exists($name);
  899. function supports($name);
  900. }
  901. }
  902. namespace Symfony\Component\Config
  903. {
  904. interface FileLocatorInterface
  905. {
  906. function locate($name, $currentPath = null, $first = true);
  907. }
  908. }
  909. namespace Symfony\Component\Templating
  910. {
  911. interface TemplateReferenceInterface
  912. {
  913. function all();
  914. function set($name, $value);
  915. function get($name);
  916. function getPath();
  917. function getLogicalName();
  918. }
  919. }
  920. namespace Symfony\Component\Templating
  921. {
  922. class TemplateReference implements TemplateReferenceInterface
  923. {
  924. protected $parameters;
  925. public function __construct($name = null, $engine = null)
  926. {
  927. $this->parameters = array(
  928. 'name' => $name,
  929. 'engine' => $engine,
  930. );
  931. }
  932. public function __toString()
  933. {
  934. return $this->getLogicalName();
  935. }
  936. public function set($name, $value)
  937. {
  938. if (array_key_exists($name, $this->parameters)) {
  939. $this->parameters[$name] = $value;
  940. } else {
  941. throw new \InvalidArgumentException(sprintf('The template does not support the "%s" parameter.', $name));
  942. }
  943. return $this;
  944. }
  945. public function get($name)
  946. {
  947. if (array_key_exists($name, $this->parameters)) {
  948. return $this->parameters[$name];
  949. }
  950. throw new \InvalidArgumentException(sprintf('The template does not support the "%s" parameter.', $name));
  951. }
  952. public function all()
  953. {
  954. return $this->parameters;
  955. }
  956. public function getPath()
  957. {
  958. return $this->parameters['name'];
  959. }
  960. public function getLogicalName()
  961. {
  962. return $this->parameters['name'];
  963. }
  964. }
  965. }
  966. namespace Symfony\Bundle\FrameworkBundle\Templating
  967. {
  968. use Symfony\Component\Templating\TemplateReference as BaseTemplateReference;
  969. class TemplateReference extends BaseTemplateReference
  970. {
  971. public function __construct($bundle = null, $controller = null, $name = null, $format = null, $engine = null)
  972. {
  973. $this->parameters = array(
  974. 'bundle' => $bundle,
  975. 'controller' => $controller,
  976. 'name' => $name,
  977. 'format' => $format,
  978. 'engine' => $engine,
  979. );
  980. }
  981. public function getPath()
  982. {
  983. $controller = str_replace('\\', '/', $this->get('controller'));
  984. $path = (empty($controller) ? '' : $controller.'/').$this->get('name').'.'.$this->get('format').'.'.$this->get('engine');
  985. return empty($this->parameters['bundle']) ? 'views/'.$path : '@'.$this->get('bundle').'/Resources/views/'.$path;
  986. }
  987. public function getLogicalName()
  988. {
  989. return sprintf('%s:%s:%s.%s.%s', $this->parameters['bundle'], $this->parameters['controller'], $this->parameters['name'], $this->parameters['format'], $this->parameters['engine']);
  990. }
  991. }
  992. }
  993. namespace Symfony\Bundle\FrameworkBundle\Templating
  994. {
  995. use Symfony\Component\Templating\TemplateNameParser as BaseTemplateNameParser;
  996. use Symfony\Component\Templating\TemplateReferenceInterface;
  997. use Symfony\Component\HttpKernel\KernelInterface;
  998. class TemplateNameParser extends BaseTemplateNameParser
  999. {
  1000. protected $kernel;
  1001. protected $cache;
  1002. public function __construct(KernelInterface $kernel)
  1003. {
  1004. $this->kernel = $kernel;
  1005. $this->cache = array();
  1006. }
  1007. public function parse($name)
  1008. {
  1009. if ($name instanceof TemplateReferenceInterface) {
  1010. return $name;
  1011. } else if (isset($this->cache[$name])) {
  1012. return $this->cache[$name];
  1013. }
  1014. $name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')));
  1015. if (false !== strpos($name, '..')) {
  1016. throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name));
  1017. }
  1018. $parts = explode(':', $name);
  1019. if (3 !== count($parts)) {
  1020. throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid (format is "bundle:section:template.format.engine").', $name));
  1021. }
  1022. $elements = explode('.', $parts[2]);
  1023. if (3 > count($elements)) {
  1024. throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid (format is "bundle:section:template.format.engine").', $name));
  1025. }
  1026. $engine = array_pop($elements);
  1027. $format = array_pop($elements);
  1028. $template = new TemplateReference($parts[0], $parts[1], implode('.', $elements), $format, $engine);
  1029. if ($template->get('bundle')) {
  1030. try {
  1031. $this->kernel->getBundle($template->get('bundle'));
  1032. } catch (\Exception $e) {
  1033. throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid.', $name), 0, $e);
  1034. }
  1035. }
  1036. return $this->cache[$name] = $template;
  1037. }
  1038. public function parseFromFilename($file)
  1039. {
  1040. $parts = explode('/', strtr($file, '\\', '/'));
  1041. $elements = explode('.', array_pop($parts));
  1042. if (3 > count($elements)) {
  1043. return false;
  1044. }
  1045. $engine = array_pop($elements);
  1046. $format = array_pop($elements);
  1047. return new TemplateReference('', implode('/', $parts), implode('.', $elements), $format, $engine);
  1048. }
  1049. }
  1050. }
  1051. namespace Symfony\Bundle\FrameworkBundle\Templating\Loader
  1052. {
  1053. use Symfony\Component\Config\FileLocatorInterface;
  1054. use Symfony\Component\Templating\TemplateReferenceInterface;
  1055. class TemplateLocator implements FileLocatorInterface
  1056. {
  1057. protected $locator;
  1058. protected $path;
  1059. protected $cache;
  1060. public function __construct(FileLocatorInterface $locator, $cacheDir = null)
  1061. {
  1062. if (null !== $cacheDir && file_exists($cache = $cacheDir.'/templates.php')) {
  1063. $this->cache = require $cache;
  1064. }
  1065. $this->locator = $locator;
  1066. }
  1067. public function locate($template, $currentPath = null, $first = true)
  1068. {
  1069. if (!$template instanceof TemplateReferenceInterface) {
  1070. throw new \InvalidArgumentException("The template must be an instance of TemplateReferenceInterface.");
  1071. }
  1072. $key = $template->getLogicalName();
  1073. if (isset($this->cache[$key])) {
  1074. return $this->cache[$key];
  1075. }
  1076. try {
  1077. return $this->cache[$key] = $this->locator->locate($template->getPath(), $currentPath);
  1078. } catch (\InvalidArgumentException $e) {
  1079. throw new \InvalidArgumentException(sprintf('Unable to find template "%s" in "%s".', $template, $this->path), 0, $e);
  1080. }
  1081. }
  1082. }
  1083. }
  1084. namespace Symfony\Component\HttpFoundation
  1085. {
  1086. class ParameterBag
  1087. {
  1088. protected $parameters;
  1089. public function __construct(array $parameters = array())
  1090. {
  1091. $this->parameters = $parameters;
  1092. }
  1093. public function all()
  1094. {
  1095. return $this->parameters;
  1096. }
  1097. public function keys()
  1098. {
  1099. return array_keys($this->parameters);
  1100. }
  1101. public function replace(array $parameters = array())
  1102. {
  1103. $this->parameters = $parameters;
  1104. }
  1105. public function add(array $parameters = array())
  1106. {
  1107. $this->parameters = array_replace($this->parameters, $parameters);
  1108. }
  1109. public function get($path, $default = null, $deep = false)
  1110. {
  1111. if (!$deep || false === $pos = strpos($path, '[')) {
  1112. return array_key_exists($path, $this->parameters) ? $this->parameters[$path] : $default;
  1113. }
  1114. $root = substr($path, 0, $pos);
  1115. if (!array_key_exists($root, $this->parameters)) {
  1116. return $default;
  1117. }
  1118. $value = $this->parameters[$root];
  1119. $currentKey = null;
  1120. for ($i=$pos,$c=strlen($path); $i<$c; $i++) {
  1121. $char = $path[$i];
  1122. if ('[' === $char) {
  1123. if (null !== $currentKey) {
  1124. throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "[" at position %d.', $i));
  1125. }
  1126. $currentKey = '';
  1127. } else if (']' === $char) {
  1128. if (null === $currentKey) {
  1129. throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "]" at position %d.', $i));
  1130. }
  1131. if (!is_array($value) || !array_key_exists($currentKey, $value)) {
  1132. return $default;
  1133. }
  1134. $value = $value[$currentKey];
  1135. $currentKey = null;
  1136. } else {
  1137. if (null === $currentKey) {
  1138. throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "%s" at position %d.', $char, $i));
  1139. }
  1140. $currentKey .= $char;
  1141. }
  1142. }
  1143. if (null !== $currentKey) {
  1144. throw new \InvalidArgumentException(sprintf('Malformed path. Path must end with "]".'));
  1145. }
  1146. return $value;
  1147. }
  1148. public function set($key, $value)
  1149. {
  1150. $this->parameters[$key] = $value;
  1151. }
  1152. public function has($key)
  1153. {
  1154. return array_key_exists($key, $this->parameters);
  1155. }
  1156. public function remove($key)
  1157. {
  1158. unset($this->parameters[$key]);
  1159. }
  1160. public function getAlpha($key, $default = '', $deep = false)
  1161. {
  1162. return preg_replace('/[^[:alpha:]]/', '', $this->get($key, $default, $deep));
  1163. }
  1164. public function getAlnum($key, $default = '', $deep = false)
  1165. {
  1166. return preg_replace('/[^[:alnum:]]/', '', $this->get($key, $default, $deep));
  1167. }
  1168. public function getDigits($key, $default = '', $deep = false)
  1169. {
  1170. return preg_replace('/[^[:digit:]]/', '', $this->get($key, $default, $deep));
  1171. }
  1172. public function getInt($key, $default = 0, $deep = false)
  1173. {
  1174. return (int) $this->get($key, $default, $deep);
  1175. }
  1176. }
  1177. }
  1178. namespace Symfony\Component\HttpFoundation
  1179. {
  1180. class HeaderBag
  1181. {
  1182. protected $headers;
  1183. protected $cacheControl;
  1184. public function __construct(array $headers = array())
  1185. {
  1186. $this->cacheControl = array();
  1187. $this->headers = array();
  1188. foreach ($headers as $key => $values) {
  1189. $this->set($key, $values);
  1190. }
  1191. }
  1192. public function __toString()
  1193. {
  1194. if (!$this->headers) {
  1195. return '';
  1196. }
  1197. $beautifier = function ($name) {
  1198. return preg_replace_callback('/\-(.)/', function ($match) { return '-'.strtoupper($match[1]); }, ucfirst($name));
  1199. };
  1200. $max = max(array_map('strlen', array_keys($this->headers))) + 1;
  1201. $content = '';
  1202. ksort($this->headers);
  1203. foreach ($this->headers as $name => $values) {
  1204. foreach ($values as $value) {
  1205. $content .= sprintf("%-{$max}s %s\r\n", $beautifier($name).':', $value);
  1206. }
  1207. }
  1208. return $content;
  1209. }
  1210. public function all()
  1211. {
  1212. return $this->headers;
  1213. }
  1214. public function keys()
  1215. {
  1216. return array_keys($this->headers);
  1217. }
  1218. public function replace(array $headers = array())
  1219. {
  1220. $this->headers = array();
  1221. $this->add($headers);
  1222. }
  1223. public function add(array $headers)
  1224. {
  1225. foreach ($headers as $key => $values) {
  1226. $this->set($key, $values);
  1227. }
  1228. }
  1229. public function get($key, $default = null, $first = true)
  1230. {
  1231. $key = strtr(strtolower($key), '_', '-');
  1232. if (!array_key_exists($key, $this->headers)) {
  1233. if (null === $default) {
  1234. return $first ? null : array();
  1235. }
  1236. return $first ? $default : array($default);
  1237. }
  1238. if ($first) {
  1239. return count($this->headers[$key]) ? $this->headers[$key][0] : $default;
  1240. }
  1241. return $this->headers[$key];
  1242. }
  1243. public function set($key, $values, $replace = true)
  1244. {
  1245. $key = strtr(strtolower($key), '_', '-');
  1246. $values = (array) $values;
  1247. if (true === $replace || !isset($this->headers[$key])) {
  1248. $this->headers[$key] = $values;
  1249. } else {
  1250. $this->headers[$key] = array_merge($this->headers[$key], $values);
  1251. }
  1252. if ('cache-control' === $key) {
  1253. $this->cacheControl = $this->parseCacheControl($values[0]);
  1254. }
  1255. }
  1256. public function has($key)
  1257. {
  1258. return array_key_exists(strtr(strtolower($key), '_', '-'), $this->headers);
  1259. }
  1260. public function contains($key, $value)
  1261. {
  1262. return in_array($value, $this->get($key, null, false));
  1263. }
  1264. public function remove($key)
  1265. {
  1266. $key = strtr(strtolower($key), '_', '-');
  1267. unset($this->headers[$key]);
  1268. if ('cache-control' === $key) {
  1269. $this->cacheControl = array();
  1270. }
  1271. }
  1272. public function getDate($key, \DateTime $default = null)
  1273. {
  1274. if (null === $value = $this->get($key)) {
  1275. return $default;
  1276. }
  1277. if (false === $date = \DateTime::createFromFormat(DATE_RFC2822, $value)) {
  1278. throw new \RuntimeException(sprintf('The %s HTTP header is not parseable (%s).', $key, $value));
  1279. }
  1280. return $date;
  1281. }
  1282. public function addCacheControlDirective($key, $value = true)
  1283. {
  1284. $this->cacheControl[$key] = $value;
  1285. $this->set('Cache-Control', $this->getCacheControlHeader());
  1286. }
  1287. public function hasCacheControlDirective($key)
  1288. {
  1289. return array_key_exists($key, $this->cacheControl);
  1290. }
  1291. public function getCacheControlDirective($key)
  1292. {
  1293. return array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null;
  1294. }
  1295. public function removeCacheControlDirective($key)
  1296. {
  1297. unset($this->cacheControl[$key]);
  1298. $this->set('Cache-Control', $this->getCacheControlHeader());
  1299. }
  1300. protected function getCacheControlHeader()
  1301. {
  1302. $parts = array();
  1303. ksort($this->cacheControl);
  1304. foreach ($this->cacheControl as $key => $value) {
  1305. if (true === $value) {
  1306. $parts[] = $key;
  1307. } else {
  1308. if (preg_match('#[^a-zA-Z0-9._-]#', $value)) {
  1309. $value = '"'.$value.'"';
  1310. }
  1311. $parts[] = "$key=$value";
  1312. }
  1313. }
  1314. return implode(', ', $parts);
  1315. }
  1316. protected function parseCacheControl($header)
  1317. {
  1318. $cacheControl = array();
  1319. preg_match_all('#([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?#', $header, $matches, PREG_SET_ORDER);
  1320. foreach ($matches as $match) {
  1321. $cacheControl[strtolower($match[1])] = isset($match[2]) && $match[2] ? $match[2] : (isset($match[3]) ? $match[3] : true);
  1322. }
  1323. return $cacheControl;
  1324. }
  1325. }
  1326. }
  1327. namespace Symfony\Component\HttpFoundation
  1328. {
  1329. use Symfony\Component\HttpFoundation\File\UploadedFile;
  1330. class FileBag extends ParameterBag
  1331. {
  1332. static private $fileKeys = array('error', 'name', 'size', 'tmp_name', 'type');
  1333. public function __construct(array $parameters = array())
  1334. {
  1335. $this->replace($parameters);
  1336. }
  1337. public function replace(array $files = array())
  1338. {
  1339. $this->parameters = array();
  1340. $this->add($files);
  1341. }
  1342. public function set($key, $value)
  1343. {
  1344. if (is_array($value) || $value instanceof UploadedFile) {
  1345. parent::set($key, $this->convertFileInformation($value));
  1346. } else {
  1347. throw new \InvalidArgumentException('An uploaded file must be an array or an instance of UploadedFile.');
  1348. }
  1349. }
  1350. public function add(array $files = array())
  1351. {
  1352. foreach ($files as $key => $file) {
  1353. $this->set($key, $file);
  1354. }
  1355. }
  1356. protected function convertFileInformation($file)
  1357. {
  1358. if ($file instanceof UploadedFile) {
  1359. return $file;
  1360. }
  1361. $file = $this->fixPhpFilesArray($file);
  1362. if (is_array($file)) {
  1363. $keys = array_keys($file);
  1364. sort($keys);
  1365. if ($keys == self::$fileKeys) {
  1366. if (UPLOAD_ERR_NO_FILE == $file['error']) {
  1367. $file = null;
  1368. } else {
  1369. $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error']);
  1370. }
  1371. } else {
  1372. $file = array_map(array($this, 'convertFileInformation'), $file);
  1373. }
  1374. }
  1375. return $file;
  1376. }
  1377. protected function fixPhpFilesArray($data)
  1378. {
  1379. if (!is_array($data)) {
  1380. return $data;
  1381. }
  1382. $keys = array_keys($data);
  1383. sort($keys);
  1384. if (self::$fileKeys != $keys || !isset($data['name']) || !is_array($data['name'])) {
  1385. return $data;
  1386. }
  1387. $files = $data;
  1388. foreach (self::$fileKeys as $k) {
  1389. unset($files[$k]);
  1390. }
  1391. foreach (array_keys($data['name']) as $key) {
  1392. $files[$key] = $this->fixPhpFilesArray(array(
  1393. 'error' => $data['error'][$key],
  1394. 'name' => $data['name'][$key],
  1395. 'type' => $data['type'][$key],
  1396. 'tmp_name' => $data['tmp_name'][$key],
  1397. 'size' => $data['size'][$key]
  1398. ));
  1399. }
  1400. return $files;
  1401. }
  1402. }
  1403. }
  1404. namespace Symfony\Component\HttpFoundation
  1405. {
  1406. class ServerBag extends ParameterBag
  1407. {
  1408. public function getHeaders()
  1409. {
  1410. $headers = array();
  1411. foreach ($this->parameters as $key => $value) {
  1412. if ('HTTP_' === substr($key, 0, 5)) {
  1413. $headers[substr($key, 5)] = $value;
  1414. }
  1415. elseif (in_array($key, array('CONTENT_LENGTH', 'CONTENT_MD5', 'CONTENT_TYPE'))) {
  1416. $headers[$key] = $this->parameters[$key];
  1417. }
  1418. }
  1419. if (isset($this->parameters['PHP_AUTH_USER'])) {
  1420. $pass = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] : '';
  1421. $headers['AUTHORIZATION'] = 'Basic '.base64_encode($this->parameters['PHP_AUTH_USER'].':'.$pass);
  1422. }
  1423. return $headers;
  1424. }
  1425. }
  1426. }
  1427. namespace Symfony\Component\HttpFoundation
  1428. {
  1429. class Request
  1430. {
  1431. static protected $trustProxy = false;
  1432. public $attributes;
  1433. public $request;
  1434. public $query;
  1435. public $server;
  1436. public $files;
  1437. public $cookies;
  1438. public $headers;
  1439. protected $content;
  1440. protected $languages;
  1441. protected $charsets;
  1442. protected $acceptableContentTypes;
  1443. protected $pathInfo;
  1444. protected $requestUri;
  1445. protected $baseUrl;
  1446. protected $basePath;
  1447. protected $method;
  1448. protected $format;
  1449. protected $session;
  1450. static protected $formats;
  1451. public function __construct(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
  1452. {
  1453. $this->initialize($query, $request, $attributes, $cookies, $files, $server, $content);
  1454. }
  1455. public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
  1456. {
  1457. $this->request = new ParameterBag($request);
  1458. $this->query = new ParameterBag($query);
  1459. $this->attributes = new ParameterBag($attributes);
  1460. $this->cookies = new ParameterBag($cookies);
  1461. $this->

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