Skip to content

Commit 5970020

Browse files
authored
Merge pull request #18 from NicoHaase/fix/symfony-flex
Properly adding tags through the extension (rather than having a service configuration for this)
2 parents 1fcb603 + b15c329 commit 5970020

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

DependencyInjection/RewieerTaskSchedulerExtension.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace Rewieer\TaskSchedulerBundle\DependencyInjection;
1010

11+
use Rewieer\TaskSchedulerBundle\Task\TaskInterface;
1112
use Symfony\Component\DependencyInjection\ContainerBuilder;
1213
use Symfony\Component\Config\FileLocator;
1314
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
@@ -16,8 +17,10 @@
1617
class RewieerTaskSchedulerExtension extends Extension {
1718
public function load(array $configs, ContainerBuilder $container)
1819
{
20+
$container->registerForAutoconfiguration(TaskInterface::class)->addTag('ts.task');
21+
1922
$configuration = new Configuration();
20-
$config = $this->processConfiguration($configuration, $configs);
23+
$this->processConfiguration($configuration, $configs);
2124

2225
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
2326
$loader->load('services.xml');

README.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ For this bundle to work, you must be able to define *CRON* jobs on your server.
1212

1313
Start by adding the bundle to your *composer.json* : `composer require rewieer/taskschedulerbundle`
1414

15-
Then add the bundle to your *AppKernel.php* :
15+
Symfony Flex will automatically enable that bundle for you. If you are not using Flex yet, add the bundle to your *AppKernel.php* :
1616
```php
1717
// in AppKernel::registerBundles()
1818
$bundles = array(
@@ -51,14 +51,6 @@ class Task extends AbstractScheduledTask {
5151
}
5252
```
5353

54-
In your *services.xml* :
55-
```xml
56-
<service id="my.task" class="Foo\Bar\Task">
57-
<tag name="ts.task" />
58-
</service>
59-
```
60-
6154
Your task is now scheduled and will be called every 5 minutes.
6255

63-
6456
You're good to go! You can now check your logs to see if this is working.

0 commit comments

Comments
 (0)