Renamed Registry -> GenericRegistry to make it clear that this registry does
[core.git] / framework / main / classes / filter / class_BaseFilterDecorator.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Filter;
4
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
7 use Org\Mxchange\CoreFramework\Request\Requestable;
8 use Org\Mxchange\CoreFramework\Response\Responseable;
9
10 /**
11  * A general filter decorator for decorating filters with other filters
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 abstract class BaseFilterDecorator extends BaseFrameworkSystem implements Filterable {
33         /**
34          * The decorated filter instance
35          */
36         private $filterInstance = NULL;
37
38         /**
39          * Protected constructor
40          *
41          * @param       $className      Name of the real class' name
42          * @return      void
43          */
44         protected function __construct ($className) {
45                 // Call parent constructor
46                 parent::__construct($className);
47         }
48
49         /**
50          * Setter for the decorated filter instance
51          *
52          * @param       $filterInstance         An instance of a filter
53          * @return      void
54          */
55         protected final function setFilterInstance (Filterable $filterInstance) {
56                 $this->filterInstance = $filterInstance;
57         }
58
59         /**
60          * Getter for the decorated filter instance
61          *
62          * @return      $filterInstance         An instance of a filter
63          */
64         protected final function getFilterInstance () {
65                 return $this->filterInstance;
66         }
67
68         /**
69          * Execute the inner filter
70          *
71          * @param       $requestInstance        An instance of a Requestable class
72          * @param       $responseInstance       An instance of a Responseable class
73          * @return      void
74          */
75         public final function execute (Requestable $requestInstance, Responseable $responseInstance) {
76                 $this->getFilterInstance()->execute($requestInstance, $responseInstance);
77         }
78
79
80         /**
81          * Do the execution of the filter
82          *
83          * @param       $requestInstance        An instance of a Requestable class
84          * @param       $responseInstance       An instance of a Responseable class
85          * @return      void
86          */
87         abstract public function doExecute (Requestable $requestInstance, Responseable $responseInstance);
88
89 }