sonata-project / SonataBlockBundle

Symfony SonataBlockBundle
https://docs.sonata-project.org/projects/SonataBlockBundle
MIT License
413 stars 142 forks source link

Upgrade block-bundle to 4.x in sonata-project bundles #700

Closed wbloszyk closed 4 years ago

wbloszyk commented 4 years ago

Feature Request

After watching some issue with Blocks (https://github.com/sonata-project/SonataMediaBundle/pull/1737, https://github.com/sonata-project/SonataMediaBundle/pull/1732) I came up with an idea.

All sonata-project stable bundles(Sonata 3) using block-bundle 3.x but 4.x is released.

block-bundle 4.0 upgrade change:

  1. block constructor
  2. AbstractAdminBlockService/AdminBlockServiceInterface to EditableBlockService
  3. Return type hints
  4. Conflict with CoreBundle

Resolve something like: (I will add example son - PR for SonataNewsBundle)

  1. https://github.com/sonata-project/SonataClassificationBundle/pull/488
  2. some steps needed
    • remove AbstractAdminBlockService/AdminBlockServiceInterface implementations
    • add methods from AbstractAdminBlockService
    • add methods from EditableBlockServce
    • methods from EditableBlockServie should not call Abstra... methods and vice versa
    • some check for override methods should be add
  3. I will describe it below
  4. Resolve conflict with CoreBundle

Return type hints return type hints

  1. move Block directory to Model/Block
  2. Create the same Class in Block like in example:

    if (`SonataBlockBundle3`) {
    class SomeBlockService Extends Modal/Block/SomeBlockServie {}  
    } elseif (`SonataBlockBundle4`) {
    // extends the came thing like Modal/Block/SomeBlockServie
    // we can add `EditableBlockService` becouse user make block-bundle MAJOR UPDATE
    class SomeBlockService Extends AbstractBlockService implements EditableBlockService
    {
        /**
        * var Modal/Block/SomeBlockServie
        */
        private $blockService;
    
        public function __construct($env, $someService)
        {
              $this->blockService = new Modal/Block/SomeBlockServie($env, $someService),
        }
    
        // add return type hints 
        public function configureSettings(OptionsResolver $resolver): void
        {
              $this->blockService->configureSettings($resolver);
        }
        .... // for all extended methods
    }  
    }

    Before start - resolve conflict with CoreBundle:

TODO:

jorrit commented 4 years ago

I think before ' add support for extensions 0.x to block-bundle 4.x to resolve core-bundle conflict' can be implemented, sonata-project/form-extensions needs to support Symfony 5. Otherwise the Symfony 5 compatibility of block-bundle 4.x is undone.

wbloszyk commented 4 years ago

@jorrit CoreBundle is almost dropped in Sonata 3 and should not be support in Sonata 4 (as extensions 0.x). More info here: https://github.com/sonata-project/dev-kit/issues/697

I should update this issue becouse some things are changed.

jorrit commented 4 years ago

If that is the case, is it even a goal to support Symfony 5 in Sonata 3?

wbloszyk commented 4 years ago

The goal for me now is drop all deprecated bundles and make stable sandbox 3.0 based on Symfony4.4 and Sonata 3.

IMHO sonata-project team is more focus on realease AdminBundle 4 now. Anyway I will help if it will be possible.

wbloszyk commented 4 years ago

Close in favor for https://github.com/sonata-project/dev-kit/issues/785