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

Commit 0b96938

Browse files
committed
General progress
1 parent 2b7feb9 commit 0b96938

File tree

12 files changed

+141
-14
lines changed

12 files changed

+141
-14
lines changed

AutoRoute/AutoRouteManager.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public function updateAutoRouteForDocument($document)
4040

4141
$builderUnitChain = $this->bucf->getChain(ClassUtils::getClass($document));
4242
$builderUnitChain->executeChain($context);
43+
44+
return $context;
4345
}
4446

4547
/**

AutoRoute/PathExists/AutoIncrementPath.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@ public function execute(BuilderContext $context)
4040
$this->routeMaker->makeRoutes($context);
4141
}
4242
}
43-

AutoRoute/RouteMaker/GenericMaker.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@ public function makeRoutes(BuilderContext $context)
6060
// create the actual content route.
6161
$doc = new AutoRoute;
6262
$doc->setName($component);
63-
$doc->setRouteContent($context->getRouteContent());
63+
$doc->setRouteContent($context->getObject());
6464
$doc->setParent($parent);
6565
} else {
6666
// otherwise create a generic document
6767
$doc = new Generic;
6868
$doc->setNodename($component);
6969
$doc->setParent($parent);
70+
var_dump($parent);
7071
}
7172
}
7273

Resources/config/auto_route.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parameter key="symfony_cmf_routing_auto_route.auto_route_manager_class">Symfony\Cmf\Bundle\RoutingAutoRouteBundle\AutoRoute\AutoRouteManager</parameter>
1010
<parameter key="symfony_cmf_routing_auto_route.builder_unit_chain_factory_class">Symfony\Cmf\Bundle\RoutingAutoRouteBundle\AutoRoute\BuilderUnitChainFactory</parameter>
1111
<parameter key="symfony_cmf_routing_auto_route.builder_class">Symfony\Cmf\Bundle\RoutingAutoRouteBundle\AutoRoute\Builder</parameter>
12-
<parameter key="symfony_cmf_routing_auto_route.provider.specified_class">Symfony\Cmf\Bundle\RoutingAutoRouteBundle\AutoRoute\PathProvider\SpecifiedProvider</parameter>
12+
<parameter key="symfony_cmf_routing_auto_route.route_maker_class">Symfony\Cmf\Bundle\RoutingAutoRouteBundle\AutoRoute\RouteMaker\GenericMaker</parameter>
1313

1414
</parameters>
1515

@@ -42,5 +42,9 @@
4242
<argument type="service" id="doctrine_phpcr.default_session"/>
4343
</service>
4444

45+
<service id="symfony_cmf_routing_auto_route.route_maker" class="%symfony_cmf_routing_auto_route.route_maker_class%">
46+
<argument type="service" id="doctrine_phpcr.odm.default_document_manager"/>
47+
</service>
48+
4549
</services>
4650
</container>

Resources/config/exists_action.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<parameters>
77

88
<parameter key="symfony_cmf_routing_auto_route.exists_action.use_class">Symfony\Cmf\Bundle\RoutingAutoRouteBundle\AutoRoute\PathExists\UsePath</parameter>
9+
<parameter key="symfony_cmf_routing_auto_route.exists_action.auto_increment_class">Symfony\Cmf\Bundle\RoutingAutoRouteBundle\AutoRoute\PathExists\AutoIncrementPath</parameter>
910

1011
</parameters>
1112

@@ -14,11 +15,22 @@
1415
<service
1516
id="symfony_cmf_routing_auto_route.exists_action.use"
1617
class="%symfony_cmf_routing_auto_route.exists_action.use_class%"
18+
scope="prototype"
1719
>
1820
<argument type="service" id="doctrine_phpcr.odm.default_document_manager"/>
1921
<tag name="symfony_cmf_routing_auto_route.exists_action" alias="use"/>
2022
</service>
2123

24+
<service
25+
id="symfony_cmf_routing_auto_route.exists_action.auto_increment"
26+
class="%symfony_cmf_routing_auto_route.exists_action.auto_increment_class%"
27+
scope="prototype"
28+
>
29+
<argument type="service" id="doctrine_phpcr.odm.default_document_manager"/>
30+
<argument type="service" id="symfony_cmf_routing_auto_route.route_maker"/>
31+
<tag name="symfony_cmf_routing_auto_route.exists_action" alias="auto_increment"/>
32+
</service>
33+
2234
</services>
2335
</container>
2436

Resources/config/not_exists_action.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,27 @@
66
<parameters>
77

88
<parameter key="symfony_cmf_routing_auto_route.not_exists_action.throw_exception_class">Symfony\Cmf\Bundle\RoutingAutoRouteBundle\AutoRoute\PathNotExists\ThrowException</parameter>
9+
<parameter key="symfony_cmf_routing_auto_route.not_exists_action.create_class">Symfony\Cmf\Bundle\RoutingAutoRouteBundle\AutoRoute\PathNotExists\CreatePath</parameter>
910
</parameters>
1011

1112
<services>
1213

1314
<service
1415
id="symfony_cmf_routing_auto_route.not_exists_action.throw_exception"
1516
class="%symfony_cmf_routing_auto_route.not_exists_action.throw_exception_class%"
17+
scope="prototype"
1618
>
1719
<tag name="symfony_cmf_routing_auto_route.not_exists_action" alias="throw_exception"/>
1820
</service>
1921

22+
<service
23+
id="symfony_cmf_routing_auto_route.not_exists_action.create"
24+
class="%symfony_cmf_routing_auto_route.not_exists_action.create_class%"
25+
scope="prototype"
26+
>
27+
<argument type="service" id="symfony_cmf_routing_auto_route.route_maker"/>
28+
<tag name="symfony_cmf_routing_auto_route.not_exists_action" alias="create"/>
29+
</service>
30+
2031
</services>
2132
</container>

Resources/config/path_provider.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,27 @@
66
<parameters>
77

88
<parameter key="symfony_cmf_routing_auto_route.provider.specified_class">Symfony\Cmf\Bundle\RoutingAutoRouteBundle\AutoRoute\PathProvider\SpecifiedProvider</parameter>
9+
<parameter key="symfony_cmf_routing_auto_route.provider.from_object_method_class">Symfony\Cmf\Bundle\RoutingAutoRouteBundle\AutoRoute\PathProvider\FromObjectMethodProvider</parameter>
10+
911
</parameters>
1012

1113
<services>
1214

1315
<service
1416
id="symfony_cmf_routing_auto_route.path_provider.specified"
1517
class="%symfony_cmf_routing_auto_route.provider.specified_class%"
18+
scope="prototype"
1619
>
1720
<tag name="symfony_cmf_routing_auto_route.path_provider" alias="specified"/>
1821
</service>
1922

23+
<service
24+
id="symfony_cmf_routing_auto_route.path_provider.from_object_method"
25+
class="%symfony_cmf_routing_auto_route.provider.from_object_method_class%"
26+
scope="prototype"
27+
>
28+
<tag name="symfony_cmf_routing_auto_route.path_provider" alias="from_object_method"/>
29+
</service>
2030
</services>
2131
</container>
2232

Resources/docs/ideas.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
symfony_cmf_routing_auto_route:
2+
3+
class_route_builder_chains:
4+
5+
##
6+
# e.g. /cms/auto-route/blog/my-blogs-title
7+
8+
Symfony\Cmf\Bundle\RoutingAutoRouteBundle\Tests\Functional\app\Document\Blog:
9+
10+
- builder: fixed
11+
options:
12+
path: /cms/auto-route/blog
13+
auto_create: true
14+
15+
- builder: slugify_object_method
16+
method: getTitle
17+
slugger: symfony_cmf_routing_auto_route.default_slugger
18+
19+
##
20+
# e.g. /cms/auto-route/blog/my-blogs-title/2013-04-09/my-post-title
21+
22+
Symfony\Cmf\Bundle\RoutingAutoRouteBundle\Tests\Functional\app\Document\Post:
23+
24+
# /cms/auto-route/blog/my-blogs-title
25+
- builder: object_method
26+
from_method: getBlogRoutePath
27+
28+
exists: use
29+
not_exists: create
30+
31+
# 2013-04-09
32+
- builder: date
33+
format: yyyy-mm-dd
34+
from_method: getPublishedAt
35+
36+
exists: use
37+
not_exists: create
38+
39+
# my-post-title
40+
- builder: slugify_object_method
41+
from_method: getTitle
42+
slugfier: symfony_cmf_routing_auto_route.default_slugifier
43+
44+
exists: auto_increment
45+
pattern: -%d
46+
47+
not_exists: create

Subscriber/AutoRouteSubscriber.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ public function onFlush(OnFlushEventArgs $args)
4848

4949
foreach ($updates as $document) {
5050
if ($this->getArm()->isAutoRouteable($document)) {
51-
$route = $this->getArm()->updateAutoRouteForDocument($document);
52-
$uow->computeSingleDocumentChangeSet($route);
51+
$context = $this->getArm()->updateAutoRouteForDocument($document);
52+
foreach ($context->getRouteStack() as $route) {
53+
$dm->persist($route);
54+
$uow->computeSingleDocumentChangeSet($route);
55+
}
5356
}
5457
}
5558

Tests/Functional/Subscriber/AutoRouteSubscriberTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Symfony\Cmf\Bundle\RoutingAutoRouteBundle\Tests\Functional\Subscriber;
44

5-
use Symfony\Cmf\Bundle\RoutingAutoRouteBundle\Tests\Functional\app\Document\Post;
5+
use Symfony\Cmf\Bundle\RoutingAutoRouteBundle\Tests\Functional\app\Document\Blog;
66
use Symfony\Cmf\Bundle\RoutingAutoRouteBundle\Tests\Functional\BaseTestCase;
77

88
class AutoRouteSubscriberTest extends BaseTestCase
@@ -13,9 +13,9 @@ public function setUp()
1313
$this->manager = $this->getContainer()->get('symfony_cmf_routing_auto_route.auto_route_manager');
1414
}
1515

16-
protected function createPost()
16+
protected function createBlog()
1717
{
18-
$post = new Post;
18+
$post = new Blog;
1919
$post->path = '/test/test-post';
2020
$post->title = 'Unit testing blog post';
2121

@@ -24,9 +24,9 @@ protected function createPost()
2424
$this->getDm()->clear();
2525
}
2626

27-
public function testPersist()
27+
public function testPersistBlog()
2828
{
29-
$this->createPost();
29+
$this->createBlog();
3030

3131
$route = $this->getDm()->find(null, '/test/auto-route/posts/unit-testing-blog-post');
3232

@@ -43,7 +43,7 @@ public function testPersist()
4343

4444
public function testUpdate()
4545
{
46-
$this->createPost();
46+
$this->createBlog();
4747

4848
$post = $this->getDm()->find(null, '/test/test-post');
4949
// test update
@@ -67,7 +67,7 @@ public function testUpdate()
6767

6868
public function testRemove()
6969
{
70-
$this->createPost();
70+
$this->createBlog();
7171
$post = $this->getDm()->find(null, '/test/test-post');
7272

7373
// test removing

0 commit comments

Comments
 (0)