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