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

Showcase short definition syntax #575

Merged
merged 2 commits into from
May 31, 2017

Conversation

ogizanagi
Copy link
Member

No description provided.


# needed for the localizeddate Twig filter
Twig\Extensions\IntlExtension: ~
Twig\Extensions\IntlExtension: ~ # same as []
Copy link
Contributor

Choose a reason for hiding this comment

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

@ogizanagi, I think it should be same as null

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right. ~ means null using yaml.
But actually, configuring null for a service definition does not mean anything, and is converted to an empty array behind the scene.

I felt like adding this comment would help the user to understand the service definition is either the full mapping of definition's attributes ({ attributes: [...], tags: [...], public: false, ... }) or directly the list (or mapping for named arguments) of constructor parameters.

But maybe that's not necessary.

arguments:
$sender: '%app.notifications.email_sender%'
# The short syntax can also be inlined:
AppBundle\EventListener\CommentNotificationSubscriber: { $sender: '%app.notifications.email_sender%' }
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to be consistent and use the same syntax in the whole app, i.e.:

    AppBundle\EventListener\CommentNotificationSubscriber:
        $sender: '%app.notifications.email_sender%'

You explain the Yaml syntax here, which is not related to the Symfony Demo I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, let's do this. :)

@javiereguiluz
Copy link
Member

@ogizanagi thanks for this! I like it ... and I didn't remember this shortcut syntax, so it's great to re-learn it!

@javiereguiluz javiereguiluz merged commit f857b2f into symfony:master May 31, 2017
javiereguiluz added a commit that referenced this pull request May 31, 2017
This PR was merged into the master branch.

Discussion
----------

Showcase short definition syntax

Commits
-------

f857b2f Tweaked the help note
fcca1cb Showcase short definition syntax
@ogizanagi ogizanagi deleted the short_def_syntax branch May 31, 2017 21:56
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.

None yet

4 participants