Skip to content

Commit

Permalink
Merge pull request #448 from tienvx/fix-non-existent-service
Browse files Browse the repository at this point in the history
Fix non existent service
  • Loading branch information
tienvx committed Dec 12, 2019
2 parents 0b4411e + 473496a commit 1262fa9
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/DependencyInjection/Compiler/ModelPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public function process(ContainerBuilder $container): void
$modelHelperDefinition->addMethodCall('addModel', [$name, $type, new Reference($serviceId)]);

$this->mergeGuardConfiguration($container, $type, $name, $guardHelperDefinition);
$workflowId = sprintf('%s.%s', $type, $name);
$container->removeDefinition($workflowId);
$this->removeWorkflow($container, $type, $name);
}
}
$guardHelperDefinition->addMethodCall('setExpressionLanguage', [new Reference('workflow.security.expression_language')]);
Expand Down Expand Up @@ -64,4 +63,21 @@ protected function mergeGuardConfiguration(ContainerBuilder $container, string $
$container->removeDefinition($guardId);
}
}

protected function removeWorkflow(ContainerBuilder $container, string $type, string $name): void
{
$workflowId = sprintf('%s.%s', $type, $name);
$container->removeDefinition($workflowId);

$registryDefinition = $container->getDefinition('workflow.registry');
$calls = $registryDefinition->getMethodCalls();

foreach ($calls as $i => $call) {
if ('addWorkflow' === $call[0] && $workflowId === (string) $call[1][0]) {
unset($calls[$i]);
break;
}
}
$registryDefinition->setMethodCalls($calls);
}
}

0 comments on commit 1262fa9

Please sign in to comment.