/
sf_dic.services.yml
264 lines (237 loc) · 8.32 KB
/
sf_dic.services.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
parameters:
debug.container.dump: '%kernel.cache_dir%/%kernel.container_class%.xml'
services:
# Register the container itself as a synthetic service for the modules to be
# able to use it as a dependency
service_container:
public: true
class: Symfony\Component\DependencyInjection\ContainerInterface
synthetic: true
kernel:
public: true
class: Symfony\Component\HttpKernel\KernelInterface
factory: [Drupal, _getKernel]
# Null implementation of the controller resolver when not using fullstack is
# spawned using the FrameworkBundleIntegrationPass compiler pass, get over it!
# Following is the actual Symfony definition
http_kernel:
public: true
class: Symfony\Component\HttpKernel\HttpKernel
arguments: ["@event_dispatcher", "@controller_resolver", "@request_stack"]
# Request stack, because we can
request_stack:
public: true
class: Symfony\Component\HttpFoundation\RequestStack
# Breadcrumb manager
breadcrumb:
public: true
class: Drupal\Core\Breadcrumb\BreadcrumbManager
# Current logged in user, not exactly the same signature than Drupal 8
# but will be API compatible for most use cases
current_user:
public: true
class: Drupal\Core\Session\UserSession
arguments: ["@entity.manager"]
# Pass-through to get the database connection via the service container,
# available for being a dependency of other services
database:
public: true
class: DatabaseConnection
factory: [Database, getConnection]
drupal.database:
public: false
alias: database
# Form builder
form_builder:
public: true
class: Drupal\Core\Form\FormBuilder
arguments: ["@service_container", "@logger.channel.form"]
# Module handler, will only proxify what Drupal 7 can do
module_handler:
public: true
class: Drupal\Core\Extension\ModuleHandler
# Cache factory
cache_factory:
public: false
class: Drupal\Core\Cache\CacheFactory
# Expose a few cache backends, core ones minus the very Drupal 8 specific ones
cache.bootstrap:
public: true
class: Drupal\Core\Cache\CacheBackendInterface
factory: cache_factory:get
arguments: [cache_bootstrap]
cache.default:
public: true
class: Drupal\Core\Cache\CacheBackendInterface
factory: cache_factory:get
arguments: [cache]
cache.entity:
public: true
class: Drupal\Core\Cache\CacheBackendInterface
factory: cache_factory:get
arguments: [cache_field]
cache.menu:
public: true
class: Drupal\Core\Cache\CacheBackendInterface
factory: cache_factory:get
arguments: [cache_menu]
cache.render:
public: true
class: Drupal\Core\Cache\CacheBackendInterface
factory: cache_factory:get
arguments: [cache]
cache.data:
public: true
class: Drupal\Core\Cache\CacheBackendInterface
factory: cache_factory:get
arguments: [cache]
# Register arbitrarily a set of entity controllers which the core provides,
# this is not Drupal 8 compatible, since it only exposes a single
# entity.manager service (which is incredibly stupid)
# @todo
# expose all controllers with their own service?
entity.manager:
public: true
class: Drupal\Core\Entity\EntityManager
# Also register the bare minimum anyone would need to work with path
# aliases the Drupal 8 way
path.alias_manager:
public: true
class: Drupal\Core\Path\AliasManager
arguments: ['@path.alias_storage', '@cache.data']
path.alias_storage:
public: true
class: Drupal\Core\Path\DefaultAliasStorage
arguments: ['@database', '@module_handler']
path.current:
public: true
class: Drupal\Core\Path\CurrentPathStack
arguments: ['@request_stack']
# We are not going to use Drupal 8 event dispatcher, but hopefully the
# symfony vanilla one is API compatible
event_dispatcher:
public: true
class: Symfony\Component\EventDispatcher\EventDispatcher
arguments: ["@service_container"]
tags: [{name: container.hot_path}]
Symfony\Component\EventDispatcher\EventDispatcherInterface:
alias: event_dispatcher
# Logger that sends everything into the watchdog
logger.watchdog:
public: false
class: MakinaCorpus\Drupal\Sf\Container\Log\DrupalLogger
# Logger factory from Drupal 8
logger.factory:
public: true
class: Drupal\Core\Logger\LoggerChannelFactory
calls:
- [addLogger, ["@logger.watchdog"]]
# Expose Drupal 8 default logger channels
logger.channel_base:
abstract: true
class: Drupal\Core\Logger\LoggerChannel
factory: ["@logger.factory", get]
logger.channel.default:
public: true
# Sorry this one is public, because we are going to use it in our unit
# tests, it should be set privte ideally
parent: logger.channel_base
arguments: ['system']
logger.channel.php:
public: false
parent: logger.channel_base
arguments: ['php']
logger.channel.image:
public: false
parent: logger.channel_base
arguments: ['image']
logger.channel.cron:
public: false
parent: logger.channel_base
arguments: ['cron']
logger.channel.file:
public: false
parent: logger.channel_base
arguments: ['file']
logger.channel.form:
public: false
parent: logger.channel_base
arguments: ['form']
session.drupal:
public: true
class: MakinaCorpus\Drupal\Sf\Session\DrupalSession
session:
public: true
alias: session.drupal
# Register a few Drupal twig helpers, no matter we are using it or not they
# will be ignored if no twig is running, but aside of that, if Twig is there
# but not the bundle, this'll work gracefully
twig.extension.drupal_common:
public: false
class: MakinaCorpus\Drupal\Sf\Twig\Extension\DrupalExtension
tags: [{name: twig.extension}]
twig.extension.drupal_http_render:
public: true
class: MakinaCorpus\Drupal\Sf\Twig\Extension\HttpRenderExtension
arguments: ['@http_kernel', '@request_stack']
tags: [{name: twig.extension}]
sf_dic.console.command.dropkernel:
public: false
class: MakinaCorpus\Drupal\Sf\Command\DropKernelCacheCommand
tags: [{name: console.command}]
sf_dic.console.command.cacheclear:
public: false
class: MakinaCorpus\Drupal\Sf\Command\CacheClearCommand
tags: [{name: console.command}]
sf_dic.console.command.panic:
public: false
class: MakinaCorpus\Drupal\Sf\Command\PanicCommand
tags: [{name: console.command}]
sf_dic.console.command.generate_entity:
public: false
class: MakinaCorpus\Drupal\Sf\Command\GenerateEntityCommand
tags: [{name: console.command}]
sf_dic.console.command.give_me_cats:
public: false
class: MakinaCorpus\Drupal\Sf\Command\GiveMeCatsCommand
tags: [{name: console.command}]
# Scalar from GET/POST argument resolver
sf_dic.argument_value_resolver.scalar_query:
class: MakinaCorpus\Drupal\Sf\Controller\ArgumentResolver\RequestQueryValueResolver
public: false
# Run before default value resolver
tags: [{name: controller.argument_value_resolver, priority: -80}]
# UserSession argument resolver
sf_dic.argument_value_resolver.user_session:
class: MakinaCorpus\Drupal\Sf\Controller\ArgumentResolver\UserSessionValueResolver
public: false
# Run before default value resolver
tags: [{name: controller.argument_value_resolver, priority: -80}]
# Custom node access helper
sf_dic.node_access.subscriber:
public: true
class: MakinaCorpus\Drupal\Sf\EventDispatcher\NodeAccessSubscriber
arguments: ["@event_dispatcher"]
tags: [{name: event_subscriber}]
# Custom router
sf_dic.drupal_router:
public: true
class: MakinaCorpus\Drupal\Sf\Routing\DrupalRouter
decorates: router
arguments: ['@sf_dic.drupal_router.inner']
# Symfony controller proxy: where Drupal router driven Symfony controllers
# are executed, response are built and handled, and exceptions are handled
# too
sf_dic.controller_handler:
public: true
class: MakinaCorpus\Drupal\Sf\Controller\ControllerHandler
arguments: ["@argument_resolver", "@service_container", "@event_dispatcher", "@http_kernel"]
# Empty testing service, it will contain all services this module provides
# in order to be able to unit test it
test_empty_service:
public: true
class: MakinaCorpus\Drupal\Sf\Tests\Mockup\EmptyService
arguments: ["%some_variable%"]
calls:
- [setContainer, ["@service_container"]]
- [setDatabaseConnection, ["@database"]]