mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
allow server:run with built-in server and create route loader
This commit is contained in:
parent
27378f34ca
commit
11a71d99ec
1
.gitignore
vendored
1
.gitignore
vendored
@ -23,3 +23,4 @@ app/config/parameters.yml
|
||||
bin/*
|
||||
/tmp/*
|
||||
src/Chill/CustomFieldsBundle/vendor/*
|
||||
bootstrap.php.cache
|
||||
|
@ -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:
|
||||
|
53
Routing/RoutesLoader.php
Normal file
53
Routing/RoutesLoader.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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é <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@ class AppKernel extends Kernel
|
||||
*/
|
||||
public function getLogDir()
|
||||
{
|
||||
return sys_get_temp_dir().'/CustomFieldsBundle/logs';
|
||||
return $this->getRootDir().'/../logs';
|
||||
}
|
||||
}
|
||||
|
||||
|
13
Tests/Fixtures/App/app/Resources/views/base.html.twig
Normal file
13
Tests/Fixtures/App/app/Resources/views/base.html.twig
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>{% block title %}Welcome!{% endblock %}</title>
|
||||
{% block stylesheets %}{% endblock %}
|
||||
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
|
||||
</head>
|
||||
<body>
|
||||
{% block body %}{% endblock %}
|
||||
{% block javascripts %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
13
Tests/Fixtures/App/app/autoload.php
Normal file
13
Tests/Fixtures/App/app/autoload.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||
use Composer\Autoload\ClassLoader;
|
||||
|
||||
/**
|
||||
* @var ClassLoader $loader
|
||||
*/
|
||||
$loader = require __DIR__.'/../../../../vendor/autoload.php';
|
||||
|
||||
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
|
||||
|
||||
return $loader;
|
6
Tests/Fixtures/App/app/config/parameters__.yml
Normal file
6
Tests/Fixtures/App/app/config/parameters__.yml
Normal file
@ -0,0 +1,6 @@
|
||||
parameters:
|
||||
database_host: 127.0.0.1
|
||||
database_port: 5434
|
||||
database_name: test0
|
||||
database_user: symfony
|
||||
database_password: symfony
|
@ -1,4 +1,4 @@
|
||||
cl_custom_fields:
|
||||
resource: "@ChillCustomFieldsBundle/Resources/config/routing.yml"
|
||||
prefix: /
|
||||
resource: .
|
||||
type: chill_routes
|
||||
|
||||
|
0
Tests/Fixtures/App/logs/empty
Normal file
0
Tests/Fixtures/App/logs/empty
Normal file
45
Tests/Routing/RoutingLoaderTest.php
Normal file
45
Tests/Routing/RoutingLoaderTest.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Chill\CustomFieldsBundle\Tests;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Test that routes are correctly loaded
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class RoutingLoaderTest extends WebTestCase
|
||||
{
|
||||
public function testRoutesAreLoaded()
|
||||
{
|
||||
$client = static::createClient();
|
||||
|
||||
$client->request('GET','/customfield/');
|
||||
|
||||
$this->assertEquals(
|
||||
Response::HTTP_OK,
|
||||
$client->getResponse()->getStatusCode()
|
||||
);
|
||||
|
||||
}
|
||||
}
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user