aboutsummaryrefslogtreecommitdiffhomepage
path: root/assets/php/vendor/symfony/routing/Loader/Configurator
diff options
context:
space:
mode:
authormarvin-borner@live.com2018-04-10 21:50:16 +0200
committermarvin-borner@live.com2018-04-10 21:54:48 +0200
commitfc9401f04a3aca5abb22f87ebc210de8afe11d32 (patch)
treeb0b310f3581764ec3955f4e496a05137a32951c3 /assets/php/vendor/symfony/routing/Loader/Configurator
parent286d643180672f20526f3dc3bd19d7b751e2fa97 (diff)
Initial Commit
Diffstat (limited to 'assets/php/vendor/symfony/routing/Loader/Configurator')
-rw-r--r--assets/php/vendor/symfony/routing/Loader/Configurator/CollectionConfigurator.php81
-rw-r--r--assets/php/vendor/symfony/routing/Loader/Configurator/ImportConfigurator.php49
-rw-r--r--assets/php/vendor/symfony/routing/Loader/Configurator/RouteConfigurator.php34
-rw-r--r--assets/php/vendor/symfony/routing/Loader/Configurator/RoutingConfigurator.php62
-rw-r--r--assets/php/vendor/symfony/routing/Loader/Configurator/Traits/AddTrait.php55
-rw-r--r--assets/php/vendor/symfony/routing/Loader/Configurator/Traits/RouteTrait.php131
6 files changed, 412 insertions, 0 deletions
diff --git a/assets/php/vendor/symfony/routing/Loader/Configurator/CollectionConfigurator.php b/assets/php/vendor/symfony/routing/Loader/Configurator/CollectionConfigurator.php
new file mode 100644
index 0000000..8baefdd
--- /dev/null
+++ b/assets/php/vendor/symfony/routing/Loader/Configurator/CollectionConfigurator.php
@@ -0,0 +1,81 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Routing\Loader\Configurator;
+
+use Symfony\Component\Routing\Route;
+use Symfony\Component\Routing\RouteCollection;
+
+/**
+ * @author Nicolas Grekas <p@tchwork.com>
+ */
+class CollectionConfigurator
+{
+ use Traits\AddTrait;
+ use Traits\RouteTrait;
+
+ private $parent;
+ private $parentConfigurator;
+
+ public function __construct(RouteCollection $parent, $name, self $parentConfigurator = null)
+ {
+ $this->parent = $parent;
+ $this->name = $name;
+ $this->collection = new RouteCollection();
+ $this->route = new Route('');
+ $this->parentConfigurator = $parentConfigurator; // for GC control
+ }
+
+ public function __destruct()
+ {
+ $this->collection->addPrefix(rtrim($this->route->getPath(), '/'));
+ $this->parent->addCollection($this->collection);
+ }
+
+ /**
+ * Adds a route.
+ *
+ * @param string $name
+ * @param string $path
+ *
+ * @return RouteConfigurator
+ */
+ final public function add($name, $path)
+ {
+ $this->collection->add($this->name.$name, $route = clone $this->route);
+
+ return new RouteConfigurator($this->collection, $route->setPath($path), $this->name, $this);
+ }
+
+ /**
+ * Creates a sub-collection.
+ *
+ * @return self
+ */
+ final public function collection($name = '')
+ {
+ return new self($this->collection, $this->name.$name, $this);
+ }
+
+ /**
+ * Sets the prefix to add to the path of all child routes.
+ *
+ * @param string $prefix
+ *
+ * @return $this
+ */
+ final public function prefix($prefix)
+ {
+ $this->route->setPath($prefix);
+
+ return $this;
+ }
+}
diff --git a/assets/php/vendor/symfony/routing/Loader/Configurator/ImportConfigurator.php b/assets/php/vendor/symfony/routing/Loader/Configurator/ImportConfigurator.php
new file mode 100644
index 0000000..d0a3c37
--- /dev/null
+++ b/assets/php/vendor/symfony/routing/Loader/Configurator/ImportConfigurator.php
@@ -0,0 +1,49 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Routing\Loader\Configurator;
+
+use Symfony\Component\Routing\RouteCollection;
+
+/**
+ * @author Nicolas Grekas <p@tchwork.com>
+ */
+class ImportConfigurator
+{
+ use Traits\RouteTrait;
+
+ private $parent;
+
+ public function __construct(RouteCollection $parent, RouteCollection $route)
+ {
+ $this->parent = $parent;
+ $this->route = $route;
+ }
+
+ public function __destruct()
+ {
+ $this->parent->addCollection($this->route);
+ }
+
+ /**
+ * Sets the prefix to add to the path of all child routes.
+ *
+ * @param string $prefix
+ *
+ * @return $this
+ */
+ final public function prefix($prefix)
+ {
+ $this->route->addPrefix($prefix);
+
+ return $this;
+ }
+}
diff --git a/assets/php/vendor/symfony/routing/Loader/Configurator/RouteConfigurator.php b/assets/php/vendor/symfony/routing/Loader/Configurator/RouteConfigurator.php
new file mode 100644
index 0000000..6422bbf
--- /dev/null
+++ b/assets/php/vendor/symfony/routing/Loader/Configurator/RouteConfigurator.php
@@ -0,0 +1,34 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Routing\Loader\Configurator;
+
+use Symfony\Component\Routing\Route;
+use Symfony\Component\Routing\RouteCollection;
+
+/**
+ * @author Nicolas Grekas <p@tchwork.com>
+ */
+class RouteConfigurator
+{
+ use Traits\AddTrait;
+ use Traits\RouteTrait;
+
+ private $parentConfigurator;
+
+ public function __construct(RouteCollection $collection, Route $route, $name = '', CollectionConfigurator $parentConfigurator = null)
+ {
+ $this->collection = $collection;
+ $this->route = $route;
+ $this->name = $name;
+ $this->parentConfigurator = $parentConfigurator; // for GC control
+ }
+}
diff --git a/assets/php/vendor/symfony/routing/Loader/Configurator/RoutingConfigurator.php b/assets/php/vendor/symfony/routing/Loader/Configurator/RoutingConfigurator.php
new file mode 100644
index 0000000..d992cef
--- /dev/null
+++ b/assets/php/vendor/symfony/routing/Loader/Configurator/RoutingConfigurator.php
@@ -0,0 +1,62 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Routing\Loader\Configurator;
+
+use Symfony\Component\Routing\Loader\PhpFileLoader;
+use Symfony\Component\Routing\RouteCollection;
+
+/**
+ * @author Nicolas Grekas <p@tchwork.com>
+ */
+class RoutingConfigurator
+{
+ use Traits\AddTrait;
+
+ private $loader;
+ private $path;
+ private $file;
+
+ public function __construct(RouteCollection $collection, PhpFileLoader $loader, $path, $file)
+ {
+ $this->collection = $collection;
+ $this->loader = $loader;
+ $this->path = $path;
+ $this->file = $file;
+ }
+
+ /**
+ * @return ImportConfigurator
+ */
+ final public function import($resource, $type = null, $ignoreErrors = false)
+ {
+ $this->loader->setCurrentDir(dirname($this->path));
+ $imported = $this->loader->import($resource, $type, $ignoreErrors, $this->file);
+ if (!is_array($imported)) {
+ return new ImportConfigurator($this->collection, $imported);
+ }
+
+ $mergedCollection = new RouteCollection();
+ foreach ($imported as $subCollection) {
+ $mergedCollection->addCollection($subCollection);
+ }
+
+ return new ImportConfigurator($this->collection, $mergedCollection);
+ }
+
+ /**
+ * @return CollectionConfigurator
+ */
+ final public function collection($name = '')
+ {
+ return new CollectionConfigurator($this->collection, $name);
+ }
+}
diff --git a/assets/php/vendor/symfony/routing/Loader/Configurator/Traits/AddTrait.php b/assets/php/vendor/symfony/routing/Loader/Configurator/Traits/AddTrait.php
new file mode 100644
index 0000000..e8b8fa2
--- /dev/null
+++ b/assets/php/vendor/symfony/routing/Loader/Configurator/Traits/AddTrait.php
@@ -0,0 +1,55 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Routing\Loader\Configurator\Traits;
+
+use Symfony\Component\Routing\Loader\Configurator\RouteConfigurator;
+use Symfony\Component\Routing\Route;
+use Symfony\Component\Routing\RouteCollection;
+
+trait AddTrait
+{
+ /**
+ * @var RouteCollection
+ */
+ private $collection;
+
+ private $name = '';
+
+ /**
+ * Adds a route.
+ *
+ * @param string $name
+ * @param string $path
+ *
+ * @return RouteConfigurator
+ */
+ final public function add($name, $path)
+ {
+ $parentConfigurator = $this instanceof RouteConfigurator ? $this->parentConfigurator : null;
+ $this->collection->add($this->name.$name, $route = new Route($path));
+
+ return new RouteConfigurator($this->collection, $route, '', $parentConfigurator);
+ }
+
+ /**
+ * Adds a route.
+ *
+ * @param string $name
+ * @param string $path
+ *
+ * @return RouteConfigurator
+ */
+ final public function __invoke($name, $path)
+ {
+ return $this->add($name, $path);
+ }
+}
diff --git a/assets/php/vendor/symfony/routing/Loader/Configurator/Traits/RouteTrait.php b/assets/php/vendor/symfony/routing/Loader/Configurator/Traits/RouteTrait.php
new file mode 100644
index 0000000..4d2e255
--- /dev/null
+++ b/assets/php/vendor/symfony/routing/Loader/Configurator/Traits/RouteTrait.php
@@ -0,0 +1,131 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Routing\Loader\Configurator\Traits;
+
+use Symfony\Component\Routing\Route;
+use Symfony\Component\Routing\RouteCollection;
+
+trait RouteTrait
+{
+ /**
+ * @var RouteCollection|Route
+ */
+ private $route;
+
+ /**
+ * Adds defaults.
+ *
+ * @return $this
+ */
+ final public function defaults(array $defaults)
+ {
+ $this->route->addDefaults($defaults);
+
+ return $this;
+ }
+
+ /**
+ * Adds requirements.
+ *
+ * @return $this
+ */
+ final public function requirements(array $requirements)
+ {
+ $this->route->addRequirements($requirements);
+
+ return $this;
+ }
+
+ /**
+ * Adds options.
+ *
+ * @return $this
+ */
+ final public function options(array $options)
+ {
+ $this->route->addOptions($options);
+
+ return $this;
+ }
+
+ /**
+ * Sets the condition.
+ *
+ * @param string $condition
+ *
+ * @return $this
+ */
+ final public function condition($condition)
+ {
+ $this->route->setCondition($condition);
+
+ return $this;
+ }
+
+ /**
+ * Sets the pattern for the host.
+ *
+ * @param string $pattern
+ *
+ * @return $this
+ */
+ final public function host($pattern)
+ {
+ $this->route->setHost($pattern);
+
+ return $this;
+ }
+
+ /**
+ * Sets the schemes (e.g. 'https') this route is restricted to.
+ * So an empty array means that any scheme is allowed.
+ *
+ * @param string[] $schemes
+ *
+ * @return $this
+ */
+ final public function schemes(array $schemes)
+ {
+ $this->route->setSchemes($schemes);
+
+ return $this;
+ }
+
+ /**
+ * Sets the HTTP methods (e.g. 'POST') this route is restricted to.
+ * So an empty array means that any method is allowed.
+ *
+ * @param string[] $methods
+ *
+ * @return $this
+ */
+ final public function methods(array $methods)
+ {
+ $this->route->setMethods($methods);
+
+ return $this;
+ }
+
+ /**
+ * Adds the "_controller" entry to defaults.
+ *
+ * @param callable|string $controller a callable or parseable pseudo-callable
+ *
+ * @return $this
+ */
+ final public function controller($controller)
+ {
+ $this->route->addDefaults(array('_controller' => $controller));
+
+ return $this;
+ }
+}