コード例 #1
0
<?php
require_once '../application/config.php';
require_once 'com/paypal/example/model/DigitalGallery.php';
require_once 'com/paypal/example/view/HomeView.php';
require_once 'com/paypal/example/view/CartView.php';

$digitalGallery = DigitalGallery::getInstance();
$action = isset( $_GET[ 'action' ] ) ? $_GET[ 'action' ] : 'home';
$view = null;
$user = '******';
$pswd = 'senha';
$signature = 'assinatura';

switch ( $action ) {
	case 'buy':
		if ( isset( $_GET[ 'idDigitalArt' ] ) && is_numeric( $_GET[ 'idDigitalArt' ] ) ) {
			$art = $digitalGallery->getDigitalArt( (int) $_GET[ 'idDigitalArt' ] );
			$cart = $digitalGallery->cart();

			if ( isset( $_GET[ 'remove' ] ) ) {
				$cart->remove( $art );
			} else {
				$cart->add( $art );
			}

			$view = new CartView( $cart->getIterator() );
			break;
		} else {
			throw new InvalidArgumentException( 'Requisição inválida' );
		}
	case 'cart' :
コード例 #2
0
	/**
	 * Recupera a instância de DigitalGallery
	 * @return	DigitalGallery
	 */
	public static function getInstance() {
		if ( self::$instance == null ) {
			self::$instance = new DigitalGallery();
		}

		return self::$instance;
	}
コード例 #3
0
	/**
	 * Recupera a instância da galeria.
	 * @return	DigitalGallery
	 */
	public function getDigitalGallery() {
		return DigitalGallery::getInstance();
	}