class_PaymentDiscoveryFilter.php

Go to the documentation of this file.
00001 <?php
00026 class PaymentDiscoveryFilter extends BaseFilter implements Filterable {
00030         private $actionName = "";
00031 
00037         protected function __construct () {
00038                 // Call parent constructor
00039                 parent::__construct(__CLASS__);
00040         }
00041 
00049         public final static function createPaymentDiscoveryFilter (PerformableAction $actionInstance) {
00050                 // Get a new instance
00051                 $filterInstance = new PaymentDiscoveryFilter();
00052 
00053                 // Get resolver from action
00054                 $resolverInstance = $actionInstance->getResolverInstance();
00055 
00056                 // Is the resolver set?
00057                 if (is_null($resolverInstance)) {
00058                         // Throw an exception here
00059                         throw new NullPointerException($filterInstance, self::EXCEPTION_IS_NULL_POINTER);
00060                 } // END - if
00061 
00062                 // Get the action name from resolver
00063                 $actionName = $resolverInstance->getActionName();
00064 
00065                 // Store it away in this class
00066                 $filterInstance->setActionName($actionName);
00067 
00068                 // Return the instance
00069                 return $filterInstance;
00070         }
00071 
00078         protected final function setActionName ($actionName) {
00079                 $this->actionName = (string) $actionName;
00080         }
00081 
00087         public final function getActionName () {
00088                 return $this->actionName;
00089         }
00090 
00099         public function execute (Requestable $requestInstance, Responseable $responseInstance) {
00100                 // Try to get real discovery class
00101                 try {
00102                         // Get an instance from the object factory
00103                         $discoveryInstance = ObjectFactory::createObjectByConfiguredName($this->getActionName().'_payment_discovery', array($this));
00104 
00105                         // Call the discovery method
00106                         $discoveryInstance->discover($requestInstance);
00107 
00108                         // Remember this instance if all wents fine
00109                         Registry::getRegistry()->addInstance('payments', $discoveryInstance);
00110                 } catch (ConfigEntryNotFoundException $e) {
00111                         // Something bad happend
00112                         $requestInstance->requestIsValid(false);
00113 
00114                         // Add a message to the response
00115                         $responseInstance->addFatalMessage('payment_config_entry_error');
00116                         $responseInstance->addFatalMessagePlain($e->getMessage());
00117 
00118                         // Abort here
00119                         return false;
00120                 } catch (ClassNotFoundException $e) {
00121                         // Something bad happend
00122                         $requestInstance->requestIsValid(false);
00123 
00124                         // Add a message to the response
00125                         $responseInstance->addFatalMessage('payment_class_error');
00126                         $responseInstance->addFatalMessagePlain($e->getMessage());
00127 
00128                         // Abort here
00129                         return false;
00130                 }
00131         }
00132 }
00133 
00134 // [EOF]
00135 ?>

Generated on Mon Dec 8 01:06:45 2008 for Ship-Simulator by  doxygen 1.5.6