/app/cache/dev/classes.php
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
- <?php
- namespace Symfony\Bundle\FrameworkBundle\EventListener
- {
- use Symfony\Component\DependencyInjection\ContainerInterface;
- use Symfony\Component\HttpKernel\HttpKernelInterface;
- use Symfony\Component\HttpKernel\Event\GetResponseEvent;
- class SessionListener
- {
- private $container;
- private $autoStart;
- public function __construct(ContainerInterface $container, $autoStart = false)
- {
- $this->container = $container;
- $this->autoStart = $autoStart;
- }
- public function onKernelRequest(GetResponseEvent $event)
- {
- if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
- return;
- }
- if (!$this->container->has('session')) {
- return;
- }
- $request = $event->getRequest();
- if ($request->hasSession()) {
- return;
- }
- $request->setSession($session = $this->container->get('session'));
- if ($this->autoStart || $request->hasPreviousSession()) {
- $session->start();
- }
- }
- }
- }
-
- namespace Symfony\Component\HttpFoundation\SessionStorage
- {
- interface SessionStorageInterface
- {
-
- function start();
-
- function getId();
-
- function read($key);
-
- function remove($key);
-
- function write($key, $data);
-
- function regenerate($destroy = false);
- }
- }
-
- namespace Symfony\Component\HttpFoundation
- {
- use Symfony\Component\HttpFoundation\SessionStorage\SessionStorageInterface;
- class Session implements \Serializable
- {
- protected $storage;
- protected $started;
- protected $attributes;
- protected $flashes;
- protected $oldFlashes;
- protected $locale;
- protected $defaultLocale;
- protected $closed;
-
- public function __construct(SessionStorageInterface $storage, $defaultLocale = 'en')
- {
- $this->storage = $storage;
- $this->defaultLocale = $defaultLocale;
- $this->locale = $defaultLocale;
- $this->flashes = array();
- $this->oldFlashes = array();
- $this->attributes = array();
- $this->setPhpDefaultLocale($this->defaultLocale);
- $this->started = false;
- $this->closed = false;
- }
-
- public function start()
- {
- if (true === $this->started) {
- return;
- }
- $this->storage->start();
- $attributes = $this->storage->read('_symfony2');
- if (isset($attributes['attributes'])) {
- $this->attributes = $attributes['attributes'];
- $this->flashes = $attributes['flashes'];
- $this->locale = $attributes['locale'];
- $this->setPhpDefaultLocale($this->locale);
- $this->oldFlashes = $this->flashes;
- }
- $this->started = true;
- }
-
- public function has($name)
- {
- return array_key_exists($name, $this->attributes);
- }
-
- public function get($name, $default = null)
- {
- return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
- }
-
- public function set($name, $value)
- {
- if (false === $this->started) {
- $this->start();
- }
- $this->attributes[$name] = $value;
- }
-
- public function all()
- {
- return $this->attributes;
- }
-
- public function replace(array $attributes)
- {
- if (false === $this->started) {
- $this->start();
- }
- $this->attributes = $attributes;
- }
-
- public function remove($name)
- {
- if (false === $this->started) {
- $this->start();
- }
- if (array_key_exists($name, $this->attributes)) {
- unset($this->attributes[$name]);
- }
- }
-
- public function clear()
- {
- if (false === $this->started) {
- $this->start();
- }
- $this->attributes = array();
- $this->flashes = array();
- $this->setPhpDefaultLocale($this->locale = $this->defaultLocale);
- }
-
- public function invalidate()
- {
- $this->clear();
- $this->storage->regenerate(true);
- }
-
- public function migrate()
- {
- $this->storage->regenerate();
- }
-
- public function getId()
- {
- if (false === $this->started) {
- $this->start();
- }
- return $this->storage->getId();
- }
-
- public function getLocale()
- {
- return $this->locale;
- }
-
- public function setLocale($locale)
- {
- if (false === $this->started) {
- $this->start();
- }
- $this->setPhpDefaultLocale($this->locale = $locale);
- }
-
- public function getFlashes()
- {
- return $this->flashes;
- }
-
- public function setFlashes($values)
- {
- if (false === $this->started) {
- $this->start();
- }
- $this->flashes = $values;
- $this->oldFlashes = array();
- }
-
- public function getFlash($name, $default = null)
- {
- return array_key_exists($name, $this->flashes) ? $this->flashes[$name] : $default;
- }
-
- public function setFlash($name, $value)
- {
- if (false === $this->started) {
- $this->start();
- }
- $this->flashes[$name] = $value;
- unset($this->oldFlashes[$name]);
- }
-
- public function hasFlash($name)
- {
- if (false === $this->started) {
- $this->start();
- }
- return array_key_exists($name, $this->flashes);
- }
-
- public function removeFlash($name)
- {
- if (false === $this->started) {
- $this->start();
- }
- unset($this->flashes[$name]);
- }
-
- public function clearFlashes()
- {
- if (false === $this->started) {
- $this->start();
- }
- $this->flashes = array();
- $this->oldFlashes = array();
- }
- public function save()
- {
- if (false === $this->started) {
- $this->start();
- }
- $this->flashes = array_diff_key($this->flashes, $this->oldFlashes);
- $this->storage->write('_symfony2', array(
- 'attributes' => $this->attributes,
- 'flashes' => $this->flashes,
- 'locale' => $this->locale,
- ));
- }
-
- public function close()
- {
- $this->closed = true;
- }
- public function __destruct()
- {
- if (true === $this->started && !$this->closed) {
- $this->save();
- }
- }
- public function serialize()
- {
- return serialize(array($this->storage, $this->defaultLocale));
- }
- public function unserialize($serialized)
- {
- list($this->storage, $this->defaultLocale) = unserialize($serialized);
- $this->attributes = array();
- $this->started = false;
- }
- private function setPhpDefaultLocale($locale)
- {
- try {
- if (class_exists('Locale', false)) {
- \Locale::setDefault($locale);
- }
- } catch (\Exception $e) {
- }
- }
- }
- }
-
- namespace Symfony\Component\HttpFoundation\SessionStorage
- {
- class NativeSessionStorage implements SessionStorageInterface
- {
- static protected $sessionIdRegenerated = false;
- static protected $sessionStarted = false;
- protected $options;
-
- public function __construct(array $options = array())
- {
- $cookieDefaults = session_get_cookie_params();
- $this->options = array_merge(array(
- 'lifetime' => $cookieDefaults['lifetime'],
- 'path' => $cookieDefaults['path'],
- 'domain' => $cookieDefaults['domain'],
- 'secure' => $cookieDefaults['secure'],
- 'httponly' => isset($cookieDefaults['httponly']) ? $cookieDefaults['httponly'] : false,
- ), $options);
- if (isset($this->options['name'])) {
- session_name($this->options['name']);
- }
- }
-
- public function start()
- {
- if (self::$sessionStarted) {
- return;
- }
- session_set_cookie_params(
- $this->options['lifetime'],
- $this->options['path'],
- $this->options['domain'],
- $this->options['secure'],
- $this->options['httponly']
- );
- session_cache_limiter(false);
- if (!ini_get('session.use_cookies') && isset($this->options['id']) && $this->options['id'] && $this->options['id'] != session_id()) {
- session_id($this->options['id']);
- }
- session_start();
- self::$sessionStarted = true;
- }
-
- public function getId()
- {
- if (!self::$sessionStarted) {
- throw new \RuntimeException('The session must be started before reading its ID');
- }
- return session_id();
- }
-
- public function read($key, $default = null)
- {
- return array_key_exists($key, $_SESSION) ? $_SESSION[$key] : $default;
- }
-
- public function remove($key)
- {
- $retval = null;
- if (isset($_SESSION[$key])) {
- $retval = $_SESSION[$key];
- unset($_SESSION[$key]);
- }
- return $retval;
- }
-
- public function write($key, $data)
- {
- $_SESSION[$key] = $data;
- }
-
- public function regenerate($destroy = false)
- {
- if (self::$sessionIdRegenerated) {
- return;
- }
- session_regenerate_id($destroy);
- self::$sessionIdRegenerated = true;
- }
- }
- }
-
- namespace Symfony\Component\Routing\Matcher
- {
- use Symfony\Component\Routing\RequestContextAwareInterface;
- interface UrlMatcherInterface extends RequestContextAwareInterface
- {
-
- function match($pathinfo);
- }
- }
-
- namespace Symfony\Component\Routing\Generator
- {
- use Symfony\Component\Routing\RequestContextAwareInterface;
- interface UrlGeneratorInterface extends RequestContextAwareInterface
- {
-
- function generate($name, $parameters = array(), $absolute = false);
- }
- }
-
- namespace Symfony\Component\Routing
- {
- use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
- use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
- interface RouterInterface extends UrlMatcherInterface, UrlGeneratorInterface
- {
- }
- }
-
- namespace Symfony\Component\Routing\Matcher
- {
- use Symfony\Component\Routing\Exception\MethodNotAllowedException;
- use Symfony\Component\Routing\Exception\ResourceNotFoundException;
- use Symfony\Component\Routing\Route;
- use Symfony\Component\Routing\RouteCollection;
- use Symfony\Component\Routing\RequestContext;
- class UrlMatcher implements UrlMatcherInterface
- {
- protected $context;
- private $routes;
-
- public function __construct(RouteCollection $routes, RequestContext $context)
- {
- $this->routes = $routes;
- $this->context = $context;
- }
-
- public function setContext(RequestContext $context)
- {
- $this->context = $context;
- }
-
- public function getContext()
- {
- return $this->context;
- }
-
- public function match($pathinfo)
- {
- $this->allow = array();
- if ($ret = $this->matchCollection($pathinfo, $this->routes)) {
- return $ret;
- }
- throw 0 < count($this->allow)
- ? new MethodNotAllowedException(array_unique(array_map('strtoupper', $this->allow)))
- : new ResourceNotFoundException();
- }
- protected function matchCollection($pathinfo, RouteCollection $routes)
- {
- $pathinfo = urldecode($pathinfo);
- foreach ($routes as $name => $route) {
- if ($route instanceof RouteCollection) {
- if (false === strpos($route->getPrefix(), '{') && $route->getPrefix() !== substr($pathinfo, 0, strlen($route->getPrefix()))) {
- continue;
- }
- if (!$ret = $this->matchCollection($pathinfo, $route)) {
- continue;
- }
- return $ret;
- }
- $compiledRoute = $route->compile();
- if ('' !== $compiledRoute->getStaticPrefix() && 0 !== strpos($pathinfo, $compiledRoute->getStaticPrefix())) {
- continue;
- }
- if (!preg_match($compiledRoute->getRegex(), $pathinfo, $matches)) {
- continue;
- }
- if ($req = $route->getRequirement('_method')) {
- if ('HEAD' === $method = $this->context->getMethod()) {
- $method = 'GET';
- }
- if (!in_array($method, $req = explode('|', strtoupper($req)))) {
- $this->allow = array_merge($this->allow, $req);
- continue;
- }
- }
- return array_merge($this->mergeDefaults($matches, $route->getDefaults()), array('_route' => $name));
- }
- }
- protected function mergeDefaults($params, $defaults)
- {
- $parameters = $defaults;
- foreach ($params as $key => $value) {
- if (!is_int($key)) {
- $parameters[$key] = rawurldecode($value);
- }
- }
- return $parameters;
- }
- }
- }
-
- namespace Symfony\Component\Routing\Generator
- {
- use Symfony\Component\Routing\Route;
- use Symfony\Component\Routing\RouteCollection;
- use Symfony\Component\Routing\RequestContext;
- use Symfony\Component\Routing\Exception\InvalidParameterException;
- use Symfony\Component\Routing\Exception\RouteNotFoundException;
- use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
- class UrlGenerator implements UrlGeneratorInterface
- {
- protected $context;
- protected $decodedChars = array(
- '%2F' => '/',
- );
- protected $routes;
- protected $cache;
-
- public function __construct(RouteCollection $routes, RequestContext $context)
- {
- $this->routes = $routes;
- $this->context = $context;
- $this->cache = array();
- }
-
- public function setContext(RequestContext $context)
- {
- $this->context = $context;
- }
-
- public function getContext()
- {
- return $this->context;
- }
-
- public function generate($name, $parameters = array(), $absolute = false)
- {
- if (null === $route = $this->routes->get($name)) {
- throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name));
- }
- if (!isset($this->cache[$name])) {
- $this->cache[$name] = $route->compile();
- }
- return $this->doGenerate($this->cache[$name]->getVariables(), $route->getDefaults(), $route->getRequirements(), $this->cache[$name]->getTokens(), $parameters, $name, $absolute);
- }
-
- protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $absolute)
- {
- $variables = array_flip($variables);
- $originParameters = $parameters;
- $parameters = array_replace($this->context->getParameters(), $parameters);
- $tparams = array_replace($defaults, $parameters);
- if ($diff = array_diff_key($variables, $tparams)) {
- throw new MissingMandatoryParametersException(sprintf('The "%s" route has some missing mandatory parameters ("%s").', $name, implode('", "', array_keys($diff))));
- }
- $url = '';
- $optional = true;
- foreach ($tokens as $token) {
- if ('variable' === $token[0]) {
- if (false === $optional || !array_key_exists($token[3], $defaults) || (isset($parameters[$token[3]]) && (string) $parameters[$token[3]] != (string) $defaults[$token[3]])) {
- if (!$isEmpty = in_array($tparams[$token[3]], array(null, '', false), true)) {
- if ($tparams[$token[3]] && !preg_match('#^'.$token[2].'$#', $tparams[$token[3]])) {
- throw new InvalidParameterException(sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given).', $token[3], $name, $token[2], $tparams[$token[3]]));
- }
- }
- if (!$isEmpty || !$optional) {
- $url = $token[1].strtr(rawurlencode($tparams[$token[3]]), $this->decodedChars).$url;
- }
- $optional = false;
- }
- } elseif ('text' === $token[0]) {
- $url = $token[1].$url;
- $optional = false;
- }
- }
- if (!$url) {
- $url = '/';
- }
- $extra = array_diff_key($originParameters, $variables, $defaults);
- if ($extra && $query = http_build_query($extra)) {
- $url .= '?'.$query;
- }
- $url = $this->context->getBaseUrl().$url;
- if ($this->context->getHost()) {
- $scheme = $this->context->getScheme();
- if (isset($requirements['_scheme']) && ($req = strtolower($requirements['_scheme'])) && $scheme != $req) {
- $absolute = true;
- $scheme = $req;
- }
- if ($absolute) {
- $port = '';
- if ('http' === $scheme && 80 != $this->context->getHttpPort()) {
- $port = ':'.$this->context->getHttpPort();
- } elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) {
- $port = ':'.$this->context->getHttpsPort();
- }
- $url = $scheme.'://'.$this->context->getHost().$port.$url;
- }
- }
- return $url;
- }
- }
- }
-
- namespace Symfony\Component\Routing\Matcher
- {
- interface RedirectableUrlMatcherInterface
- {
-
- function redirect($path, $route, $scheme = null);
- }
- }
-
- namespace Symfony\Component\Routing
- {
- interface RequestContextAwareInterface
- {
-
- function setContext(RequestContext $context);
- }
- }
-
- namespace Symfony\Component\Routing
- {
- class RequestContext
- {
- private $baseUrl;
- private $method;
- private $host;
- private $scheme;
- private $httpPort;
- private $httpsPort;
- private $parameters;
-
- public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $scheme = 'http', $httpPort = 80, $httpsPort = 443)
- {
- $this->baseUrl = $baseUrl;
- $this->method = strtoupper($method);
- $this->host = $host;
- $this->scheme = strtolower($scheme);
- $this->httpPort = $httpPort;
- $this->httpsPort = $httpsPort;
- $this->parameters = array();
- }
-
- public function getBaseUrl()
- {
- return $this->baseUrl;
- }
-
- public function setBaseUrl($baseUrl)
- {
- $this->baseUrl = $baseUrl;
- }
-
- public function getMethod()
- {
- return $this->method;
- }
-
- public function setMethod($method)
- {
- $this->method = strtoupper($method);
- }
-
- public function getHost()
- {
- return $this->host;
- }
-
- public function setHost($host)
- {
- $this->host = $host;
- }
-
- public function getScheme()
- {
- return $this->scheme;
- }
-
- public function setScheme($scheme)
- {
- $this->scheme = strtolower($scheme);
- }
-
- public function getHttpPort()
- {
- return $this->httpPort;
- }
-
- public function setHttpPort($httpPort)
- {
- $this->httpPort = $httpPort;
- }
-
- public function getHttpsPort()
- {
- return $this->httpsPort;
- }
-
- public function setHttpsPort($httpsPort)
- {
- $this->httpsPort = $httpsPort;
- }
-
- public function getParameters()
- {
- return $this->parameters;
- }
-
- public function setParameters(array $parameters)
- {
- $this->parameters = $parameters;
- return $this;
- }
-
- public function getParameter($name)
- {
- return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
- }
-
- public function hasParameter($name)
- {
- return array_key_exists($name, $this->parameters);
- }
-
- public function setParameter($name, $parameter)
- {
- $this->parameters[$name] = $parameter;
- }
- }
- }
-
- namespace Symfony\Component\Routing
- {
- use Symfony\Component\Config\Loader\LoaderInterface;
- use Symfony\Component\Config\ConfigCache;
- class Router implements RouterInterface
- {
- protected $matcher;
- protected $generator;
- protected $defaults;
- protected $context;
- protected $loader;
- protected $collection;
- protected $resource;
- protected $options;
-
- public function __construct(LoaderInterface $loader, $resource, array $options = array(), RequestContext $context = null, array $defaults = array())
- {
- $this->loader = $loader;
- $this->resource = $resource;
- $this->context = null === $context ? new RequestContext() : $context;
- $this->defaults = $defaults;
- $this->setOptions($options);
- }
-
- public function setOptions(array $options)
- {
- $this->options = array(
- 'cache_dir' => null,
- 'debug' => false,
- 'generator_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
- 'generator_base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
- 'generator_dumper_class' => 'Symfony\\Component\\Routing\\Generator\\Dumper\\PhpGeneratorDumper',
- 'generator_cache_class' => 'ProjectUrlGenerator',
- 'matcher_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher',
- 'matcher_base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher',
- 'matcher_dumper_class' => 'Symfony\\Component\\Routing\\Matcher\\Dumper\\PhpMatcherDumper',
- 'matcher_cache_class' => 'ProjectUrlMatcher',
- 'resource_type' => null,
- );
- $invalid = array();
- $isInvalid = false;
- foreach ($options as $key => $value) {
- if (array_key_exists($key, $this->options)) {
- $this->options[$key] = $value;
- } else {
- $isInvalid = true;
- $invalid[] = $key;
- }
- }
- if ($isInvalid) {
- throw new \InvalidArgumentException(sprintf('The Router does not support the following options: "%s".', implode('\', \'', $invalid)));
- }
- }
-
- public function setOption($key, $value)
- {
- if (!array_key_exists($key, $this->options)) {
- throw new \InvalidArgumentException(sprintf('The Router does not support the "%s" option.', $key));
- }
- $this->options[$key] = $value;
- }
-
- public function getOption($key)
- {
- if (!array_key_exists($key, $this->options)) {
- throw new \InvalidArgumentException(sprintf('The Router does not support the "%s" option.', $key));
- }
- return $this->options[$key];
- }
-
- public function getRouteCollection()
- {
- if (null === $this->collection) {
- $this->collection = $this->loader->load($this->resource, $this->options['resource_type']);
- }
- return $this->collection;
- }
-
- public function setContext(RequestContext $context)
- {
- $this->context = $context;
- $this->getMatcher()->setContext($context);
- $this->getGenerator()->setContext($context);
- }
-
- public function getContext()
- {
- return $this->context;
- }
-
- public function generate($name, $parameters = array(), $absolute = false)
- {
- return $this->getGenerator()->generate($name, $parameters, $absolute);
- }
-
- public function match($url)
- {
- return $this->getMatcher()->match($url);
- }
-
- public function getMatcher()
- {
- if (null !== $this->matcher) {
- return $this->matcher;
- }
- if (null === $this->options['cache_dir'] || null === $this->options['matcher_cache_class']) {
- return $this->matcher = new $this->options['matcher_class']($this->getRouteCollection(), $this->context, $this->defaults);
- }
- $class = $this->options['matcher_cache_class'];
- $cache = new ConfigCache($this->options['cache_dir'].'/'.$class.'.php', $this->options['debug']);
- if (!$cache->isFresh($class)) {
- $dumper = new $this->options['matcher_dumper_class']($this->getRouteCollection());
- $options = array(
- 'class' => $class,
- 'base_class' => $this->options['matcher_base_class'],
- );
- $cache->write($dumper->dump($options), $this->getRouteCollection()->getResources());
- }
- require_once $cache;
- return $this->matcher = new $class($this->context, $this->defaults);
- }
-
- public function getGenerator()
- {
- if (null !== $this->generator) {
- return $this->generator;
- }
- if (null === $this->options['cache_dir'] || null === $this->options['generator_cache_class']) {
- return $this->generator = new $this->options['generator_class']($this->getRouteCollection(), $this->context, $this->defaults);
- }
- $class = $this->options['generator_cache_class'];
- $cache = new ConfigCache($this->options['cache_dir'].'/'.$class.'.php', $this->options['debug']);
- if (!$cache->isFresh($class)) {
- $dumper = new $this->options['generator_dumper_class']($this->getRouteCollection());
- $options = array(
- 'class' => $class,
- 'base_class' => $this->options['generator_base_class'],
- );
- $cache->write($dumper->dump($options), $this->getRouteCollection()->getResources());
- }
- require_once $cache;
- return $this->generator = new $class($this->context, $this->defaults);
- }
- }
- }
-
- namespace Symfony\Bundle\FrameworkBundle\Routing
- {
- use Symfony\Component\Routing\Matcher\UrlMatcher;
- use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface;
- class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface
- {
-
- public function redirect($path, $route, $scheme = null)
- {
- return array(
- '_controller' => 'Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController::urlRedirectAction',
- 'path' => $path,
- 'permanent' => true,
- 'scheme' => $scheme,
- 'httpPort' => $this->context->getHttpPort(),
- 'httpsPort' => $this->context->getHttpsPort(),
- '_route' => $route,
- );
- }
- }
- }
-
- namespace Symfony\Bundle\FrameworkBundle\Routing
- {
- use Symfony\Component\Routing\Router as BaseRouter;
- use Symfony\Component\Routing\RequestContext;
- use Symfony\Component\DependencyInjection\ContainerInterface;
- class Router extends BaseRouter
- {
- private $container;
-
- public function __construct(ContainerInterface $container, $resource, array $options = array(), RequestContext $context = null, array $defaults = array())
- {
- $this->container = $container;
- $this->resource = $resource;
- $this->context = null === $context ? new RequestContext() : $context;
- $this->defaults = $defaults;
- $this->setOptions($options);
- }
-
- public function getRouteCollection()
- {
- if (null === $this->collection) {
- $this->collection = $this->container->get('routing.loader')->load($this->resource, $this->options['resource_type']);
- }
- return $this->collection;
- }
- }
- }
-
- namespace Symfony\Bundle\FrameworkBundle\Templating
- {
- use Symfony\Component\DependencyInjection\ContainerInterface;
- class GlobalVariables
- {
- protected $container;
- public function __construct(ContainerInterface $container)
- {
- $this->container = $container;
- }
-
- public function getSecurity()
- {
- if ($this->container->has('security.context')) {
- return $this->container->get('security.context');
- }
- }
-
- public function getUser()
- {
- if (!$security = $this->getSecurity()) {
- return;
- }
- if (!$token = $security->getToken()) {
- return;
- }
- $user = $token->getUser();
- if (!is_object($user)) {
- return;
- }
- return $user;
- }
-
- public function getRequest()
- {
- if ($this->container->has('request') && $request = $this->container->get('request')) {
- return $request;
- }
- }
-
- public function getSession()
- {
- if ($request = $this->getRequest()) {
- return $request->getSession();
- }
- }
-
- public function getEnvironment()
- {
- return $this->container->getParameter('kernel.environment');
- }
-
- public function getDebug()
- {
- return (Boolean) $this->container->getParameter('kernel.debug');
- }
- }
- }
-
- namespace Symfony\Bundle\FrameworkBundle\Templating
- {
- use Symfony\Component\Templating\EngineInterface as BaseEngineInterface;
- use Symfony\Component\HttpFoundation\Response;
- interface EngineInterface extends BaseEngineInterface
- {
-
- function renderResponse($view, array $parameters = array(), Response $response = null);
- }
- }
-
- namespace Symfony\Component\Templating
- {
- interface TemplateNameParserInterface
- {
-
- function parse($name);
- }
- }
-
- namespace Symfony\Component\Templating
- {
- use Symfony\Component\Templating\TemplateReferenceInterface;
- use Symfony\Component\Templating\TemplateReference;
- class TemplateNameParser implements TemplateNameParserInterface
- {
-
- public function parse($name)
- {
- if ($name instanceof TemplateReferenceInterface) {
- return $name;
- }
- $engine = null;
- if (false !== $pos = strrpos($name, '.')) {
- $engine = substr($name, $pos + 1);
- }
- return new TemplateReference($name, $engine);
- }
- }
- }
-
- namespace Symfony\Component\Templating
- {
- interface EngineInterface
- {
-
- function render($name, array $parameters = array());
-
- function exists($name);
-
- function supports($name);
- }
- }
-
- namespace Symfony\Component\Config
- {
- interface FileLocatorInterface
- {
-
- function locate($name, $currentPath = null, $first = true);
- }
- }
-
- namespace Symfony\Component\Templating
- {
- interface TemplateReferenceInterface
- {
-
- function all();
-
- function set($name, $value);
-
- function get($name);
-
- function getPath();
-
- function getLogicalName();
- }
- }
-
- namespace Symfony\Component\Templating
- {
- class TemplateReference implements TemplateReferenceInterface
- {
- protected $parameters;
- public function __construct($name = null, $engine = null)
- {
- $this->parameters = array(
- 'name' => $name,
- 'engine' => $engine,
- );
- }
- public function __toString()
- {
- return $this->getLogicalName();
- }
-
- public function set($name, $value)
- {
- if (array_key_exists($name, $this->parameters)) {
- $this->parameters[$name] = $value;
- } else {
- throw new \InvalidArgumentException(sprintf('The template does not support the "%s" parameter.', $name));
- }
- return $this;
- }
-
- public function get($name)
- {
- if (array_key_exists($name, $this->parameters)) {
- return $this->parameters[$name];
- }
- throw new \InvalidArgumentException(sprintf('The template does not support the "%s" parameter.', $name));
- }
-
- public function all()
- {
- return $this->parameters;
- }
-
- public function getPath()
- {
- return $this->parameters['name'];
- }
-
- public function getLogicalName()
- {
- return $this->parameters['name'];
- }
- }
- }
-
- namespace Symfony\Bundle\FrameworkBundle\Templating
- {
- use Symfony\Component\Templating\TemplateReference as BaseTemplateReference;
- class TemplateReference extends BaseTemplateReference
- {
- public function __construct($bundle = null, $controller = null, $name = null, $format = null, $engine = null)
- {
- $this->parameters = array(
- 'bundle' => $bundle,
- 'controller' => $controller,
- 'name' => $name,
- 'format' => $format,
- 'engine' => $engine,
- );
- }
-
- public function getPath()
- {
- $controller = str_replace('\\', '/', $this->get('controller'));
- $path = (empty($controller) ? '' : $controller.'/').$this->get('name').'.'.$this->get('format').'.'.$this->get('engine');
- return empty($this->parameters['bundle']) ? 'views/'.$path : '@'.$this->get('bundle').'/Resources/views/'.$path;
- }
-
- public function getLogicalName()
- {
- return sprintf('%s:%s:%s.%s.%s', $this->parameters['bundle'], $this->parameters['controller'], $this->parameters['name'], $this->parameters['format'], $this->parameters['engine']);
- }
- }
- }
-
- namespace Symfony\Bundle\FrameworkBundle\Templating
- {
- use Symfony\Component\Templating\TemplateNameParser as BaseTemplateNameParser;
- use Symfony\Component\Templating\TemplateReferenceInterface;
- use Symfony\Component\HttpKernel\KernelInterface;
- class TemplateNameParser extends BaseTemplateNameParser
- {
- protected $kernel;
- protected $cache;
-
- public function __construct(KernelInterface $kernel)
- {
- $this->kernel = $kernel;
- $this->cache = array();
- }
-
- public function parse($name)
- {
- if ($name instanceof TemplateReferenceInterface) {
- return $name;
- } else if (isset($this->cache[$name])) {
- return $this->cache[$name];
- }
- $name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')));
- if (false !== strpos($name, '..')) {
- throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name));
- }
- $parts = explode(':', $name);
- if (3 !== count($parts)) {
- throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid (format is "bundle:section:template.format.engine").', $name));
- }
- $elements = explode('.', $parts[2]);
- if (3 > count($elements)) {
- throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid (format is "bundle:section:template.format.engine").', $name));
- }
- $engine = array_pop($elements);
- $format = array_pop($elements);
- $template = new TemplateReference($parts[0], $parts[1], implode('.', $elements), $format, $engine);
- if ($template->get('bundle')) {
- try {
- $this->kernel->getBundle($template->get('bundle'));
- } catch (\Exception $e) {
- throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid.', $name), 0, $e);
- }
- }
- return $this->cache[$name] = $template;
- }
-
- public function parseFromFilename($file)
- {
- $parts = explode('/', strtr($file, '\\', '/'));
- $elements = explode('.', array_pop($parts));
- if (3 > count($elements)) {
- return false;
- }
- $engine = array_pop($elements);
- $format = array_pop($elements);
- return new TemplateReference('', implode('/', $parts), implode('.', $elements), $format, $engine);
- }
- }
- }
-
- namespace Symfony\Bundle\FrameworkBundle\Templating\Loader
- {
- use Symfony\Component\Config\FileLocatorInterface;
- use Symfony\Component\Templating\TemplateReferenceInterface;
- class TemplateLocator implements FileLocatorInterface
- {
- protected $locator;
- protected $path;
- protected $cache;
-
- public function __construct(FileLocatorInterface $locator, $cacheDir = null)
- {
- if (null !== $cacheDir && file_exists($cache = $cacheDir.'/templates.php')) {
- $this->cache = require $cache;
- }
- $this->locator = $locator;
- }
-
- public function locate($template, $currentPath = null, $first = true)
- {
- if (!$template instanceof TemplateReferenceInterface) {
- throw new \InvalidArgumentException("The template must be an instance of TemplateReferenceInterface.");
- }
- $key = $template->getLogicalName();
- if (isset($this->cache[$key])) {
- return $this->cache[$key];
- }
- try {
- return $this->cache[$key] = $this->locator->locate($template->getPath(), $currentPath);
- } catch (\InvalidArgumentException $e) {
- throw new \InvalidArgumentException(sprintf('Unable to find template "%s" in "%s".', $template, $this->path), 0, $e);
- }
- }
- }
- }
-
- namespace Symfony\Component\HttpFoundation
- {
- class ParameterBag
- {
- protected $parameters;
-
- public function __construct(array $parameters = array())
- {
- $this->parameters = $parameters;
- }
-
- public function all()
- {
- return $this->parameters;
- }
-
- public function keys()
- {
- return array_keys($this->parameters);
- }
-
- public function replace(array $parameters = array())
- {
- $this->parameters = $parameters;
- }
-
- public function add(array $parameters = array())
- {
- $this->parameters = array_replace($this->parameters, $parameters);
- }
-
- public function get($path, $default = null, $deep = false)
- {
- if (!$deep || false === $pos = strpos($path, '[')) {
- return array_key_exists($path, $this->parameters) ? $this->parameters[$path] : $default;
- }
- $root = substr($path, 0, $pos);
- if (!array_key_exists($root, $this->parameters)) {
- return $default;
- }
- $value = $this->parameters[$root];
- $currentKey = null;
- for ($i=$pos,$c=strlen($path); $i<$c; $i++) {
- $char = $path[$i];
- if ('[' === $char) {
- if (null !== $currentKey) {
- throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "[" at position %d.', $i));
- }
- $currentKey = '';
- } else if (']' === $char) {
- if (null === $currentKey) {
- throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "]" at position %d.', $i));
- }
- if (!is_array($value) || !array_key_exists($currentKey, $value)) {
- return $default;
- }
- $value = $value[$currentKey];
- $currentKey = null;
- } else {
- if (null === $currentKey) {
- throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "%s" at position %d.', $char, $i));
- }
- $currentKey .= $char;
- }
- }
- if (null !== $currentKey) {
- throw new \InvalidArgumentException(sprintf('Malformed path. Path must end with "]".'));
- }
- return $value;
- }
-
- public function set($key, $value)
- {
- $this->parameters[$key] = $value;
- }
-
- public function has($key)
- {
- return array_key_exists($key, $this->parameters);
- }
-
- public function remove($key)
- {
- unset($this->parameters[$key]);
- }
-
- public function getAlpha($key, $default = '', $deep = false)
- {
- return preg_replace('/[^[:alpha:]]/', '', $this->get($key, $default, $deep));
- }
-
- public function getAlnum($key, $default = '', $deep = false)
- {
- return preg_replace('/[^[:alnum:]]/', '', $this->get($key, $default, $deep));
- }
-
- public function getDigits($key, $default = '', $deep = false)
- {
- return preg_replace('/[^[:digit:]]/', '', $this->get($key, $default, $deep));
- }
-
- public function getInt($key, $default = 0, $deep = false)
- {
- return (int) $this->get($key, $default, $deep);
- }
- }
- }
-
- namespace Symfony\Component\HttpFoundation
- {
- class HeaderBag
- {
- protected $headers;
- protected $cacheControl;
-
- public function __construct(array $headers = array())
- {
- $this->cacheControl = array();
- $this->headers = array();
- foreach ($headers as $key => $values) {
- $this->set($key, $values);
- }
- }
-
- public function __toString()
- {
- if (!$this->headers) {
- return '';
- }
- $beautifier = function ($name) {
- return preg_replace_callback('/\-(.)/', function ($match) { return '-'.strtoupper($match[1]); }, ucfirst($name));
- };
- $max = max(array_map('strlen', array_keys($this->headers))) + 1;
- $content = '';
- ksort($this->headers);
- foreach ($this->headers as $name => $values) {
- foreach ($values as $value) {
- $content .= sprintf("%-{$max}s %s\r\n", $beautifier($name).':', $value);
- }
- }
- return $content;
- }
-
- public function all()
- {
- return $this->headers;
- }
-
- public function keys()
- {
- return array_keys($this->headers);
- }
-
- public function replace(array $headers = array())
- {
- $this->headers = array();
- $this->add($headers);
- }
-
- public function add(array $headers)
- {
- foreach ($headers as $key => $values) {
- $this->set($key, $values);
- }
- }
-
- public function get($key, $default = null, $first = true)
- {
- $key = strtr(strtolower($key), '_', '-');
- if (!array_key_exists($key, $this->headers)) {
- if (null === $default) {
- return $first ? null : array();
- }
- return $first ? $default : array($default);
- }
- if ($first) {
- return count($this->headers[$key]) ? $this->headers[$key][0] : $default;
- }
- return $this->headers[$key];
- }
-
- public function set($key, $values, $replace = true)
- {
- $key = strtr(strtolower($key), '_', '-');
- $values = (array) $values;
- if (true === $replace || !isset($this->headers[$key])) {
- $this->headers[$key] = $values;
- } else {
- $this->headers[$key] = array_merge($this->headers[$key], $values);
- }
- if ('cache-control' === $key) {
- $this->cacheControl = $this->parseCacheControl($values[0]);
- }
- }
-
- public function has($key)
- {
- return array_key_exists(strtr(strtolower($key), '_', '-'), $this->headers);
- }
-
- public function contains($key, $value)
- {
- return in_array($value, $this->get($key, null, false));
- }
-
- public function remove($key)
- {
- $key = strtr(strtolower($key), '_', '-');
- unset($this->headers[$key]);
- if ('cache-control' === $key) {
- $this->cacheControl = array();
- }
- }
-
- public function getDate($key, \DateTime $default = null)
- {
- if (null === $value = $this->get($key)) {
- return $default;
- }
- if (false === $date = \DateTime::createFromFormat(DATE_RFC2822, $value)) {
- throw new \RuntimeException(sprintf('The %s HTTP header is not parseable (%s).', $key, $value));
- }
- return $date;
- }
- public function addCacheControlDirective($key, $value = true)
- {
- $this->cacheControl[$key] = $value;
- $this->set('Cache-Control', $this->getCacheControlHeader());
- }
- public function hasCacheControlDirective($key)
- {
- return array_key_exists($key, $this->cacheControl);
- }
- public function getCacheControlDirective($key)
- {
- return array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null;
- }
- public function removeCacheControlDirective($key)
- {
- unset($this->cacheControl[$key]);
- $this->set('Cache-Control', $this->getCacheControlHeader());
- }
- protected function getCacheControlHeader()
- {
- $parts = array();
- ksort($this->cacheControl);
- foreach ($this->cacheControl as $key => $value) {
- if (true === $value) {
- $parts[] = $key;
- } else {
- if (preg_match('#[^a-zA-Z0-9._-]#', $value)) {
- $value = '"'.$value.'"';
- }
- $parts[] = "$key=$value";
- }
- }
- return implode(', ', $parts);
- }
-
- protected function parseCacheControl($header)
- {
- $cacheControl = array();
- preg_match_all('#([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?#', $header, $matches, PREG_SET_ORDER);
- foreach ($matches as $match) {
- $cacheControl[strtolower($match[1])] = isset($match[2]) && $match[2] ? $match[2] : (isset($match[3]) ? $match[3] : true);
- }
- return $cacheControl;
- }
- }
- }
-
- namespace Symfony\Component\HttpFoundation
- {
- use Symfony\Component\HttpFoundation\File\UploadedFile;
- class FileBag extends ParameterBag
- {
- static private $fileKeys = array('error', 'name', 'size', 'tmp_name', 'type');
-
- public function __construct(array $parameters = array())
- {
- $this->replace($parameters);
- }
-
- public function replace(array $files = array())
- {
- $this->parameters = array();
- $this->add($files);
- }
-
- public function set($key, $value)
- {
- if (is_array($value) || $value instanceof UploadedFile) {
- parent::set($key, $this->convertFileInformation($value));
- } else {
- throw new \InvalidArgumentException('An uploaded file must be an array or an instance of UploadedFile.');
- }
- }
-
- public function add(array $files = array())
- {
- foreach ($files as $key => $file) {
- $this->set($key, $file);
- }
- }
-
- protected function convertFileInformation($file)
- {
- if ($file instanceof UploadedFile) {
- return $file;
- }
- $file = $this->fixPhpFilesArray($file);
- if (is_array($file)) {
- $keys = array_keys($file);
- sort($keys);
- if ($keys == self::$fileKeys) {
- if (UPLOAD_ERR_NO_FILE == $file['error']) {
- $file = null;
- } else {
- $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error']);
- }
- } else {
- $file = array_map(array($this, 'convertFileInformation'), $file);
- }
- }
- return $file;
- }
-
- protected function fixPhpFilesArray($data)
- {
- if (!is_array($data)) {
- return $data;
- }
- $keys = array_keys($data);
- sort($keys);
- if (self::$fileKeys != $keys || !isset($data['name']) || !is_array($data['name'])) {
- return $data;
- }
- $files = $data;
- foreach (self::$fileKeys as $k) {
- unset($files[$k]);
- }
- foreach (array_keys($data['name']) as $key) {
- $files[$key] = $this->fixPhpFilesArray(array(
- 'error' => $data['error'][$key],
- 'name' => $data['name'][$key],
- 'type' => $data['type'][$key],
- 'tmp_name' => $data['tmp_name'][$key],
- 'size' => $data['size'][$key]
- ));
- }
- return $files;
- }
- }
- }
-
- namespace Symfony\Component\HttpFoundation
- {
- class ServerBag extends ParameterBag
- {
- public function getHeaders()
- {
- $headers = array();
- foreach ($this->parameters as $key => $value) {
- if ('HTTP_' === substr($key, 0, 5)) {
- $headers[substr($key, 5)] = $value;
- }
- elseif (in_array($key, array('CONTENT_LENGTH', 'CONTENT_MD5', 'CONTENT_TYPE'))) {
- $headers[$key] = $this->parameters[$key];
- }
- }
- if (isset($this->parameters['PHP_AUTH_USER'])) {
- $pass = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] : '';
- $headers['AUTHORIZATION'] = 'Basic '.base64_encode($this->parameters['PHP_AUTH_USER'].':'.$pass);
- }
- return $headers;
- }
- }
- }
-
- namespace Symfony\Component\HttpFoundation
- {
- class Request
- {
- static protected $trustProxy = false;
-
- public $attributes;
-
- public $request;
-
- public $query;
-
- public $server;
-
- public $files;
-
- public $cookies;
-
- public $headers;
- protected $content;
- protected $languages;
- protected $charsets;
- protected $acceptableContentTypes;
- protected $pathInfo;
- protected $requestUri;
- protected $baseUrl;
- protected $basePath;
- protected $method;
- protected $format;
- protected $session;
- static protected $formats;
-
- public function __construct(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
- {
- $this->initialize($query, $request, $attributes, $cookies, $files, $server, $content);
- }
-
- public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
- {
- $this->request = new ParameterBag($request);
- $this->query = new ParameterBag($query);
- $this->attributes = new ParameterBag($attributes);
- $this->cookies = new ParameterBag($cookies);
- $this->…
Large files files are truncated, but you can click here to view the full file