Sets a service.

@param string $id      The service identifier
@param object $service The service instance

@throws BadMethodCallException When this ContainerBuilder is frozen
437687
public function set($id, $service)
    {
        $id = strtolower($id);

        if ($this->isFrozen() && (isset($this->definitions[$id]) && !$this->definitions[$id]->isSynthetic())) {
            // setting a synthetic service on a frozen container is alright
            throw new BadMethodCallException(sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a frozen container is not allowed.', $id));
        }

        unset($this->definitions[$id], $this->aliasDefinitions[$id]);

        parent::set($id, $service);
    }
1148517
public function setService(\Flowcode\ShopBundle\Entity\Service $service = null)
    {
        $this->service = $service;

        return $this;
    }
352844
final public function set(string $id, string $class = null): ServiceConfigurator
    {
        $this->__destruct();

        return $this->parent->set($id, $class);
    }
1051375
public function setId($id)
    {
        $context = $this->_context;

        if (!$context->started) {
            $this->_start();
        }

        $context->session_id = $id;
    }
631887
public function setService($key, $service)
    {
        $this->set($key, $service);
        unset($this->instanceCache[$key]);
        return $this;
    }
25088
public function setService($name, $object)
    {
        if (isset($this->services[$name])) {
            throw new \InvalidArgumentException(sprintf(
                '%s service "%s" already exists.',
                $this->serviceType,
                $name
            ));
        }

        $this->services[$name] = $object;
    }
555774
protected function initService($id, array $args = null) {
		$method = sprintf($this->methodNameTemplate, lcfirst($id));
		
		if (! method_exists($this, $method)) {
			throw new Exceptions\ServiceNotFound('Unable to found the service "' . $id . '"');
		}
		
		if ($args === null) {
			return $this->$method();
		}
		
		return call_user_func_array([$this, $method], $args);
	}
177788
public function setId($id)
    {
        $this->id = (string)$id;

        if (!$this->isIdValid($this->id)) {
            throw new InvalidIdException($this);
        }

        return $this;
    }
888783
function set(iContainerService $service)
    {
        $name  = $service->getName();
        if ($name !== null && $this->has($name) && !$this->_attainCService($name)->isAllowOverride())
            throw new \Exception(
                "A service by the name or alias ({$name}) already exists and cannot be overridden;"
            );

        $this->_storeCService($name, $service);
        return $this;
    }
949701
public function add($id, $service, $replace = false)
    {
        if ($this->has($id) == true && $replace == false) {           
            throw new ServiceExistsException($id);
        }
        $this->services[$id] = $service;
    }
431898
public function setDefinition($id, Definition $definition)
    {
        if ($this->isCompiled()) {
            throw new BadMethodCallException('Adding definition to a compiled container is not allowed');
        }

        $id = $this->normalizeId($id);

        unset($this->aliasDefinitions[$id], $this->removedIds[$id]);

        return $this->definitions[$id] = $definition;
    }
1150969
public function addRunnerService($name, $id, array $options = array())
    {
        if (!$this->container->has($id)) {
            throw new InvalidArgumentException("Service container does not have required service registered.");
        }
        $this->runnerServices[$name] = array(
            'id' => $id,
            'options' => $options,
        );
    }
829769
public final void setServicePid(String servicePid) {
        synchronized (lock) {
            if (servicePid == null) {
                serviceProperties.remove(SERVICE_PID);
            } else {
                serviceProperties.put(SERVICE_PID, servicePid);
            }

            if (serviceRegistration != null) {
                serviceRegistration.setProperties(serviceProperties);
            }
        }
    }
213390
private function createServiceConfig($id, array $service)
    {
        $serviceConfig = new ServiceConfig($service);

        if (!$serviceConfig->has($tag = ServiceConfig::FIND_TAG)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Service "%s" must define at least the "%s" attribute for tag "%s".',
                    $id,
                    $tag,
                    $this->baseTag
                )
            );
        }

        return $serviceConfig;
    }
135974
private function set($type, $id)
    {
        if (isset($this->definedTypes[$type])) {
            return;
        }

        // is this already a type/class that is known to match multiple services?
        if (isset($this->ambiguousServiceTypes[$type])) {
            $this->ambiguousServiceTypes[$type][] = $id;

            return;
        }

        // check to make sure the type doesn't match multiple services
        if (!isset($this->types[$type]) || $this->types[$type] === $id) {
            $this->types[$type] = $id;

            return;
        }

        // keep an array of all services matching this type
        if (!isset($this->ambiguousServiceTypes[$type])) {
            $this->ambiguousServiceTypes[$type] = array($this->types[$type]);
            unset($this->types[$type]);
        }
        $this->ambiguousServiceTypes[$type][] = $id;
    }
141176
public function enableService($id)
	{
	    if(!isset($this->services[$id])){
	        throw new Exception\ServiceNotFoundException(
                sprintf('Service ID "%s" does not exist', $id)
	        );
	    }
	    
	    if (!isset($this->services[$id]['listener'])) {
	        $this->services[$id]['listener'] = $this->getCommandManager()->attach(
                $this->services[$id]['name'], $id, $this->services[$id]['priority']);
	        
	        return true;
	    } else {
	        return false;
	    }
	}
262994
public function offsetSet($key, $service)
    {
        if ( ! is_callable($service)) {
            throw new BindingResolutionException("Service definition [{$service}] is not an instance of Closure");
        }

        $this->bind($key, $service);
    }