Skip to content

Commit

Permalink
More CI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierstoval committed Dec 27, 2017
1 parent f4a302e commit 083db46
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 45 deletions.
4 changes: 4 additions & 0 deletions .scrutinizer.yml
@@ -1,2 +1,6 @@
checks:
php: true

filter:
excluded_paths:
- Tests/
4 changes: 0 additions & 4 deletions .sensiolabs.yml
@@ -1,7 +1,3 @@
rules:
symfony.dependency_injection.no_entity_manager_as_parameter:
enabled: false

filter:
excluded_paths:
- "Tests/"
4 changes: 1 addition & 3 deletions Action/AbstractStepAction.php
Expand Up @@ -197,9 +197,7 @@ protected function flashMessage(string $msg, string $type = null, array $msgPara
: strtr($msg, $msgParams)
;

$session = $this->getSession();

$flashbag = $session->getFlashBag();
$flashbag = $this->getSession()->getFlashBag();

// Add the message manually.
$existingMessages = $flashbag->peek($type);
Expand Down
80 changes: 42 additions & 38 deletions DependencyInjection/Compiler/StepsPass.php
Expand Up @@ -143,50 +143,54 @@ private function processConfiguredServices(ContainerBuilder $container)
$registryDefinition = $container->getDefinition(ActionsRegistry::class);

foreach ($container->getParameter(static::PARAMETERS_MANAGERS) as $managerName => $config) {
$this->processStepAction($managerName, $config, $registryDefinition, $container);
}
}

/** @var array[] $finalSteps */
$finalSteps = $config['steps'];

foreach ($finalSteps as $step) {
$action = $step['action'];
if ($container->has($action)) {
/** @var $definition */
$definition = $container->getDefinition($action);
} else {
// If action is not yet a service, it means it's a class name.
// In this case, we create a new service.
$definition = new Definition($action);
$definition
->setLazy(true)
->setPrivate(true)
->setAutowired(true)
;
$container->setDefinition($action, $definition);
}
private function processStepAction(string $managerName, array $config, Definition $registryDefinition, ContainerBuilder $container): void
{
/** @var array[] $finalSteps */
$finalSteps = $config['steps'];

foreach ($finalSteps as $step) {
$action = $step['action'];
if ($container->has($action)) {
/** @var $definition */
$definition = $container->getDefinition($action);
} else {
// If action is not yet a service, it means it's a class name.
// In this case, we create a new service.
$definition = new Definition($action);
$definition
->addMethodCall('configure', [
$managerName,
$step['name'],
$config['character_class'],
new Reference(StepResolverInterface::class),
])
->setLazy(true)
->setPrivate(true)
->setAutowired(true)
;
$container->setDefinition($action, $definition);
}

// If class extends the abstract one, we inject some cool services.
if (is_a($definition->getClass(), AbstractStepAction::class, true)) {
$ignoreOnInvalid = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
$definition
->addMethodCall('setObjectManager', [new Reference(ObjectManager::class, $ignoreOnInvalid)])
->addMethodCall('setTwig', [new Reference(Environment::class, $ignoreOnInvalid)])
->addMethodCall('setRouter', [new Reference(RouterInterface::class, $ignoreOnInvalid)])
->addMethodCall('setTranslator', [new Reference(TranslatorInterface::class, $ignoreOnInvalid)])
;
}

// Finally add the step action to the registry
$registryDefinition->addMethodCall('addStepAction', [$step['name'], new Reference($action)]);
$definition
->addMethodCall('configure', [
$managerName,
$step['name'],
$config['character_class'],
new Reference(StepResolverInterface::class),
])
;

// If class extends the abstract one, we inject some cool services.
if (is_a($definition->getClass(), AbstractStepAction::class, true)) {
$ignoreOnInvalid = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
$definition
->addMethodCall('setObjectManager', [new Reference(ObjectManager::class, $ignoreOnInvalid)])
->addMethodCall('setTwig', [new Reference(Environment::class, $ignoreOnInvalid)])
->addMethodCall('setRouter', [new Reference(RouterInterface::class, $ignoreOnInvalid)])
->addMethodCall('setTranslator', [new Reference(TranslatorInterface::class, $ignoreOnInvalid)])
;
}

// Finally add the step action to the registry
$registryDefinition->addMethodCall('addStepAction', [$step['name'], new Reference($action)]);
}
}

Expand Down

0 comments on commit 083db46

Please sign in to comment.