PageRenderTime 77ms CodeModel.GetById 35ms RepoModel.GetById 0ms app.codeStats 2ms

/app/cache/prod/classes.php

https://bitbucket.org/pyneff/carsharing
PHP | 10461 lines | 6888 code | 2340 blank | 1233 comment | 856 complexity | ebfced95bec06120f349805c2e991833 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-3.0, BSD-3-Clause, BSD-2-Clause

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

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

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