Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 3f9d7a2

Browse files
committed
Merge pull request #53 from symfony-cmf/bundle_standards
Updated to bundle stadnards
2 parents 0211982 + 454064f commit 3f9d7a2

File tree

12 files changed

+77
-70
lines changed

12 files changed

+77
-70
lines changed

AutoRoute/AutoRouteStack.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace Symfony\Cmf\Bundle\RoutingAutoBundle\AutoRoute;
1414

15-
use Symfony\Cmf\Bundle\RoutingAutoBundle\Document\AutoRoute;
15+
use Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute;
1616

1717
/**
1818
* Special sub class for AutoRoutes.

AutoRoute/RouteMaker/AutoRouteMaker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use Doctrine\ODM\PHPCR\DocumentManager;
1616
use Symfony\Cmf\Bundle\RoutingAutoBundle\AutoRoute\RouteMakerInterface;
17-
use Symfony\Cmf\Bundle\RoutingAutoBundle\Document\AutoRoute;
17+
use Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute;
1818
use Symfony\Cmf\Bundle\RoutingAutoBundle\AutoRoute\RouteStack;
1919

2020
/**

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Changelog
22
=========
33

4+
* **2013-01-25**: Upgraded to the CMF bundle standards.
5+
- Changed namespace of AutoRoute document
6+
- Changed namespace of AutoRouteListener
7+
48
* **2013-12-08**: Major configuration format changes.
59
See the documentation: http://symfony.com/doc/current/cmf/bundles/routing_auto.html
610

CmfRoutingAutoBundle.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,39 @@
1515
use Symfony\Component\HttpKernel\Bundle\Bundle;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Cmf\Bundle\RoutingAutoBundle\DependencyInjection\Compiler\AutoRoutePass;
18+
use Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass;
1819

1920
class CmfRoutingAutoBundle extends Bundle
2021
{
2122
public function build(ContainerBuilder $container)
2223
{
2324
parent::build($container);
2425
$container->addCompilerPass(new AutoRoutePass());
26+
$this->buildPhpcrCompilerPass($container);
2527
}
28+
29+
/**
30+
* Creates and registers compiler passes for PHPCR-ODM mapping if both the
31+
* phpcr-odm and the phpcr-bundle are present.
32+
*
33+
* @param ContainerBuilder $container
34+
*/
35+
private function buildPhpcrCompilerPass(ContainerBuilder $container)
36+
{
37+
if (!class_exists('Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass')
38+
|| !class_exists('Doctrine\ODM\PHPCR\Version')
39+
) {
40+
return;
41+
}
42+
43+
$container->addCompilerPass(
44+
DoctrinePhpcrMappingsPass::createXmlMappingDriver(
45+
array(
46+
realpath(__DIR__.'/Resources/config/doctrine-model') => 'Symfony\Cmf\Bundle\RoutingAutoBundle\Model',
47+
),
48+
array('cmf_routing_auto.persistence.phpcr.manager_name')
49+
)
50+
);
51+
}
52+
2653
}

EventListener/AutoRouteListener.php renamed to Doctrine/Phpcr/AutoRouteListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
*/
1111

1212

13-
namespace Symfony\Cmf\Bundle\RoutingAutoBundle\EventListener;
13+
namespace Symfony\Cmf\Bundle\RoutingAutoBundle\Doctrine\Phpcr;
1414

1515
use Doctrine\Common\Persistence\Event\ManagerEventArgs;
1616
use Doctrine\ODM\PHPCR\DocumentManager;
1717
use Symfony\Component\DependencyInjection\ContainerInterface;
18-
use Symfony\Cmf\Bundle\RoutingAutoBundle\Document\AutoRoute;
18+
use Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute;
1919

