public function getProvider( MShop_Service_Item_Interface $item )
	{
		$domain = ucwords( $item->getType() );
		$names = explode( ',', $item->getProvider() );

		if ( ctype_alnum( $domain ) === false ) {
			throw new MShop_Service_Exception( sprintf( 'Invalid characters in domain name "%1$s"', $domain ) );
		}

		if( ( $provider = array_shift( $names ) ) === null ) {
			throw new MShop_Service_Exception( sprintf( 'Provider in "%1$s" not available', $item->getProvider() ) );
		}

		if ( ctype_alnum( $provider ) === false ) {
			throw new MShop_Service_Exception( sprintf( 'Invalid characters in provider name "%1$s"', $provider ) );
		}

		$interface = 'MShop_Service_Provider_Factory_Interface';
		$classname = 'MShop_Service_Provider_' . $domain . '_' . $provider;

		if ( class_exists( $classname ) === false ) {
			throw new MShop_Service_Exception(sprintf( 'Class "%1$s" not available', $classname ) );
		}

		$context = $this->_getContext();
		$provider = new $classname( $context, $item );

		if ( ( $provider instanceof $interface ) === false )
		{
			$msg = sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $interface );
			throw new MShop_Service_Exception($msg);
		}

		$config = $context->getConfig();
		$decorators = $config->get( 'mshop/service/provider/' . $item->getType() . '/decorators', array() );

		$provider = $this->_addServiceDecorators( $item, $provider, $names );
		return $this->_addServiceDecorators( $item, $provider, $decorators );
	}
public function getProvider( MShop_Service_Item_Interface $item )
	{
		$domain = ucwords( $item->getType() );
		$names = explode( ',', $item->getProvider() );

		if ( ctype_alnum( $domain ) === false ) {
			throw new MShop_Service_Exception( sprintf( 'Invalid characters in domain name "%1$s"', $domain ) );
		}

		if( ( $provider = array_shift( $names ) ) === null ) {
			throw new MShop_Service_Exception( sprintf( 'Provider in "%1$s" not available', $item->getProvider() ) );
		}

		if ( ctype_alnum( $provider ) === false ) {
			throw new MShop_Service_Exception( sprintf( 'Invalid characters in provider name "%1$s"', $provider ) );
		}

		$interface = 'MShop_Service_Provider_Factory_Interface';
		$classname = 'MShop_Service_Provider_' . $domain . '_' . $provider;

		if ( class_exists( $classname ) === false ) {
			throw new MShop_Service_Exception(sprintf( 'Class "%1$s" not available', $classname ) );
		}

		$context = $this->_getContext();
		$provider = new $classname( $context, $item );

		if ( ( $provider instanceof $interface ) === false )
		{
			$msg = sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $interface );
			throw new MShop_Service_Exception($msg);
		}

		$config = $context->getConfig();
		$decorators = $config->get( 'mshop/service/provider/' . $item->getType() . '/decorators', array() );

		$provider = $this->_addServiceDecorators( $item, $provider, $names );
		return $this->_addServiceDecorators( $item, $provider, $decorators );
	}
public function getProvider ( MShop_Service_Item_Interface $ item ) { $ domain = ucwords ( $ item -> getType ( ) ) ; $ names = explode ( ',' , $ item -> getProvider ( ) ) ; if ( ctype_alnum ( $ domain ) === false ) { throw new MShop_Service_Exception ( sprintf ( 'Invalid characters in domain name "%1$s"' , $ domain ) ) ; } if ( ( $ provider = array_shift ( $ names ) ) === null ) { throw new MShop_Service_Exception ( sprintf ( 'Provider in "%1$s" not available' , $ item -> getProvider ( ) ) ) ; } if ( ctype_alnum ( $ provider ) === false ) { throw new MShop_Service_Exception ( sprintf ( 'Invalid characters in provider name "%1$s"' , $ provider ) ) ; } $ interface = 'MShop_Service_Provider_Factory_Interface' ; $ classname = 'MShop_Service_Provider_' . $ domain . '_' . $ provider ; if ( class_exists ( $ classname ) === false ) { throw new MShop_Service_Exception ( sprintf ( 'Class "%1$s" not available' , $ classname ) ) ; } $ context = $ this -> _getContext ( ) ; $ provider = new $ classname ( $ context , $ item ) ; if ( ( $ provider instanceof $ interface ) === false ) { $ msg = sprintf ( 'Class "%1$s" does not implement interface "%2$s"' , $ classname , $ interface ) ; throw new MShop_Service_Exception ( $ msg ) ; } $ config = $ context -> getConfig ( ) ; $ decorators = $ config -> get ( 'mshop/service/provider/' . $ item -> getType ( ) . '/decorators' , array ( ) ) ; $ provider = $ this -> _addServiceDecorators ( $ item , $ provider , $ names ) ; return $ this -> _addServiceDecorators ( $ item , $ provider , $ decorators ) ; }
Returns the service provider which is responsible for the service item.

@param MShop_Service_Item_Interface $item Delivery or payment service item object
@return MShop_Service_Provider_Interface Returns a service provider implementing MShop_Service_Provider_Interface
@throws MShop_Service_Exception If provider couldn't be found
Returns the service provider which is responsible for the service item .