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

Add DI support for twill Block getData method #2292

Merged
merged 5 commits into from
Feb 4, 2024
Merged

Add DI support for twill Block getData method #2292

merged 5 commits into from
Feb 4, 2024

Conversation

Afting
Copy link
Contributor

@Afting Afting commented Jun 15, 2023

Hello, I have been trying to use Twill Block, and extend it like it's documented in https://twillcms.com/docs/block-editor/rendering-blocks.html#content-modifying-block-data, though no method supports DI. This change would allow to use DI in getData() method.
Regarding the changes Laravel itself likes to do things like that, ex. https://github.com/laravel/framework/blob/10.x/src/Illuminate/Mail/Mailable.php#L1612-L1614

Also had a discussion on Discord to create this PR

@CLAassistant
Copy link

CLAassistant commented Jun 15, 2023

CLA assistant check
All committers have signed the CLA.

@Afting Afting closed this Jun 15, 2023
@Afting Afting reopened this Jun 15, 2023
@ifox
Copy link
Member

ifox commented Jan 25, 2024

Hi @Afting I was about to merge this but I'm concerned about the example provided in the docs needing a correction if we remove the getData method implementation in the Block parent class:

public function getData(array $data, \A17\Twill\Models\Block $block): array
{
    $data = parent::getData($data, $block);
    // ...
}

parent::getData() wouldn't work anymore, and it is almost certain that developers using this feature are currently using it by pasting the example from the docs. Can we keep it while benefiting from DI in the method override?

@ifox ifox merged commit 5073e74 into area17:3.x Feb 4, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants