Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .github/workflows/code_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,11 @@ jobs:
stability: prefer-stable
minimum-stability: stable
is-current: true
- php: '8.4'
symfony-version: '^8.0'
stability: prefer-stable
minimum-stability: dev
is-current: true
- php: '8.5'
symfony-version: 8.0.*
stability: prefer-stable
minimum-stability: stable
is-current: false
- php: '8.5'
symfony-version: '^8.0'
stability: prefer-stable
minimum-stability: dev
is-current: false

name: PHP ${{ matrix.php }} - ${{ matrix.symfony-version }} - ${{ matrix.stability }}
steps:
Expand Down
3 changes: 3 additions & 0 deletions config/routing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fc_load_events:
path: /fc-load-events
controller: CalendarBundle\Controller\CalendarController::load
23 changes: 23 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
services:
CalendarBundle\Serializer\Serializer:
class: CalendarBundle\Serializer\Serializer

CalendarBundle\Serializer\SerializerInterface:
alias: CalendarBundle\Serializer\Serializer

calendar.serializer:
alias: CalendarBundle\Serializer\Serializer

CalendarBundle\Controller\CalendarController:
class: CalendarBundle\Controller\CalendarController
public: true
autowire: true
arguments:
$eventDispatcher: '@event_dispatcher'
$serializer: '@CalendarBundle\Serializer\Serializer'
tags:
- controller.service_arguments

calendar.controller:
alias: CalendarBundle\Controller\CalendarController
public: true
File renamed without changes.
File renamed without changes.
File renamed without changes.
81 changes: 81 additions & 0 deletions docs/upgrade-to-abstractbundle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Migrating to v8.1

This guide explains how to upgrade your application when updating CalendarBundle to the version 8.1.

## What Changed

The bundle has been modernized to follow Symfony 8 best practices:

| Before | After |
|--------|-------|
| `src/CalendarBundle.php` extends `Bundle` | Extends `AbstractBundle` |
| `src/DependencyInjection/CalendarExtension.php` | Removed (merged into bundle) |
| `src/DependencyInjection/Configuration.php` | Removed |
| `src/Resources/config/services.yaml` | `config/services.yaml` |
| `src/Resources/config/routing.yaml` | `config/routing.yaml` |
| `src/Resources/views/` | `templates/` |
| `src/Resources/doc/` | `docs/` |
| `tests/DependencyInjection/CalendarExtensionTest.php` | `tests/DependencyInjection/CalendarBundleTest.php` |

### New Service Aliases

Short service aliases have been added for convenience:

| Class Name | Alias |
|------------|-------|
| `CalendarBundle\Serializer\Serializer` | `calendar.serializer` |
| `CalendarBundle\Controller\CalendarController` | `calendar.controller` |

Both naming conventions are supported.

## Breaking Changes

### 1. Routing Configuration Path

If you import the bundle's routing manually, update the path:

**Before:**
```yaml
# config/routes/calendar.yaml
calendar:
resource: '@CalendarBundle/Resources/config/routing.yaml'
```

**After:**
```yaml
# config/routes/calendar.yaml
calendar:
resource: '@CalendarBundle/config/routing.yaml'
```

### 2. Template Path (if overriding)

If you override the bundle's templates in your application, no change is required. Symfony automatically resolves the correct location.

## Migration Steps

1. **Update the bundle** via Composer:
```bash
composer update tattali/calendar-bundle
```

2. **Update routing import** in `config/routes/calendar.yaml` (if using manual import):
```yaml
calendar:
resource: '@CalendarBundle/config/routing.yaml'
```

3. **Clear cache**:
```bash
php bin/console cache:clear
```

## No Changes Required

The following remain unchanged and fully backward compatible:

- **Service IDs** - `CalendarBundle\Serializer\Serializer`, `CalendarBundle\Controller\CalendarController`, and `CalendarBundle\Serializer\SerializerInterface` alias
- **Event subscriber pattern** - Your `SetDataEvent` subscribers work exactly the same
- **API endpoint** - `/fc-load-events` route and behavior unchanged
- **Event entity** - `CalendarBundle\Entity\Event` unchanged
- **Frontend integration** - No JavaScript changes needed
18 changes: 16 additions & 2 deletions src/CalendarBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@

namespace CalendarBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;

class CalendarBundle extends Bundle {}
class CalendarBundle extends AbstractBundle
{
/**
* @param array<string, mixed> $config
*/
public function loadExtension(
array $config,
ContainerConfigurator $container,
ContainerBuilder $builder,
): void {
$container->import('../config/services.yaml');
}
}
27 changes: 0 additions & 27 deletions src/DependencyInjection/CalendarExtension.php

This file was deleted.

24 changes: 0 additions & 24 deletions src/DependencyInjection/Configuration.php

This file was deleted.

4 changes: 0 additions & 4 deletions src/Resources/config/routing.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions src/Resources/config/services.yaml

This file was deleted.

File renamed without changes.
82 changes: 82 additions & 0 deletions tests/DependencyInjection/CalendarBundleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

declare(strict_types=1);

namespace CalendarBundle\Tests\DependencyInjection;

use CalendarBundle\CalendarBundle;
use CalendarBundle\Controller\CalendarController;
use CalendarBundle\Serializer\Serializer;
use CalendarBundle\Serializer\SerializerInterface;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;

final class CalendarBundleTest extends TestCase
{
public function testLoadExtensionRegistersServices(): void
{
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(\dirname(__DIR__, 2) . '/config'));
$loader->load('services.yaml');

self::assertTrue($container->hasDefinition(Serializer::class));
self::assertTrue($container->hasDefinition(CalendarController::class));
self::assertTrue($container->hasAlias(SerializerInterface::class));
}

public function testSerializerServiceConfiguration(): void
{
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(\dirname(__DIR__, 2) . '/config'));
$loader->load('services.yaml');

$definition = $container->getDefinition(Serializer::class);
self::assertSame(Serializer::class, $definition->getClass());
}

public function testControllerServiceConfiguration(): void
{
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(\dirname(__DIR__, 2) . '/config'));
$loader->load('services.yaml');

$definition = $container->getDefinition(CalendarController::class);
self::assertSame(CalendarController::class, $definition->getClass());
self::assertTrue($definition->isPublic());
self::assertTrue($definition->isAutowired());
}

public function testBundleExtendsAbstractBundle(): void
{
$bundle = new CalendarBundle();

self::assertInstanceOf(AbstractBundle::class, $bundle);
}

public function testBundleLoadExtension(): void
{
$bundle = new CalendarBundle();
$container = new ContainerBuilder();
$bundlePath = \dirname(__DIR__, 2) . '/src';

$locator = new FileLocator($bundlePath);
$resolver = new \Symfony\Component\Config\Loader\LoaderResolver([
new YamlFileLoader($container, $locator),
new \Symfony\Component\DependencyInjection\Loader\PhpFileLoader($container, $locator),
]);
$loader = new \Symfony\Component\DependencyInjection\Loader\PhpFileLoader($container, $locator);
$loader->setResolver($resolver);
$instanceOf = [];

$configurator = new ContainerConfigurator($container, $loader, $instanceOf, $bundlePath, 'calendar_test');

$bundle->loadExtension([], $configurator, $container);

self::assertTrue($container->hasDefinition(Serializer::class));
self::assertTrue($container->hasDefinition(CalendarController::class));
}
}
35 changes: 0 additions & 35 deletions tests/DependencyInjection/CalendarExtensionTest.php

This file was deleted.

Loading