private $class;
private $file;
private $factory;
- private $factoryClass;
- private $factoryMethod;
- private $factoryService;
private $shared = true;
private $deprecated = false;
private $deprecationTemplate;
- private $scope = ContainerInterface::SCOPE_CONTAINER;
private $properties = array();
private $calls = array();
private $configurator;
private $public = true;
private $synthetic = false;
private $abstract = false;
- private $synchronized = false;
private $lazy = false;
private $decoratedService;
private $autowired = false;
return $this->factory;
}
- /**
- * Sets the name of the class that acts as a factory using the factory method,
- * which will be invoked statically.
- *
- * @param string $factoryClass The factory class name
- *
- * @return $this
- *
- * @deprecated since version 2.6, to be removed in 3.0.
- */
- public function setFactoryClass($factoryClass)
- {
- @trigger_error(sprintf('%s(%s) is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead.', __METHOD__, $factoryClass), E_USER_DEPRECATED);
-
- $this->factoryClass = $factoryClass;
-
- return $this;
- }
-
- /**
- * Gets the factory class.
- *
- * @return string|null The factory class name
- *
- * @deprecated since version 2.6, to be removed in 3.0.
- */
- public function getFactoryClass($triggerDeprecationError = true)
- {
- if ($triggerDeprecationError) {
- @trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0.', E_USER_DEPRECATED);
- }
-
- return $this->factoryClass;
- }
-
- /**
- * Sets the factory method able to create an instance of this class.
- *
- * @param string $factoryMethod The factory method name
- *
- * @return $this
- *
- * @deprecated since version 2.6, to be removed in 3.0.
- */
- public function setFactoryMethod($factoryMethod)
- {
- @trigger_error(sprintf('%s(%s) is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead.', __METHOD__, $factoryMethod), E_USER_DEPRECATED);
-
- $this->factoryMethod = $factoryMethod;
-
- return $this;
- }
-
/**
* Sets the service that this service is decorating.
*
public function setDecoratedService($id, $renamedId = null, $priority = 0)
{
if ($renamedId && $id == $renamedId) {
- throw new \InvalidArgumentException(sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id));
+ throw new InvalidArgumentException(sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id));
}
if (null === $id) {
return $this->decoratedService;
}
- /**
- * Gets the factory method.
- *
- * @return string|null The factory method name
- *
- * @deprecated since version 2.6, to be removed in 3.0.
- */
- public function getFactoryMethod($triggerDeprecationError = true)
- {
- if ($triggerDeprecationError) {
- @trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0.', E_USER_DEPRECATED);
- }
-
- return $this->factoryMethod;
- }
-
- /**
- * Sets the name of the service that acts as a factory using the factory method.
- *
- * @param string $factoryService The factory service id
- *
- * @return $this
- *
- * @deprecated since version 2.6, to be removed in 3.0.
- */
- public function setFactoryService($factoryService, $triggerDeprecationError = true)
- {
- if ($triggerDeprecationError) {
- @trigger_error(sprintf('%s(%s) is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead.', __METHOD__, $factoryService), E_USER_DEPRECATED);
- }
-
- $this->factoryService = $factoryService;
-
- return $this;
- }
-
- /**
- * Gets the factory service id.
- *
- * @return string|null The factory service id
- *
- * @deprecated since version 2.6, to be removed in 3.0.
- */
- public function getFactoryService($triggerDeprecationError = true)
- {
- if ($triggerDeprecationError) {
- @trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0.', E_USER_DEPRECATED);
- }
-
- return $this->factoryService;
- }
-
/**
* Sets the service class.
*
return $this->shared;
}
- /**
- * Sets the scope of the service.
- *
- * @param string $scope Whether the service must be shared or not
- *
- * @return $this
- *
- * @deprecated since version 2.8, to be removed in 3.0.
- */
- public function setScope($scope, $triggerDeprecationError = true)
- {
- if ($triggerDeprecationError) {
- @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
- }
-
- if (ContainerInterface::SCOPE_PROTOTYPE === $scope) {
- $this->setShared(false);
- }
-
- $this->scope = $scope;
-
- return $this;
- }
-
- /**
- * Returns the scope of the service.
- *
- * @return string
- *
- * @deprecated since version 2.8, to be removed in 3.0.
- */
- public function getScope($triggerDeprecationError = true)
- {
- if ($triggerDeprecationError) {
- @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
- }
-
- return $this->scope;
- }
-
/**
* Sets the visibility of this service.
*
return $this->public;
}
- /**
- * Sets the synchronized flag of this service.
- *
- * @param bool $boolean
- *
- * @return $this
- *
- * @deprecated since version 2.7, will be removed in 3.0.
- */
- public function setSynchronized($boolean, $triggerDeprecationError = true)
- {
- if ($triggerDeprecationError) {
- @trigger_error('The '.__METHOD__.' method is deprecated since version 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
- }
-
- $this->synchronized = (bool) $boolean;
-
- return $this;
- }
-
- /**
- * Whether this service is synchronized.
- *
- * @return bool
- *
- * @deprecated since version 2.7, will be removed in 3.0.
- */
- public function isSynchronized($triggerDeprecationError = true)
- {
- if ($triggerDeprecationError) {
- @trigger_error('The '.__METHOD__.' method is deprecated since version 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
- }
-
- return $this->synchronized;
- }
-
/**
* Sets the lazy flag of this service.
*
/**
* Sets a configurator to call after the service is fully initialized.
*
- * @param callable $callable A PHP callable
+ * @param string|array $configurator A PHP callable
*
* @return $this
*/
- public function setConfigurator($callable)
+ public function setConfigurator($configurator)
{
- $this->configurator = $callable;
+ if (is_string($configurator) && strpos($configurator, '::') !== false) {
+ $configurator = explode('::', $configurator, 2);
+ }
+
+ $this->configurator = $configurator;
return $this;
}