A Symfony bundle for axi/mycalendar package.
Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
Open a command console, enter your project directory and execute:
composer require axi/mycalendar-bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
composer require axi/mycalendar-bundle
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php file of your project:
// config/bundles.php
return [
// ...
Axi\MyCalendarBundle\AxiMyCalendarBundle::class => ['all' => true],
];
axi_my_calendar:
# Select only certain recipes, use a list of FQDN recipes class names
only_recipes:
# - Axi\MyCalendar\Recipe\NowRecipe
# - Axi\MyCalendar\Recipe\MillionMinutesRecipe
# - App\NowRecipe
# Exclude certain recipes from the provided ones, use a list of FQDN recipes class names
except_recipes:
# - Axi\MyCalendar\Recipe\PlanetsRevolutionsRecipe
# Configure Recipe rendering, allowing to prevent / allow some recipes to be rendered with certain renderers
recipe_rendering:
# Allows only the specified renderers
only:
# Allows all available renderers but the ones listed here
exclude:
Axi\MyCalendar\Recipe\NowRecipe:
- Axi\MyCalendar\Renderer\JsonRenderer
- Axi\MyCalendar\Renderer\IcalRenderer
Inject Axi\MyCalendar\Service\CalendarService in your controller action and use it:
<?php
// src/Controller/MyController.php
namespace App;
use Axi\MyCalendar\Service\CalendarService;
use DateTimeImmutable;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class MyController extends AbstractController {
#[Route(
path: /events
)]
public function eventsDate(
CalendarService $calendarService
): Response {
$birthdate = new DateTimeImmutable('1984-01-12');
$events = $calendarService->getEvents($birthdate);
dump($events);
return new Response();
}
}
Create a new class that extends Axi\MyCalendar\Recipe\AbstractRecipe or at least implements Axi\MyCalendar\Recipe\RecipeInterface.
It will be automaticaly added to CalendarService recipes.
<?php
namespace App;
use Axi\MyCalendar\Recipe\AbstractRecipe;
use Axi\MyCalendar\Event;
use Symfony\Component\Translation\TranslatableMessage;
class NowRecipe extends AbstractRecipe
{
public function getEvents(\DateTimeImmutable $basedOn): array
{
$event = new Event(
new \DateTimeImmutable()
);
$event->setSummary(new TranslatableMessage('Now'));
$event->setSourceRecipe(self::class);
return [$event];
}
public function getSummary(...$vars): TranslatableMessage
{
return new TranslatableMessage('Now');
}
}
but you're also welcome to propose a PR to add it to the main project: https://github.com/axi/my-calendar/pulls
How can I help you explore Laravel packages today?