Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify that blocks implements EditableBlockService to add/edit them. #1624

Conversation

jordisala1991
Copy link
Member

@jordisala1991 jordisala1991 commented Oct 1, 2022

Subject

I am targeting this branch, because this becomes a problem on 4.x since block bundle splitted interfaces.

Closes #1621

Changelog

### Fixed
- Fix to not show blocks that are not meant to be editable.

@jordisala1991 jordisala1991 changed the base branch from 3.x to 4.x October 1, 2022 07:55
@jordisala1991 jordisala1991 force-pushed the hotfix/allow-only-to-insert-editable-blocks branch 5 times, most recently from f284009 to aa77aeb Compare October 1, 2022 08:22
@jordisala1991 jordisala1991 changed the title Hotfix/allow only to insert editable blocks Verify that blocks implements EditableBlockService to add/edit them. Oct 1, 2022
@jordisala1991
Copy link
Member Author

Needs #1623 first.

@jordisala1991 jordisala1991 mentioned this pull request Oct 2, 2022
36 tasks
@SonataCI
Copy link
Collaborator

SonataCI commented Oct 3, 2022

Could you please rebase your PR and fix merge conflicts?

@jordisala1991 jordisala1991 marked this pull request as ready for review October 4, 2022 08:24
@jordisala1991 jordisala1991 force-pushed the hotfix/allow-only-to-insert-editable-blocks branch from aa77aeb to e662e16 Compare October 6, 2022 06:45
Comment on lines +277 to +283
foreach ($blockServices as $code => $blockService) {
if ($blockService instanceof EditableBlockService) {
continue;
}

unset($blockServices[$code]);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're doing this logic at least twice.

Would it make sens to add/modify a method in BlockServiceManager then ?
If most of the time/always we need to work on EditableBlockService only in PageBundle, it might make sens.

WDYT ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BlockServiceManager is from block-bundle, how could we handle this change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if we should introduce an EditableBlockServiceManager in BlockBundle then.
Or introduce getEditableService and getEditableServiceByContext...

But this solution is currently the only one we have

@jordisala1991
Copy link
Member Author

Should we merge this or wait for another solution? @VincentLanglet ?

@VincentLanglet
Copy link
Member

Should we merge this or wait for another solution? @VincentLanglet ?

I'm ok merging this:

  • This is working
  • This can be easily removed as soon as we have a better solution

The only question would be, would it be useful to provide something in the BlockBundle to avoid this extra code ; if yes we might create a feature request.

@VincentLanglet VincentLanglet merged commit 92ef1e0 into sonata-project:4.x Oct 9, 2022
@haivala
Copy link
Contributor

haivala commented Oct 12, 2022

Check this comment about my thoughts about the implementation: #1621 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants