improve autowiring and add workflow to tasks

This commit is contained in:
2018-04-25 12:03:16 +02:00
parent 196fc2c38f
commit adc830142b
10 changed files with 4669 additions and 117 deletions

View File

@@ -8,6 +8,7 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Chill\TaskBundle\Security\Authorization\TaskVoter;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Chill\TaskBundle\Workflow\TaskWorkflowManager;
/**
* This is the class that loads and manages your bundle configuration.
@@ -28,11 +29,26 @@ class ChillTaskExtension extends Extension implements PrependExtensionInterface
$loader->load('services/controller.yml');
$loader->load('services/security.yml');
$loader->load('services/repositories.yml');
$loader->load('services/workflow.yml');
}
public function prepend(ContainerBuilder $container)
{
$this->prependAuthorization($container);
$this->prependRoute($container);
$this->prependWorkflows($container);
}
protected function prependRoute(ContainerBuilder $container)
{
//declare routes for task bundle
$container->prependExtensionConfig('chill_main', array(
'routing' => array(
'resources' => array(
'@ChillTaskBundle/Resources/config/routing.yml'
)
)
));
}
public function prependAuthorization(ContainerBuilder $container)
@@ -44,5 +60,38 @@ class ChillTaskExtension extends Extension implements PrependExtensionInterface
)
));
}
protected function prependWorkflows(ContainerBuilder $container)
{
$container->prependExtensionConfig('framework', [
'workflows' => [
'task_default' => [
'marking_store' => [
'type' => 'multiple_state',
'arguments' => [
'currentStates'
],
],
'type' => 'workflow',
'support_strategy' => TaskWorkflowManager::class,
'places' => [ 'new', 'in_progress', 'closed', 'canceled'],
'initial_place' => 'new',
'transitions' => [
'start' => [
'from' => 'new',
'to' => 'in_progress'
],
'close' => [
'from' => 'in_progress',
'to' => 'closed'
],
'cancel' => [
'from' => ['new', 'in_progress'],
'to' => 'canceled'
]
]
]
]
]);
}
}