Skip to content

Commit

Permalink
Merge pull request #18 from NicoHaase/fix/symfony-flex
Browse files Browse the repository at this point in the history
Properly adding tags through the extension (rather than having a service configuration for this)
  • Loading branch information
NicoHaase authored Apr 1, 2020
2 parents 1fcb603 + b15c329 commit 5970020
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
5 changes: 4 additions & 1 deletion DependencyInjection/RewieerTaskSchedulerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Rewieer\TaskSchedulerBundle\DependencyInjection;

use Rewieer\TaskSchedulerBundle\Task\TaskInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
Expand All @@ -16,8 +17,10 @@
class RewieerTaskSchedulerExtension extends Extension {
public function load(array $configs, ContainerBuilder $container)
{
$container->registerForAutoconfiguration(TaskInterface::class)->addTag('ts.task');

$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$this->processConfiguration($configuration, $configs);

$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
Expand Down
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For this bundle to work, you must be able to define *CRON* jobs on your server.

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

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

In your *services.xml* :
```xml
<service id="my.task" class="Foo\Bar\Task">
<tag name="ts.task" />
</service>
```

Your task is now scheduled and will be called every 5 minutes.


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

0 comments on commit 5970020

Please sign in to comment.