2020
/**
2121
* Doctrine PHPCR ODM listener for maintaining automatic routes.

Document/AutoRoute.php renamed to Model/AutoRoute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111

1212

13-
namespace Symfony\Cmf\Bundle\RoutingAutoBundle\Document;
13+
namespace Symfony\Cmf\Bundle\RoutingAutoBundle\Model;
1414

1515
use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route;
1616

README.md

Lines changed: 27 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,43 @@
1-
# [WIP] Symfony CMF Routing Auto Route Bundle [![Build Status](https://secure.travis-ci.org/symfony-cmf/RoutingAutoBundle.png)](http://travis-ci.org/symfony-cmf/RoutingAutoBundle)
1+
# Symfony CMF Routing Auto Bundle
22

3-
This bundle automatically creates and manages routes for configured persisted
4-
document classes.
5-
6-
*WARNING*: This bundle is still experimental. It works, but there may be some
7-
as-yet unknown issues. The API, however, should not change too much in the
8-
future.
3+
[![Build Status](https://secure.travis-ci.org/symfony-cmf/RoutingAutoBundle.png)](http://travis-ci.org/symfony-cmf/RoutingAutoBundle)
4+
[![Latest Stable Version](https://poser.pugx.org/symfony-cmf/routing-auto-bundle/version.png)](https://packagist.org/packages/symfony-cmf/routing-auto-bundle)
5+
[![Total Downloads](https://poser.pugx.org/symfony-cmf/routing-auto-bundle/d/total.png)](https://packagist.org/packages/symfony-cmf/routing-auto-bundle)
96

10-
See the [official documentation](http://symfony.com/doc/master/cmf/bundles/routing_auto/index.html)
7+
This bundle is part of the [Symfony Content Management Framework (CMF)](http://cmf.symfony.com/)
8+
and licensed under the [MIT License](LICENSE).
119

12-
## Example configuration
1310

14-
The following is the current functional test configuration:
11+
This bundle automatically creates and manages routes for configured persisted
12+
document classes.
1513

16-
symfony_cmf_routing_auto:
14+
## Requirements
1715

18-
auto_route_mapping:
16+
* Symfony 2.2.x
17+
* See also the `require` section of [composer.json](composer.json)
1918

20-
##
21-
# e.g. /cms/auto-route/blog/my-blogs-title
22-
Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Functional\app\Document\Blog:
19+
## Documentation
2320

24-
# generate or use path components leading up to the final part of the path
25-
content_path:
26-
base:
27-
provider:
28-
name: specified
29-
path: /test/auto-route/blog
30-
exists_action:
31-
strategy: use
32-
not_exists_action:
33-
strategy: create
34-
patcher: generic
21+
For the install guide and reference, see:
3522

36-
content_name:
37-
provider:
38-
name: from_object_method
39-
method: getTitle
40-
exists_action:
41-
strategy: auto_increment
42-
pattern: -%d
43-
not_exists_action:
44-
strategy: create
23+
* [RoutingAuto documentation](http://symfony.com/doc/master/cmf/bundles/routing_auto/index.html)
4524

46-
## Restrictions:
25+
See also:
4726

48-
* Only documents stored with PHPCR-ODM are supported.
49-
* You must have the RoutingBundle installed.
27+
* [Creating a basic CMS (with RoutingAuto)](http://symfony.com/doc/master/cmf/cookbook/creating_a_cms/index.html)
28+
* [All Symfony CMF documentation](http://symfony.com/doc/master/cmf/index.html) - complete Symfony CMF reference
29+
* [Symfony CMF Website](http://cmf.symfony.com/) - introduction, live demo, support and community links
5030

51-
## Installation
31+
## Contributing
5232

53-
Add a requirement for ``symfony-cmf/routing-auto-bundle`` to your
54-
composer.json and instantiate the bundle in your AppKernel.php
33+
Pull requests are welcome. Please see our
34+
[CONTRIBUTING](https://github.com/symfony-cmf/symfony-cmf/blob/master/CONTRIBUTING.md)
35+
guide.
5536

56-
new Symfony\Cmf\Bundle\RoutingAutoBundle\CmfRoutingAutoBundle()
37+
Unit and/or functional tests exist for this bundle. See the
38+
[Testing documentation](http://symfony.com/doc/master/cmf/components/testing.html)
39+
for a guide to running the tests.
5740

41+
Thanks to
42+
[everyone who has contributed](https://github.com/symfony-cmf/RoutingAutoBundle/contributors) already.
5843
## Running the tests
59-
60-
To initialize the test environment run the initialization script (you only need
61-
to do this once):
62-
63-
./Tests/Functional/init_travis.sh
64-
65-
Then run all the tests with:
66-
67-
phpunit -c phpunit.xml.dist

Resources/config/auto_route.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<parameters>
77

8-
<parameter key="cmf_routing_auto.phpcrodm_auto_route_listener_class">Symfony\Cmf\Bundle\RoutingAutoBundle\EventListener\AutoRouteListener</parameter>
8+
<parameter key="cmf_routing_auto.phpcrodm_auto_route_listener_class">Symfony\Cmf\Bundle\RoutingAutoBundle\Doctrine\Phpcr\AutoRouteListener</parameter>
99
<parameter key="cmf_routing_auto.auto_route_manager_class">Symfony\Cmf\Bundle\RoutingAutoBundle\AutoRoute\AutoRouteManager</parameter>
1010
<parameter key="cmf_routing_auto.factory_class">Symfony\Cmf\Bundle\RoutingAutoBundle\AutoRoute\Factory</parameter>
1111
<parameter key="cmf_routing_auto.route_stack_builder_class">Symfony\Cmf\Bundle\RoutingAutoBundle\AutoRoute\RouteStack\Builder</parameter>
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/phpcr/doctrine-mapping"
22
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
33

4-
<document name="Symfony\Cmf\Bundle\RoutingAutoBundle\Document\AutoRoute"/>
4+
<document name="Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute"/>
55

66
</doctrine-mapping>
77

Tests/Functional/EventListener/AutoRouteListenerTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Blog;
1717
use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Post;
1818
use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Article;
19-
use Symfony\Cmf\Bundle\RoutingAutoBundle\Document\AutoRoute;
19+
use Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute;
2020

2121
class AutoRouteListenerTest extends BaseTestCase
2222
{
@@ -52,7 +52,7 @@ public function testPersistBlog()
5252
$routes = $this->getDm()->getReferrers($blog);
5353

5454
$this->assertCount(1, $routes);
55-
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Document\AutoRoute', $routes[0]);
55+
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute', $routes[0]);
5656
$this->assertEquals('unit-testing-blog', $routes[0]->getName());
5757
}
5858

@@ -84,7 +84,7 @@ public function testUpdateRenameBlog($withPosts = false)
8484
$routes = $blog->routes;
8585

8686
$this->assertCount(1, $routes);
87-
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Document\AutoRoute', $routes[0]);
87+
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute', $routes[0]);
8888

8989
$this->assertEquals('foobar', $routes[0]->getName());
9090
$this->assertEquals('/test/auto-route/blog/foobar', $routes[0]->getId());
@@ -117,7 +117,7 @@ public function testUpdatePostNotChangingTitle()
117117
$routes = $post->routes;
118118

119119
$this->assertCount(1, $routes);
120-
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Document\AutoRoute', $routes[0]);
120+
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute', $routes[0]);
121121

122122
$this->assertEquals('this-is-a-post-title', $routes[0]->getName());
123123
}
@@ -148,7 +148,7 @@ public function testPersistPost()
148148
$routes = $this->getDm()->getReferrers($post);
149149

150150
$this->assertCount(1, $routes);
151-
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Document\AutoRoute', $routes[0]);
151+
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute', $routes[0]);
152152
$this->assertEquals('this-is-a-post-title', $routes[0]->getName());
153153
}
154154

@@ -165,7 +165,7 @@ public function testUpdatePost()
165165
$routes = $this->getDm()->getReferrers($post);
166166

167167
$this->assertCount(1, $routes);
168-
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Document\AutoRoute', $routes[0]);
168+
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute', $routes[0]);
169169
$this->assertEquals('this-is-different', $routes[0]->getName());
170170
}
171171

@@ -211,7 +211,7 @@ public function testMultilangArticle($data, $expectedPaths)
211211
$route = $this->getDm()->find(null, $expectedPath);
212212

213213
$this->assertNotNull($route);
214-
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Document\AutoRoute', $route);
214+
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute', $route);
215215

216216
$content = $route->getContent();
217217

0 commit comments

Comments
 (0)