Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[make:schedule] Add transport name for attribute #1568

Merged

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

src/Resources/skeleton/scheduler/Schedule.tpl.php Outdated Show resolved Hide resolved
@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
Co-authored-by: Jesse Rushlow <40327885+jrushlow@users.noreply.github.com>
@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
8 checks passed
@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