diff --git a/.gitignore b/.gitignore
index d91d2cef2..83f2334e7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,3 +23,4 @@ app/config/parameters.yml
bin/*
/tmp/*
src/Chill/CustomFieldsBundle/vendor/*
+bootstrap.php.cache
diff --git a/Resources/config/services.yml b/Resources/config/services.yml
index 78ecea642..14bdc0f96 100644
--- a/Resources/config/services.yml
+++ b/Resources/config/services.yml
@@ -2,6 +2,11 @@ parameters:
# cl_custom_fields.example.class: Chill\CustomFieldsBundle\Example
services:
+ chill.custom_fields.routing_loader:
+ class: Chill\CustomFieldsBundle\Routing\RoutesLoader
+ tags:
+ - { name: routing.loader }
+
chill.custom_field_compiler:
class: Chill\CustomFieldsBundle\Service\CustomFieldProvider
call:
diff --git a/Routing/RoutesLoader.php b/Routing/RoutesLoader.php
new file mode 100644
index 000000000..d9a8ab035
--- /dev/null
+++ b/Routing/RoutesLoader.php
@@ -0,0 +1,53 @@
+
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+namespace Chill\CustomFieldsBundle\Routing;
+
+use Symfony\Component\Config\Loader\LoaderInterface;
+use Symfony\Component\Config\Loader\LoaderResolverInterface;
+use Symfony\Component\Config\Loader\Loader;
+use Symfony\Component\Routing\RouteCollection;
+
+/**
+ * Load routes automatically
+ *
+ * @author Julien Fastré
+ */
+class RoutesLoader extends Loader
+{
+ public function load($resource, $type = null)
+ {
+ $collection = new RouteCollection();
+
+ $resource = '@ChillCustomFieldsBundle/Resources/config/routing.yml';
+ $type = 'yaml';
+
+ $importedRoutes = $this->import($resource, $type);
+
+ $collection->addCollection($importedRoutes);
+
+ return $collection;
+ }
+
+ public function supports($resource, $type = null)
+ {
+ return 'chill_routes' === $type;
+ }
+}
diff --git a/Tests/Fixtures/App/app/AppKernel.php b/Tests/Fixtures/App/app/AppKernel.php
index 194a82a11..b45dc09aa 100644
--- a/Tests/Fixtures/App/app/AppKernel.php
+++ b/Tests/Fixtures/App/app/AppKernel.php
@@ -36,7 +36,7 @@ class AppKernel extends Kernel
*/
public function getLogDir()
{
- return sys_get_temp_dir().'/CustomFieldsBundle/logs';
+ return $this->getRootDir().'/../logs';
}
}
diff --git a/Tests/Fixtures/App/app/Resources/views/base.html.twig b/Tests/Fixtures/App/app/Resources/views/base.html.twig
new file mode 100644
index 000000000..bafd28d3b
--- /dev/null
+++ b/Tests/Fixtures/App/app/Resources/views/base.html.twig
@@ -0,0 +1,13 @@
+
+
+
+
+ {% block title %}Welcome!{% endblock %}
+ {% block stylesheets %}{% endblock %}
+
+
+
+ {% block body %}{% endblock %}
+ {% block javascripts %}{% endblock %}
+
+
diff --git a/Tests/Fixtures/App/app/autoload.php b/Tests/Fixtures/App/app/autoload.php
new file mode 100644
index 000000000..57a507088
--- /dev/null
+++ b/Tests/Fixtures/App/app/autoload.php
@@ -0,0 +1,13 @@
+
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+namespace Chill\CustomFieldsBundle\Tests;
+
+use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
+use Symfony\Component\HttpFoundation\Response;
+
+/**
+ * Test that routes are correctly loaded
+ *
+ * @author Julien Fastré
+ */
+class RoutingLoaderTest extends WebTestCase
+{
+ public function testRoutesAreLoaded()
+ {
+ $client = static::createClient();
+
+ $client->request('GET','/customfield/');
+
+ $this->assertEquals(
+ Response::HTTP_OK,
+ $client->getResponse()->getStatusCode()
+ );
+
+ }
+}
diff --git a/composer.json b/composer.json
index ab82fba00..132fc4e7e 100644
--- a/composer.json
+++ b/composer.json
@@ -27,5 +27,16 @@
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0",
"sensio/framework-extra-bundle": "~3.0"
+ },
+ "scripts": {
+ "post-install-cmd": [
+ "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap"
+ ],
+ "post-update-cmd": [
+ "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap"
+ ]
+ },
+ "extra": {
+ "symfony-app-dir": "Tests/Fixtures/App/app"
}
}