1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PEIP\ABS\Context; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the PEIP package. |
7
|
|
|
* (c) 2009-2016 Timo Michna <timomichna/yahoo.de> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
10
|
|
|
* file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
/* |
14
|
|
|
* PEIP\ABS\Context\ContextPlugin |
15
|
|
|
* Abstract base class for all context plugins. |
16
|
|
|
* |
17
|
|
|
* @author Timo Michna <timomichna/yahoo.de> |
18
|
|
|
* @package PEIP |
19
|
|
|
* @subpackage context |
20
|
|
|
* @implements \PEIP\INF\Context\ContextPlugin |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
use PEIP\Context\XMLContext; |
24
|
|
|
use PEIP\Factory\ServiceFactory; |
25
|
|
|
|
26
|
|
|
abstract class ContextPlugin implements \PEIP\INF\Context\ContextPlugin |
27
|
|
|
{ |
28
|
|
|
protected $context; |
29
|
|
|
|
30
|
|
|
protected $builders = []; |
31
|
|
|
|
32
|
|
|
//protected static $builders = array(); |
|
|
|
|
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Initializes the plugin with given context. |
36
|
|
|
* Registers node-builders of the plugin in with the given context. |
37
|
|
|
* |
38
|
|
|
* @param \PEIP\INF\Context\Context $context context instance to register the plugin with |
39
|
|
|
* |
40
|
|
|
* @return |
41
|
|
|
*/ |
42
|
|
|
public function init(\PEIP\INF\Context\Context $context) |
43
|
|
|
{ |
44
|
|
|
$this->context = $context; |
45
|
|
|
foreach ($this->builders as $node => $method) { |
46
|
|
|
$context->registerNodeBuilder($node, [$this, $method]); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Builds and modifies an arbitrary service/object instance from a config-obect. |
52
|
|
|
* |
53
|
|
|
* @see XMLContext::doBuild |
54
|
|
|
* @see XMLContext::modifyService |
55
|
|
|
* @implements \PEIP\INF\Context\Context |
56
|
|
|
* |
57
|
|
|
* @param object $config configuration object to build a service instance from. |
58
|
|
|
* @param array $arguments arguments for the service constructor |
59
|
|
|
* @param string $defaultClass class to create instance for if none is set in config |
60
|
|
|
* |
61
|
|
|
* @return object build and modified srvice instance |
62
|
|
|
*/ |
63
|
|
|
public function buildAndModify($config, $arguments, $defaultClass = false) |
64
|
|
|
{ |
65
|
|
|
return ServiceFactory::buildAndModify($config, $arguments, $defaultClass); |
|
|
|
|
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.