Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

More clear description of factory service creation#7377

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
hvt wants to merge1 commit intosymfony:masterfromhvt:more-clear-service-factory-example
Closed

More clear description of factory service creation#7377

hvt wants to merge1 commit intosymfony:masterfromhvt:more-clear-service-factory-example

Conversation

@hvt
Copy link
Contributor

@hvthvt commentedJan 17, 2017

I found the service container factory description a bit ambiguous. Especially the two different examples of both static and regular create method usage. Hopefully this clarifies some things.

Eager to know what you guys think...

Copy link
Member

@javiereguiluzjaviereguiluz left a comment

Choose a reason for hiding this comment

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

👍

service too. Later, in the ":ref:`factories-passing-arguments-factory-method`"
section, you learn how you can inject arguments in this method.

Configuration of the service container then looks like this::

Choose a reason for hiding this comment

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

The double colon at the end of this line should be a single colon.

object, by calling the static ``createNewsletterManager()`` method::

classNewsletterManagerFactory
classNewsletterManagerStaticFactory

Choose a reason for hiding this comment

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

This class name looks ugly ... but at the same time it's perfectly understandable. I'm divided about it 😕

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Exactly my thought, I'm happy to change it either way ;].


When using a factory to create services, the value chosen for the ``class``
option has no effect on the resulting service. The actual class name
only depends on the object that is returned by the factory. However,

Choose a reason for hiding this comment

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

About this:

However, the configured class name may be used by compiler passes and therefore should be set to a sensible value.

Should I open a Symfony code issue to improve this behavior and make this class optional?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

(This note was already there, don't know why it is marked as new by the diff.)

I do however believe the note is still valid, because it might be handy to use the class definition somewhere in a compiler pass.

On the other hand, it might be good to check why no active validation is done on the return type of the creation method...


Suppose you have a factory that configures and returns a new ``NewsletterManager``
object::
object, by calling the static ``createNewsletterManager()`` method::
Copy link
Member

Choose a reason for hiding this comment

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

the comma should be removed

factory:['AppBundle\Email\NewsletterManagerStaticFactory',createNewsletterManager]
..code-block::xml
Copy link
Member

Choose a reason for hiding this comment

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

we should add a comment containing the filename like this:

<!-- app/config/services.xml-->

Copy link
Member

Choose a reason for hiding this comment

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

Can you please add this for the other formats too (usingconfig.yml andconfig.php respectively)?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I've done this. Am however wondering whether it's notapp/config/services.yml andapp/config/services.php to be exactly?

Copy link
Member

Choose a reason for hiding this comment

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

Of course, you are absolutely right. Sorry for the confusion.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

No worries ;].

@hvt
Copy link
ContributorAuthor

hvt commentedJan 18, 2017

Fixed everything mentioned.

Shall I squash everything into one commit?

@xabbuh
Copy link
Member

@hvt If you want to, you can do that. Otherwise, we'll do that while merging your PR. :)

@hvt
Copy link
ContributorAuthor

hvt commentedJan 18, 2017

Done :].

@xabbuh
Copy link
Member

Thank you@hvt.

xabbuh added a commit that referenced this pull requestJan 31, 2017
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes#7377).Discussion----------More clear description of factory service creationI found the service container factory description a bit ambiguous. Especially the two different examples of both static and regular create method usage. Hopefully this clarifies some things.Eager to know what you guys think...Commits-------a5f99d8 More clear description of factory service creation
@xabbuhxabbuh closed thisJan 31, 2017
@hvt
Copy link
ContributorAuthor

hvt commentedFeb 1, 2017

@xabbuh, will it be merged into master and all >2.7 branches too?

@xabbuh
Copy link
Member

@hvt Yes, I'll do that later today. Thank you for the heads up.

@hvt
Copy link
ContributorAuthor

hvt commentedAug 9, 2017

Hey@xabbuh , found this in the bottom of my inbox ;].

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@xabbuhxabbuhxabbuh left review comments

@javiereguiluzjaviereguiluzjaviereguiluz approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@hvt@xabbuh@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp