0864675b51bdb0dfb4120c81f955666ef7adec96
[core.git] / inc / main / classes / discovery / payment / class_LocalPaymentDiscovery.php
1 <?php
2 // Own namespace
3 namespace CoreFramework\Discovery\Payment;
4
5 // Import framework stuff
6 use CoreFramework\Registry\Registerable;
7
8 /**
9  * A local payment discovery class. This class looks in local database for
10  * registered payment types and like all the others it at least returns the
11  * money bank transfer type.
12  *
13  * @author              Roland Haeder <webmaster@shipsimu.org>
14  * @version             0.0.0
15  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
16  * @license             GNU GPL 3.0 or any newer version
17  * @link                http://www.shipsimu.org
18  *
19  * This program is free software: you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation, either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  */
32 class LocalPaymentDiscovery extends BaseDiscovery implements Discoverable, Registerable {
33         /**
34          * Protected constructor
35          *
36          * @return      void
37          */
38         protected function __construct () {
39                 // Call parent constructor
40                 parent::__construct(__CLASS__);
41         }
42
43         /**
44          * Create an instance of this class
45          *
46          * @param       $filterInstance         An instance of a filter
47          * @return      $discoveryInstance      An instance of this discovery class
48          */
49         public static final function createLocalPaymentDiscovery (Filterable $filterInstance) {
50                 // Get an instance of this class
51                 $discoveryInstance = new LocalPaymentDiscovery();
52
53                 // Set the action from filter
54                 $discoveryInstance->setActionName($filterInstance->getActionName());
55
56                 // Return the prepared instance
57                 return $discoveryInstance;
58         }
59
60         /**
61          * Discovers the request
62          *
63          * @param       $requestInstance        An instance of a Requestable class
64          * @return      void
65          */
66         public function discover (Requestable $requestInstance) {
67                 // Now get a search criteria and set app name and payment action as search critera
68                 $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
69                 $criteriaInstance->addCriteria('app_name', $requestInstance->getRequestElement('app'));
70                 $criteriaInstance->addCriteria('payment_action', $this->getActionName() . '_action');
71                 $criteriaInstance->setLimit(1);
72
73                 // Get a wrapper instance
74                 $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('payment_db_wrapper_class');
75
76                 // Get result back
77                 $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
78
79                 // Advanced to next entry and assert on it as it should always be there
80                 assert($resultInstance->valid());
81
82                 // Set the result instance
83                 $this->setResultInstance($resultInstance);
84         }
85
86         /**
87          * Adds the database result in a human-readable format to the helper class
88          *
89          * @param       $helperInstance         An instance of a helper class
90          * @return      void
91          * @todo        0% done
92          */
93         public function addResultsToHelper (HelpableTemplate $helperInstance) {
94                 // Undone part
95         }
96 }
97
98 // [EOF]
99 ?>