Skip to content

Conversation

@NicolasJourdan
Copy link
Contributor

Hey ! 👋

I often use the command make:schedule and I wanted to add this new feature : Ask for the name used in the attribute #[AsSchedule].

Without name

Console :
Capture d’écran 2024-06-01 à 11 49 48

Generated class :

<?php

namespace App\Scheduler;

use Symfony\Component\Scheduler\Attribute\AsSchedule;
use Symfony\Component\Scheduler\RecurringMessage;
use Symfony\Component\Scheduler\Schedule;
use Symfony\Component\Scheduler\ScheduleProviderInterface;
use Symfony\Contracts\Cache\CacheInterface;

#[AsSchedule]
final class MainSchedule implements ScheduleProviderInterface
{
    public function __construct(
        private CacheInterface $cache,
    ) {
    }

    public function getSchedule(): Schedule
    {
        return (new Schedule())
        ->add(
            // @TODO - Create a Message to schedule
            // RecurringMessage::every('1 hour', new App\Message\Message()),
        )
        ->stateful($this->cache)
        ;
    }
}

With dummy name

Console :
Capture d’écran 2024-06-01 à 11 50 01

Generated class :

<?php

namespace App\Scheduler;

use Symfony\Component\Scheduler\Attribute\AsSchedule;
use Symfony\Component\Scheduler\RecurringMessage;
use Symfony\Component\Scheduler\Schedule;
use Symfony\Component\Scheduler\ScheduleProviderInterface;
use Symfony\Contracts\Cache\CacheInterface;

#[AsSchedule('dummy')]
final class MainSchedule implements ScheduleProviderInterface
{
    public function __construct(
        private CacheInterface $cache,
    ) {
    }

    public function getSchedule(): Schedule
    {
        return (new Schedule())
        ->add(
            // @TODO - Create a Message to schedule
            // RecurringMessage::every('1 hour', new App\Message\Message()),
        )
        ->stateful($this->cache)
        ;
    }
}

@NicolasJourdan NicolasJourdan force-pushed the feature/make-scheduler_add-attribute branch from 3197586 to dbe141b Compare June 1, 2024 10:16
Copy link
Contributor

@mdoutreluingne mdoutreluingne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Collaborator

@jrushlow jrushlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! One minor comment

@jrushlow jrushlow added Feature New Feature Status: Needs Work Additional work is needed labels Jun 4, 2024
@jrushlow jrushlow added this to the v1.60.0 milestone Jun 4, 2024
@jrushlow jrushlow added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Work Additional work is needed labels Jun 5, 2024
Copy link
Collaborator

@jrushlow jrushlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @NicolasJourdan!

@jrushlow jrushlow merged commit d4fa901 into symfony:main Jun 5, 2024
@jrushlow jrushlow mentioned this pull request Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New Feature Status: Reviewed Has been reviewed by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants