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