Skip to content

Commit e01ff5a

Browse files
committed
[Workflow] Make many internal services as hidden
1 parent 525fdd3 commit e01ff5a

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
632632
if ('workflow' === $type) {
633633
$transitionDefinition = new Definition(Workflow\Transition::class, [$transition['name'], $transition['from'], $transition['to']]);
634634
$transitionDefinition->setPublic(false);
635-
$transitionId = sprintf('%s.transition.%s', $workflowId, $transitionCounter++);
635+
$transitionId = sprintf('.%s.transition.%s', $workflowId, $transitionCounter++);
636636
$container->setDefinition($transitionId, $transitionDefinition);
637637
$transitions[] = new Reference($transitionId);
638638
if (isset($transition['guard'])) {
@@ -654,7 +654,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
654654
foreach ($transition['to'] as $to) {
655655
$transitionDefinition = new Definition(Workflow\Transition::class, [$transition['name'], $from, $to]);
656656
$transitionDefinition->setPublic(false);
657-
$transitionId = sprintf('%s.transition.%s', $workflowId, $transitionCounter++);
657+
$transitionId = sprintf('.%s.transition.%s', $workflowId, $transitionCounter++);
658658
$container->setDefinition($transitionId, $transitionDefinition);
659659
$transitions[] = new Reference($transitionId);
660660
if (isset($transition['guard'])) {
@@ -750,7 +750,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
750750
$listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.transition', $name), 'method' => 'onTransition']);
751751
$listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.enter', $name), 'method' => 'onEnter']);
752752
$listener->addArgument(new Reference('logger'));
753-
$container->setDefinition(sprintf('%s.listener.audit_trail', $workflowId), $listener);
753+
$container->setDefinition(sprintf('.%s.listener.audit_trail', $workflowId), $listener);
754754
}
755755

756756
// Add Guard Listener
@@ -779,7 +779,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
779779
$guard->addTag('kernel.event_listener', ['event' => $eventName, 'method' => 'onTransition']);
780780
}
781781

782-
$container->setDefinition(sprintf('%s.listener.guard', $workflowId), $guard);
782+
$container->setDefinition(sprintf('.%s.listener.guard', $workflowId), $guard);
783783
$container->setParameter('workflow.has_guard_listeners', true);
784784
}
785785
}

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public function testWorkflows()
264264
$params = $transitionsMetadataCall[1];
265265
$this->assertCount(2, $params);
266266
$this->assertInstanceOf(Reference::class, $params[0]);
267-
$this->assertSame('state_machine.pull_request.transition.0', (string) $params[0]);
267+
$this->assertSame('.state_machine.pull_request.transition.0', (string) $params[0]);
268268

269269
$serviceMarkingStoreWorkflowDefinition = $container->getDefinition('workflow.service_marking_store_workflow');
270270
/** @var Reference $markingStoreRef */
@@ -311,7 +311,7 @@ public function testWorkflowMultipleTransitionsWithSameName()
311311

312312
$this->assertCount(5, $transitions);
313313

314-
$this->assertSame('workflow.article.transition.0', (string) $transitions[0]);
314+
$this->assertSame('.workflow.article.transition.0', (string) $transitions[0]);
315315
$this->assertSame([
316316
'request_review',
317317
[
@@ -322,7 +322,7 @@ public function testWorkflowMultipleTransitionsWithSameName()
322322
],
323323
], $container->getDefinition($transitions[0])->getArguments());
324324

325-
$this->assertSame('workflow.article.transition.1', (string) $transitions[1]);
325+
$this->assertSame('.workflow.article.transition.1', (string) $transitions[1]);
326326
$this->assertSame([
327327
'journalist_approval',
328328
[
@@ -333,7 +333,7 @@ public function testWorkflowMultipleTransitionsWithSameName()
333333
],
334334
], $container->getDefinition($transitions[1])->getArguments());
335335

336-
$this->assertSame('workflow.article.transition.2', (string) $transitions[2]);
336+
$this->assertSame('.workflow.article.transition.2', (string) $transitions[2]);
337337
$this->assertSame([
338338
'spellchecker_approval',
339339
[
@@ -344,7 +344,7 @@ public function testWorkflowMultipleTransitionsWithSameName()
344344
],
345345
], $container->getDefinition($transitions[2])->getArguments());
346346

347-
$this->assertSame('workflow.article.transition.3', (string) $transitions[3]);
347+
$this->assertSame('.workflow.article.transition.3', (string) $transitions[3]);
348348
$this->assertSame([
349349
'publish',
350350
[
@@ -356,7 +356,7 @@ public function testWorkflowMultipleTransitionsWithSameName()
356356
],
357357
], $container->getDefinition($transitions[3])->getArguments());
358358

359-
$this->assertSame('workflow.article.transition.4', (string) $transitions[4]);
359+
$this->assertSame('.workflow.article.transition.4', (string) $transitions[4]);
360360
$this->assertSame([
361361
'publish',
362362
[
@@ -372,10 +372,10 @@ public function testWorkflowGuardExpressions()
372372
{
373373
$container = $this->createContainerFromFile('workflow_with_guard_expression');
374374

375-
$this->assertTrue($container->hasDefinition('workflow.article.listener.guard'), 'Workflow guard listener is registered as a service');
375+
$this->assertTrue($container->hasDefinition('.workflow.article.listener.guard'), 'Workflow guard listener is registered as a service');
376376
$this->assertTrue($container->hasParameter('workflow.has_guard_listeners'), 'Workflow guard listeners parameter exists');
377377
$this->assertTrue(true === $container->getParameter('workflow.has_guard_listeners'), 'Workflow guard listeners parameter is enabled');
378-
$guardDefinition = $container->getDefinition('workflow.article.listener.guard');
378+
$guardDefinition = $container->getDefinition('.workflow.article.listener.guard');
379379
$this->assertSame([
380380
[
381381
'event' => 'workflow.article.guard.publish',
@@ -385,9 +385,9 @@ public function testWorkflowGuardExpressions()
385385
$guardsConfiguration = $guardDefinition->getArgument(0);
386386
$this->assertTrue(1 === \count($guardsConfiguration), 'Workflow guard configuration contains one element per transition name');
387387
$transitionGuardExpressions = $guardsConfiguration['workflow.article.guard.publish'];
388-
$this->assertSame('workflow.article.transition.3', (string) $transitionGuardExpressions[0]->getArgument(0));
388+
$this->assertSame('.workflow.article.transition.3', (string) $transitionGuardExpressions[0]->getArgument(0));
389389
$this->assertSame('!!true', $transitionGuardExpressions[0]->getArgument(1));
390-
$this->assertSame('workflow.article.transition.4', (string) $transitionGuardExpressions[1]->getArgument(0));
390+
$this->assertSame('.workflow.article.transition.4', (string) $transitionGuardExpressions[1]->getArgument(0));
391391
$this->assertSame('!!false', $transitionGuardExpressions[1]->getArgument(1));
392392
}
393393

0 commit comments

Comments
 (0)