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

Inject connections into constructor instead of using a method #69

Closed

Conversation

odolbeau
Copy link
Member

There is no reason to use a addConnection instead of pass them directly to the constructor.

@mfpierre
Copy link

It also exposes the clients through the container 👍

* {@inheritDoc}
*/
public function addConnection($name, array $connection)
public function __construct(array $connections = [])

Choose a reason for hiding this comment

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

Phpdoc on the constructor ?

@odolbeau odolbeau closed this Oct 15, 2015
}
$container->setParameter('swarrot.connections', $connections);
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, you should replace the argument instead of adding a parameter for that

Copy link
Member Author

Choose a reason for hiding this comment

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

I closed this PR without merging it.
In fact, I needed this connections list to be able to reuse them in another bundle that's why I wished I had this parameter. :)

PR #67 solved my problem as it already expose a parameter containing the connection list.

Copy link
Contributor

Choose a reason for hiding this comment

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

well, removing the mutator from the interface still makes sense to me

@odolbeau odolbeau deleted the constructor-instead-of-method branch October 19, 2015 08:09
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