⚡ valuein/shop:5.10

⚡ valuein/shop:5.102 🎉3 🚀2 🔥

  • 🎉 Added Stripe payment methods to Salesforce Subscription Management
  • 🎉 Added Stripe to Valuein Invoice Engine payment methods
  • 🚀 Improved PHP version
  • 🚀 Improved pdf generation
  • 🚀 Improved code management using rector
  • 🔥 Changed dependency to pdf generator
  • 🔥 Changed declaration of sonata admin classes

🎉 New features

Added Stripe payment methods to Salesforce Subscription Management

Stripe payment methods can now be used with Salesforce Subscription Management.
This feature require a Salesforce package to work fully

On the administration page, we can choose if we enable or not Stripe, by default it is not enabled.

You can also choose for customer and sales-rep which payments methods are allowed.

🚀 Improvements

Improved code management using rector

A rector file have been added to the project.
This file allow for quick refactoring of class and automated upgrade of the framework or the language.

NOTE: While this tools is quite stable, the change must be checked before being applied.

The current official set list is the following :

  • SetList::CODE_QUALITY
  • SetList::DEAD_CODE
  • SetList::EARLY_RETURN
  • LevelSetList::UP_TO_PHP_83
  • SymfonySetList::SYMFONY_40
  • SymfonySetList::SYMFONY_41
  • SymfonySetList::SYMFONY_42
  • SymfonySetList::SYMFONY_43
  • SymfonySetList::SYMFONY_44
  • SymfonySetList::SYMFONY_50
  • SymfonySetList::SYMFONY_51
  • SymfonySetList::SYMFONY_52
  • SymfonySetList::SYMFONY_53
  • SymfonySetList::SYMFONY_54
  • SymfonySetList::SYMFONY_CODE_QUALITY
  • SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION

The current custom rule is the following :

  • SonataAdminTagRector::class : Replace sonata admin constructor by Symfony tag

For various reason, the following rules are excluded :

  • From CodeQuality
    • Array_\CallableThisArrayToAnonymousFunctionRector
    • Identical\FlipTypeControlToUseExclusiveTypeRector
    • FuncCall\CountArrayToEmptyArrayComparisonRector
  • From DEAD_CODE
    • ClassMethod\RemoveUselessParamTagRector
    • ClassMethod\RemoveUselessReturnTagRector
  • From EARLY_RETURN
    • Return_\PreparedValueToEarlyReturnRector
  • From PHP_74
    • Closure\ClosureToArrowFunctionRector
    • Assign\NullCoalescingOperatorRector
  • From PHP_80
    • Class_\ClassPropertyAssignToConstructorPromotionRector
    • FunctionLike\MixedTypeRector
    • Switch_\ChangeSwitchToMatchRector
  • From PHP_81
    • ClassConst\FinalizePublicClassConstantRector
    • Property\ReadOnlyPropertyRector
  • From PHP_83
    • ClassConst\AddTypeToConstRector
  • From SYMFONY_CODE_QUALITY
    • ClassMethod\ActionSuffixRemoverRector
    • Class_\EventListenerToEventSubscriberRector
    • ClassMethod\AddParamTypeDeclarationRector

🔥 Breaking changes

Changed dependency to pdf generator

With the new version of alpine (3.19) used to have php 8.3, and the discontinuation of wkhtmltopdf development, a new solution was required.
This new solution is to use directly chrome as a render engine.

For the end user, the change should not be visible as the rendering engine is still the same (webkit).

For the deployment, a new container running alonside the web container is required :

yaml
version: '3'
services:
    pdfRenderer:
        image: registry.valuein.app/valuein/pdf-renderer:v1
        labels:
            - "fr.z-keys.port-to-wait=5017"

The shop now also require a new environment variable to specify which service should be used for rendering pdf :

yaml
version: '3'
services:
    web:
        environment:
            - PDF_RENDERER_URL=http://pdfRenderer:5017

Changed declaration of sonata admin classes

Currently, the declaration of sonata admin is done using constants on the class itself :

php
class ProductRatePlanConfigurationAdmin extends AbstractAdmin
{
    public const ADMIN_CODE         = 'salesforce_invoice_engine.product_rate_plan_definition';
    public const ADMIN_ENTITY_CLASS = ProductRatePlanDefinition::class;
    public const ADMIN_GROUP        = 'Billing';
    public const ADMIN_LABEL        = 'Invoice Engine Catalog';

    private RouterInterface $router;

    /**
     * @param string               $code
     * @param class-string<object> $class
     * @param string               $crud
     * @param RouterInterface      $router
     */
    public function __construct(
        string $code,
        string $class,
        string $crud,
        RouterInterface $router
    ) {
        parent::__construct($code, $class, $crud);

        $this->router = $router;
    }
    // ...
}

With recent version of sonata admin, this method is deprecated and replaced by the sonata.admin tag which must be added to the class.

This mean that we need to :

  • Remove the constant
  • Remove the $code, $class and $crud parameter from the __construct function
  • Remove the $code, $class and $crud parameter from the __construct call to the parent class
  • Add an AutoconfigureTag attribute with the name sonata.admin to the class

For example :

php

#[AutoconfigureTag('sonata.admin', ['code' => 'salesforce_invoice_engine.product_rate_plan_definition', 'model_class' => ProductRatePlanDefinition::class, 'group' => 'Billing', 'label' => 'Invoice Engine Catalog', 'manager_type' => 'orm'])]
class ProductRatePlanConfigurationAdmin extends AbstractAdmin
{

    private RouterInterface $router;

    /**
     * @param RouterInterface $router
     */
    public function __construct(
        RouterInterface $router
    ) {
        parent::__construct();

        $this->router = $router;
    }
    // ...
}

The mapping between the constant and the class is the following :

Constant nameTag attribute
ADMIN_CODEcode
ADMIN_ENTITY_CLASSmodel_class
ADMIN_CRUD_CONTROLLERcontroller
ADMIN_LABELlabel
ADMIN_GROUPgroup
ADMIN_SHOW_IN_DASHBOARDshow_in_dashboard
ADMIN_IS_DEFAULTdefault
Written by julien.tattevin on Mar 14 2024, 12:07 PM.
Executive
Projects
None
Subscribers
None

Event Timeline