-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[WIP][DependencyInjection] Add a new Syntax to define factories as callables. #9839
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
CHANGELOG | ||
========= | ||
|
||
2.6.0 | ||
----- | ||
|
||
* added new factory syntax and deprecated the old one | ||
|
||
2.5.0 | ||
----- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ class Definition | |
{ | ||
private $class; | ||
private $file; | ||
private $factory; | ||
private $factoryClass; | ||
private $factoryMethod; | ||
private $factoryService; | ||
|
@@ -56,6 +57,34 @@ public function __construct($class = null, array $arguments = array()) | |
$this->arguments = $arguments; | ||
} | ||
|
||
/** | ||
* Sets a factory | ||
* | ||
* @param callable $factory The PHP callable to call or an array containing a Reference and a method to call | ||
* | ||
* @return Definition The current instance | ||
* | ||
* @api | ||
*/ | ||
public function setFactory($factory) | ||
{ | ||
$this->factory = $factory; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Gets the factory . | ||
* | ||
* @return callable|array The PHP callable to call or an array containing a Reference and a method to call | ||
* | ||
* @api | ||
*/ | ||
public function getFactory() | ||
{ | ||
return $this->factory; | ||
} | ||
|
||
/** | ||
* Sets the name of the class that acts as a factory using the factory method, | ||
* which will be invoked statically. | ||
|
@@ -65,6 +94,7 @@ public function __construct($class = null, array $arguments = array()) | |
* @return Definition The current instance | ||
* | ||
* @api | ||
* @deprecated Deprecated since version 2.5, to be removed in 3.0. | ||
*/ | ||
public function setFactoryClass($factoryClass) | ||
{ | ||
|
@@ -79,6 +109,7 @@ public function setFactoryClass($factoryClass) | |
* @return string|null The factory class name | ||
* | ||
* @api | ||
* @deprecated Deprecated since version 2.5, to be removed in 3.0. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since version 2.6 |
||
*/ | ||
public function getFactoryClass() | ||
{ | ||
|
@@ -93,6 +124,7 @@ public function getFactoryClass() | |
* @return Definition The current instance | ||
* | ||
* @api | ||
* @deprecated Deprecated since version 2.5, to be removed in 3.0. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since version 2.6 |
||
*/ | ||
public function setFactoryMethod($factoryMethod) | ||
{ | ||
|
@@ -142,6 +174,7 @@ public function getDecoratedService() | |
* @return string|null The factory method name | ||
* | ||
* @api | ||
* @deprecated Deprecated since version 2.5, to be removed in 3.0. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since version 2.6 |
||
*/ | ||
public function getFactoryMethod() | ||
{ | ||
|
@@ -156,6 +189,7 @@ public function getFactoryMethod() | |
* @return Definition The current instance | ||
* | ||
* @api | ||
* @deprecated Deprecated since version 2.5, to be removed in 3.0. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since version 2.6 |
||
*/ | ||
public function setFactoryService($factoryService) | ||
{ | ||
|
@@ -170,6 +204,7 @@ public function setFactoryService($factoryService) | |
* @return string|null The factory service id | ||
* | ||
* @api | ||
* @deprecated Deprecated since version 2.5, to be removed in 3.0. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since version 2.6 |
||
*/ | ||
public function getFactoryService() | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since version 2.6