public function attach($serviceClassName, array $options = [])
    {
        if (true === isset($this->service[$serviceClassName])) {
            throw new DuplicateEntryException(
                'The service "' . $serviceClassName . '" was already attached to the service factory.',
                1456418859
            );
        }

        $this->currentService = $serviceClassName;
        $this->service[$serviceClassName] = [
            'className' => $serviceClassName,
            'options'   => $options
        ];

        return $this;
    }
public function attach($serviceClassName, array $options = [])
    {
        if (true === isset($this->service[$serviceClassName])) {
            throw new DuplicateEntryException(
                'The service "' . $serviceClassName . '" was already attached to the service factory.',
                1456418859
            );
        }

        $this->currentService = $serviceClassName;
        $this->service[$serviceClassName] = [
            'className' => $serviceClassName,
            'options'   => $options
        ];

        return $this;
    }
public function attach ( $ serviceClassName , array $ options = [ ] ) { if ( true === isset ( $ this -> service [ $ serviceClassName ] ) ) { throw new DuplicateEntryException ( 'The service "' . $ serviceClassName . '" was already attached to the service factory.' , 1456418859 ) ; } $ this -> currentService = $ serviceClassName ; $ this -> service [ $ serviceClassName ] = [ 'className' => $ serviceClassName , 'options' => $ options ] ; return $ this ; }
Will attach a service to this factory.

It will also reset the current service value to the given service,
allowing the usage of the function `setOption` with this service.

@param string $serviceClassName The class name of the service which will be attached.
@param array  $options          Array of options which will be sent to the service.
@return $this
@throws DuplicateEntryException
Will attach a service to this factory .