public function getProvider( MShop_Coupon_Item_Interface $item, $code )
	{
		$names = explode( ',', $item->getProvider() );

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

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

		$interface = 'MShop_Coupon_Provider_Factory_Interface';
		$classname = 'MShop_Coupon_Provider_' . $providername;

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

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

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

		$decorators = $context->getConfig()->get( 'mshop/coupon/provider/decorators', array() );

		$object = $this->_addCouponDecorators( $item, $code, $provider, $names );
		$object = $this->_addCouponDecorators( $item, $code, $object, $decorators );
		$object->setObject( $object );

		return $object;
	}
public function getProvider( MShop_Coupon_Item_Interface $item, $code )
	{
		$names = explode( ',', $item->getProvider() );

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

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

		$interface = 'MShop_Coupon_Provider_Factory_Interface';
		$classname = 'MShop_Coupon_Provider_' . $providername;

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

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

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

		$decorators = $context->getConfig()->get( 'mshop/coupon/provider/decorators', array() );

		$object = $this->_addCouponDecorators( $item, $code, $provider, $names );
		$object = $this->_addCouponDecorators( $item, $code, $object, $decorators );
		$object->setObject( $object );

		return $object;
	}
public function getProvider ( MShop_Coupon_Item_Interface $ item , $ code ) { $ names = explode ( ',' , $ item -> getProvider ( ) ) ; if ( ( $ providername = array_shift ( $ names ) ) === null ) { throw new MShop_Coupon_Exception ( sprintf ( 'Provider in "%1$s" not available' , $ item -> getProvider ( ) ) ) ; } if ( ctype_alnum ( $ providername ) === false ) { throw new MShop_Coupon_Exception ( sprintf ( 'Invalid characters in provider name "%1$s"' , $ providername ) ) ; } $ interface = 'MShop_Coupon_Provider_Factory_Interface' ; $ classname = 'MShop_Coupon_Provider_' . $ providername ; if ( class_exists ( $ classname ) === false ) { throw new MShop_Coupon_Exception ( sprintf ( 'Class "%1$s" not available' , $ classname ) ) ; } $ context = $ this -> _getContext ( ) ; $ provider = new $ classname ( $ context , $ item , $ code ) ; if ( ( $ provider instanceof $ interface ) === false ) { $ msg = sprintf ( 'Class "%1$s" does not implement interface "%2$s"' , $ classname , $ interface ) ; throw new MShop_Coupon_Exception ( $ msg ) ; } $ decorators = $ context -> getConfig ( ) -> get ( 'mshop/coupon/provider/decorators' , array ( ) ) ; $ object = $ this -> _addCouponDecorators ( $ item , $ code , $ provider , $ names ) ; $ object = $ this -> _addCouponDecorators ( $ item , $ code , $ object , $ decorators ) ; $ object -> setObject ( $ object ) ; return $ object ; }
Returns the coupon model which belongs to the given code.

@param MShop_Coupon_Item_Interface $item Coupon item interface
@return MShop_Coupon_Provider_Interface Returns a coupon provider instance
@throws MShop_Coupon_Exception If coupon couldn't be found
Returns the coupon model which belongs to the given code .