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 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
23 * @license GNU GPL 3.0 or any newer version
24 * @link http://www.shipsimu.org
26 * This program is free software: you can redistribute it and/or modify
27 * it under the terms of the GNU General Public License as published by
28 * the Free Software Foundation, either version 3 of the License, or
29 * (at your option) any later version.
31 * This program is distributed in the hope that it will be useful,
32 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 * GNU General Public License for more details.
36 * You should have received a copy of the GNU General Public License
37 * along with this program. If not, see <http://www.gnu.org/licenses/>.
39 class LocalPaymentDiscovery extends BaseDiscovery implements Discoverable, Registerable {
41 * Protected constructor
45 protected function __construct () {
46 // Call parent constructor
47 parent::__construct(__CLASS__);
51 * Create an instance of this class
53 * @param $filterInstance An instance of a filter
54 * @return $discoveryInstance An instance of this discovery class
56 public static final function createLocalPaymentDiscovery (Filterable $filterInstance) {
57 // Get an instance of this class
58 $discoveryInstance = new LocalPaymentDiscovery();
60 // Set the action from filter
61 $discoveryInstance->setActionName($filterInstance->getActionName());
63 // Return the prepared instance
64 return $discoveryInstance;
68 * Discovers the request
70 * @param $requestInstance An instance of a Requestable class
73 public function discover (Requestable $requestInstance) {
74 // Now get a search criteria and set app name and payment action as search critera
75 $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
76 $criteriaInstance->addCriteria('app_name', $requestInstance->getRequestElement('app'));
77 $criteriaInstance->addCriteria('payment_action', $this->getActionName() . '_action');
78 $criteriaInstance->setLimit(1);
80 // Get a wrapper instance
81 $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('payment_db_wrapper_class');
84 $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
86 // Advanced to next entry and assert on it as it should always be there
87 assert($resultInstance->valid());
89 // Set the result instance
90 $this->setResultInstance($resultInstance);
94 * Adds the database result in a human-readable format to the helper class
96 * @param $helperInstance An instance of a helper class
100 public function addResultsToHelper (HelpableTemplate $helperInstance) {