Skip to content

Supports array in AsBlock->name argument #17

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

Closed
wants to merge 2 commits into from

Conversation

silasjoisten
Copy link
Collaborator

@silasjoisten silasjoisten commented Mar 18, 2025

This pullrequest should allow multiple attributes on one class for example:

use Storyblok\Bundle\Block\Attribute\AsBlock;

#[AsBlock(name: 'youtube_video')]
#[AsBlock(name: 'spotify_embed')]
#[AsBlock(name: 'instagram_embed')]
#[AsBlock(name: 'linkedin_embed')]
final readonly class Embed
{
    public string $url;

    /**
     * @param array<string, mixed> $values
     */
    public function __construct(array $values)
    {
        $this->url = $values['url'];
    }
}

@silasjoisten silasjoisten self-assigned this Mar 18, 2025
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.69%. Comparing base (0eb9f8e) to head (bed8e6f).

Additional details and impacted files
@@            Coverage Diff            @@
##             master      #17   +/-   ##
=========================================
  Coverage     91.69%   91.69%           
  Complexity       70       70           
=========================================
  Files            12       12           
  Lines           313      313           
=========================================
  Hits            287      287           
  Misses           26       26           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@silasjoisten silasjoisten changed the title Allow multiple attributes Allow multiple #[AsBlock] attributes Mar 18, 2025
@silasjoisten silasjoisten changed the title Allow multiple #[AsBlock] attributes Allow multiple #[AsBlock] attributes on a single class Mar 18, 2025
@silasjoisten silasjoisten changed the title Allow multiple #[AsBlock] attributes on a single class Supports array in AsBlock->name argument Mar 18, 2025
@OskarStark
Copy link
Collaborator

OskarStark commented Mar 18, 2025

The attribute itself is already repeatable?

Besides that, what's the reasons behind it? Dan you share a real world example?

@silasjoisten
Copy link
Collaborator Author

See the PR description for a real world example.

@silasjoisten silasjoisten deleted the feature/allow-multiple-attributes branch March 18, 2025 14:56
@silasjoisten
Copy link
Collaborator Author

Symfony does not allow adding the same attribute multiple times. and i think its better to have a dedicated class for each content type event if they share the values.

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