⚡ valuein/invoice:6.0

⚡ valuein/invoice:6.01 🎉4 🔥

  • 🎉 Migrated to symfony 6
  • 🔥 Changed loading of local bundles configs
  • 🔥 Changed path of security_main.yml
  • 🔥 Changed Switchable interface
  • 🔥 Changed migration namespace discovery interface

🔥 Breaking changes

Changed loading of local bundles configs

In the previous version, a mechanism was in place to load automatically the files :

  • src/Local/*Bundle/Resources/config/services_main.{yml|php}
  • src/Local/*Bundle/Resources/config/parameters_main.{yml|php}
  • src/Local/*Bundle/Resources/config/services.{yml|php}
  • src/Local/*Bundle/Resources/config/security.{yml|php}
  • src/Local/*Bundle/Resources/config/parameters.{yml|php}
  • src/Local/*Bundle/Resources/config/email-contexts.yml
  • src/Local/*Bundle/Resources/config/matrix-config.yml

This system have been removed and now the loading of these files must be done explicitly by the bundle by creating an extension.

If the bundle only declare services, then the following extension can be used as a template :

php
<?php

namespace Local\TestBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

class TestExtension extends Extension
{

    public function load(array $configs, ContainerBuilder $container)
    {
        // Load the services required by this bundle
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
        $loader->load("services.yml");
    }
}

If the bundle change the configuration of other bundles (for example change twig default date format) and the priority is important, then the following extension should be used as a template :

NOTE: This version is provided only as an helper to migrate and should not be used on the long term
php
<?php

namespace Local\TestBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Yaml\Yaml;

class TestExtension extends Extension implements PrependExtensionInterface
{

    public function load(array $configs, ContainerBuilder $container)
    {
        // No operation
    }

    public function prepend(ContainerBuilder $container)
    {
        // NOTE: This version is provided only as an helper to migrate and should not be used on the long term
        // Prepend the config of other bundle or set parameters
        $content = Yaml::parseFile(__DIR__ . '/../Resources/config/services.yml');
        foreach ($content['parameters'] as $key => $value) {
            $container->setParameter($key, $value);
        }
        unset($content['imports'], $content['parameters'], $content['services']);
        foreach ($content as $package => $config) {
            $container->prependExtensionConfig($package, $config);
        }

        // Append the config of other bundle or set parameters
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
        $loader->load("services.yml");
    }
}

If the bundle change the configuration of other bundles (for example register a twig path) and the priority is not important, then the following extension should be used as a template :

php
<?php

namespace Local\TestBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Yaml\Yaml;

class TestExtension extends Extension implements PrependExtensionInterface
{

    public function load(array $configs, ContainerBuilder $container)
    {
        // No operation
    }

    public function prepend(ContainerBuilder $container)
    {
        // NOTE: This version is provided only as an helper to migrate and should not be used on the long term
        // Append the config of other bundle or set parameters
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
        $loader->load("services.yml");
    }
}

Changed path of security_main.yml

Previously, the project was scanning for the file security.yml at one of these locations :

  • src/Local/*Bundle/Resources/config/security_main.{yml|php}

Now, the file is scanned at one of these locations :

  • src/Local/*Bundle/Resources/config/security.{yaml|yml|php|xml}

Changed Switchable interface

The method isEnabled(string $env) have been removed, instead the method getBundles(): array have been added.
Before the bundle was expected to declare if he was enabled or not. Now it must return the list of bundle that it manage, as if it was in the bundles.php file : [ App\App::class => ['all' => true] ]

The method getDependency have also been removed, since it's now part of the getBundles method.

Changed migration namespace discovery interface

Previously, the migrations namespaces were discovered automatically.
Any migration in the folder src/Local/*Bundle/DoctrineMigrations/$Year/$Month was registering the namespace.

For example :

  • File : src/Local/PlanhatBundle/DoctrineMigrations/2023/07/Version20230705151550.php
  • Namespace : Local\PlanhatBundle\DoctrineMigrations

In this version, the namespace need to be manually registered by adding a dependency injection extension.
This extension must have a prepend method loading a yml file.

This yml must have a content similar to :

doctrine_migrations:
    migrations_paths:
        'Local\???Bundle\DoctrineMigrations': '%kernel.project_dir%/src/Local/???Bundle/DoctrineMigrations'

For example :

doctrine_migrations:
    migrations_paths:
        'Local\PlanhatBundle\DoctrineMigrations': '%kernel.project_dir%/src/Local/PlanhatBundle/DoctrineMigrations'
Written by julien.tattevin on Jan 10 2024, 9:00 AM.
Executive
Projects
None
Subscribers
None

Event Timeline