7
7
8
8
class Container extends ContainerBuilder
9
9
{
10
+ const MODE_EMBEDDED_SHELL = 'shell ' ;
11
+ const MODE_EMBEDDED_COMMAND = 'command ' ;
12
+ const MODE_STANDALONE = 'standalon ' ;
13
+
14
+ protected $ mode ;
15
+
10
16
/**
11
17
* @var array Transports
12
18
*/
@@ -15,9 +21,11 @@ class Container extends ContainerBuilder
15
21
'transport.transport.jackrabbit ' => 'PHPCR\Shell\Transport\Transport\Jackrabbit ' ,
16
22
);
17
23
18
- public function __construct ()
24
+ public function __construct ($ mode = self :: MODE_STANDALONE )
19
25
{
20
26
parent ::__construct ();
27
+ $ this ->mode = $ mode ;
28
+
21
29
$ this ->registerHelpers ();
22
30
$ this ->registerConfig ();
23
31
$ this ->registerPhpcr ();
@@ -75,27 +83,11 @@ public function registerEvent()
75
83
{
76
84
$ ids = array ();
77
85
$ subscribers = array ();
86
+
78
87
$ subscribers [] = $ this ->register (
79
88
$ ids [] = 'event.subscriber.profile_from_session_input ' ,
80
89
'PHPCR\Shell\Subscriber\ProfileFromSessionInputSubscriber '
81
90
);
82
- $ subscribers [] = $ this ->register (
83
- $ ids [] = 'event.subscriber.profile_writer ' ,
84
- 'PHPCR\Shell\Subscriber\ProfileWriterSubscriber '
85
- )
86
- ->addArgument (new Reference ('config.profile_loader ' ))
87
- ->addArgument (new Reference ('helper.question ' ));
88
- $ subscribers [] = $ this ->register (
89
- $ ids [] = 'event.subscriber.profile_loader ' ,
90
- 'PHPCR\Shell\Subscriber\ProfileLoaderSubscriber '
91
- )
92
- ->addArgument (new Reference ('config.profile_loader ' ))
93
- ->addArgument (new Reference ('helper.question ' ));
94
- $ subscribers [] = $ this ->register (
95
- $ ids [] = 'event.subscriber.config_init ' ,
96
- 'PHPCR\Shell\Subscriber\ConfigInitSubscriber '
97
- )
98
- ->addArgument (new Reference ('config.manager ' ));
99
91
$ subscribers [] = $ this ->register (
100
92
$ ids [] = 'event.subscriber.exception ' ,
101
93
'PHPCR\Shell\Subscriber\ExceptionSubscriber '
@@ -104,12 +96,37 @@ public function registerEvent()
104
96
$ ids [] = 'event.subscriber.alias ' ,
105
97
'PHPCR\Shell\Subscriber\AliasSubscriber '
106
98
)
107
- ->addArgument (new Reference ('config.manager ' ));
99
+ ->addArgument (new Reference ('config.manager ' ));
100
+
101
+ if ($ this ->mode === self ::MODE_STANDALONE ) {
102
+ $ subscribers [] = $ this ->register (
103
+ $ ids [] = 'event.subscriber.profile_writer ' ,
104
+ 'PHPCR\Shell\Subscriber\ProfileWriterSubscriber '
105
+ )
106
+ ->addArgument (new Reference ('config.profile_loader ' ))
107
+ ->addArgument (new Reference ('helper.question ' ));
108
+ $ subscribers [] = $ this ->register (
109
+ $ ids [] = 'event.subscriber.profile_loader ' ,
110
+ 'PHPCR\Shell\Subscriber\ProfileLoaderSubscriber '
111
+ )
112
+ ->addArgument (new Reference ('config.profile_loader ' ))
113
+ ->addArgument (new Reference ('helper.question ' ));
114
+ $ subscribers [] = $ this ->register (
115
+ $ ids [] = 'event.subscriber.config_init ' ,
116
+ 'PHPCR\Shell\Subscriber\ConfigInitSubscriber '
117
+ )
118
+ ->addArgument (new Reference ('config.manager ' ));
119
+ }
108
120
109
121
$ dispatcher = $ this ->register ('event.dispatcher ' , 'Symfony\Component\EventDispatcher\EventDispatcher ' );
110
122
111
123
foreach ($ ids as $ id ) {
112
124
$ dispatcher ->addMethodCall ('addSubscriber ' , array (new Reference ($ id )));
113
125
}
114
126
}
127
+
128
+ public function getMode ()
129
+ {
130
+ return $ this ->mode ;
131
+ }
115
132
}
0 commit comments