Skip to content

[DependencyInjection] Add documentation about service decoration#3753

Closed
romainneutron wants to merge 1 commit intosymfony:masterfrom
romainneutron:service-decoration
Closed

[DependencyInjection] Add documentation about service decoration#3753
romainneutron wants to merge 1 commit intosymfony:masterfrom
romainneutron:service-decoration

Conversation

@romainneutron
Copy link
Copy Markdown
Contributor

Q A
Doc fix? yes
New docs? yes (symfony/symfony#10600)
Applies to 2.5+
Fixed tickets #3745

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Decorating Services

@romainneutron
Copy link
Copy Markdown
Contributor Author

PR updated. @stof I've not addressed your comment #3753 (comment) yet. I don't really get what you mean

@wouterj
Copy link
Copy Markdown
Member

wouterj commented Apr 3, 2014

@romainneutron you say "You can change the parent service name if you want to:" in the line from @stof's comment, it should be "inner service name" instead of "parent service name"

@romainneutron
Copy link
Copy Markdown
Contributor Author

@wouterj It has already been fixed ^^

@stof
Copy link
Copy Markdown
Member

stof commented Apr 3, 2014

You sentence reads as follow:

By convention, the old foo service is going to be renamed foo1.inner

When reading this, people could think that the conventional id foo1.inner is related to the id foo mentionned in the same sentence just before, while it has nothing to do with it (if the old service was named acme_demo.hello_greater, the conventional name would still be foo1.inner). The convention for the generated inner id (foo1.inner) is based on the id of the decorator service (foo1 here), not of the decorated service (foo here). This is mandatory to allow several decorators on the same service (they need to have different generated inner ids).

@stof
Copy link
Copy Markdown
Member

stof commented Apr 3, 2014

I would add a note that most of the time, the decorator service should be declared private, as you will not need to retrieve it as foo1 from the container. The visibility of the decorated foo service (whch is an alias for foo1) will still be the same than the original foo visibility.

If the original service is public, this will not have much impact (the runtime access of aliases has been optimized in Symfony 2.4 already so there won't be any overhead if both foo and foo1 are kept public). but if the original service was private, a public foo1 in the call chain will prevent inlining calls to foo (they will still be rewritten to calls to foo1, but not inlined further).

I don't have any use case in mind where you will want your decorator service to have a public id.

@romainneutron
Copy link
Copy Markdown
Contributor Author

@stof thanks for clarification, I've added a note about what you explained in #3753 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and replace it with ...

@romainneutron
Copy link
Copy Markdown
Contributor Author

PR has been updated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ist this necessary for this example? We don't have it in either the YAML or XML configuration.

@romainneutron
Copy link
Copy Markdown
Contributor Author

PR updated, I've fixed code examples

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you should use double quotes for consistency. And there should be no spaces inside [], only inside {}

@romainneutron
Copy link
Copy Markdown
Contributor Author

PR updated

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.

7 participants