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