This repository was archived by the owner on Sep 16, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +107
-37
lines changed Expand file tree Collapse file tree 6 files changed +107
-37
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 3
3
namespace Symfony \Cmf \Bundle \RoutingAutoBundle \AutoRoute ;
4
4
5
5
use Doctrine \ODM \PHPCR \DocumentManager ;
6
+ use Symfony \Cmf \Bundle \RoutingAutoBundle \AutoRoute \RouteMakerInterface ;
6
7
use Symfony \Cmf \Bundle \RoutingAutoBundle \Document \AutoRoute ;
7
8
8
9
/**
11
12
*
12
13
* @author Daniel Leech <[email protected] >
13
14
*/
14
- class AutoRouteMaker
15
+ class AutoRouteMaker implements RouteMakerInterface
15
16
{
16
17
protected $ dm ;
17
18
@@ -20,7 +21,7 @@ public function __construct(DocumentManager $dm)
20
21
$ this ->dm = $ dm ;
21
22
}
22
23
23
- public function createOrUpdateAutoRoute ( AutoRouteStack $ autoRouteStack )
24
+ public function make ( RouteStack $ routeStack )
24
25
{
25
26
$ context = $ autoRouteStack ->getContext ();
26
27
$ content = $ context ->getContent ();
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Symfony \Cmf \Bundle \RoutingAutoBundle \AutoRoute ;
4
+
5
+ use Symfony \Cmf \Bundle \RoutingAutoBundle \AutoRoute \RouteMakerInterface ;
6
+
7
+ /**
8
+ * Default route maker class - automatically delegates to an
9
+ * appropriate maker depending on the context.
10
+ *
11
+ * @author Daniel Leech <[email protected] >
12
+ */
13
+ class RouteMaker implements RouteMakerInterface
14
+ {
15
+ protected $ autoRouteMaker ;
16
+ protected $ patcher ;
17
+
18
+ public function __construct (RouteMakerInterface $ autoRouteMaker , RouteMakerInterface $ patcher )
19
+ {
20
+ $ this ->autoRouteMaker = $ autoRouteMaker ;
21
+ $ this ->patcher = $ patcher ;
22
+ }
23
+
24
+ public function make (RouteStack $ routeStack )
25
+ {
26
+ if ($ routeStack instanceOf AutoRouteStack) {
27
+ $ this ->autoRouteMaker ->make ($ routeStack );
28
+ } else {
29
+ $ this ->patcher ->make ($ routeStack );
30
+ }
31
+ }
32
+ }
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- namespace Symfony \Cmf \Bundle \RoutingAutoBundle \AutoRoute \RoutePatcher ;
3
+ namespace Symfony \Cmf \Bundle \RoutingAutoBundle \AutoRoute \RouteMaker ;
4
4
5
- use Symfony \Cmf \Bundle \RoutingAutoBundle \AutoRoute \RoutePatcherInterface ;
5
+ use Symfony \Cmf \Bundle \RoutingAutoBundle \AutoRoute \RouteMakerInterface ;
6
6
use Doctrine \ODM \PHPCR \DocumentManager ;
7
7
use Doctrine \ODM \PHPCR \Document \Generic ;
8
8
use Symfony \Cmf \Bundle \RoutingAutoBundle \AutoRoute \RouteStack ;
13
13
*
14
14
* @author Daniel Leech <[email protected] >
15
15
*/
16
- class GenericPatcher implements RoutePatcherInterface
16
+ class GenericMaker implements RouteMakerInterface
17
17
{
18
18
public function __construct (DocumentManager $ dm )
19
19
{
20
20
$ this ->dm = $ dm ;
21
21
}
22
22
23
- public function patch (RouteStack $ routeStack )
23
+ public function make (RouteStack $ routeStack )
24
24
{
25
25
$ paths = $ routeStack ->getFullPaths ();
26
26
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Symfony \Cmf \Bundle \RoutingAutoBundle \AutoRoute \RouteMaker ;
4
+
5
+ use Symfony \Cmf \Bundle \RoutingAutoBundle \AutoRoute \RouteMakerInterface ;
6
+ use Doctrine \ODM \PHPCR \DocumentManager ;
7
+ use Doctrine \ODM \PHPCR \Document \Generic ;
8
+ use Symfony \Cmf \Bundle \RoutingAutoBundle \AutoRoute \RouteStack ;
9
+ use Symfony \Cmf \Bundle \RoutingAutoBundle \AutoRoute \Exception \MissingOptionException ;
10
+ use Symfony \Cmf \Bundle \RoutingExtraBundle \Document \Route ;
11
+
12
+ /**
13
+ * This class will make the Route classes using
14
+ * Generic documents using.
15
+ *
16
+ * @author Daniel Leech <[email protected] >
17
+ */
18
+ class RouteMaker implements RouteMakerInterface
19
+ {
20
+ protected $ defaults = array ();
21
+
22
+ public function __construct (DocumentManager $ dm )
23
+ {
24
+ $ this ->dm = $ dm ;
25
+ }
26
+
27
+ public function init (array $ options )
28
+ {
29
+ $ this ->defaults = $ defaults ;
30
+ }
31
+
32
+ public function make (RouteStack $ routeStack )
33
+ {
34
+ $ paths = $ routeStack ->getFullPaths ();
35
+
36
+ foreach ($ paths as $ path ) {
37
+ $ absPath = '/ ' .$ path ;
38
+ $ doc = $ this ->dm ->find (null , $ absPath );
39
+
40
+ if (null === $ doc ) {
41
+ $ doc = new Route ;
42
+ $ doc ->setDefaults ($ this ->defaults );
43
+ $ doc ->setId ($ absPath );
44
+ }
45
+
46
+ $ routeStack ->addRoute ($ doc );
47
+ }
48
+ }
49
+ }
50
+
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Symfony \Cmf \Bundle \RoutingAutoBundle \AutoRoute ;
4
+
5
+ use Symfony \Cmf \Bundle \RoutingAutoBundle \AutoRoute \RouteStack ;
6
+
7
+ /**
8
+ * Classes implementing this interface complete a route stack
9
+ * by adding one PHPCR-ODM document for each path element contained
10
+ * in the RouteStack.
11
+ *
12
+ * @author Daniel Leech <[email protected] >
13
+ * @date 13/03/24
14
+ */
15
+ class RouteMakerInterface
16
+ {
17
+ public function make (RouteStack $ routeStack );
18
+ }
You can’t perform that action at this time.
0 commit comments