Sets a service.
@api
string $id The service identifier:
object $service The service instance:
string $scope The scope of the service:
Overrides ContainerInterface::set
public function set($id, $service, $scope = self::SCOPE_CONTAINER) {
if (self::SCOPE_PROTOTYPE === $scope) {
throw new InvalidArgumentException('You cannot set services of scope "prototype".');
}
$id = strtolower($id);
if (self::SCOPE_CONTAINER !== $scope) {
if (!isset($this->scopedServices[$scope])) {
throw new RuntimeException('You cannot set services of inactive scopes.');
}
$this->scopedServices[$scope][$id] = $service;
}
$this->services[$id] = $service;
}