These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Copyright (c) 2013-2016 |
||
4 | * |
||
5 | * @category Library |
||
6 | * @package Dwoo\Adapters\ZendFramework |
||
7 | * @author Jordi Boggiano <[email protected]> |
||
8 | * @author David Sanchez <[email protected]> |
||
9 | * @copyright 2008-2013 Jordi Boggiano |
||
10 | * @copyright 2013-2016 David Sanchez |
||
11 | * @license http://dwoo.org/LICENSE Modified BSD License |
||
12 | * @version 1.3.0 |
||
13 | * @date 2016-09-19 |
||
14 | * @link http://dwoo.org/ |
||
15 | */ |
||
16 | |||
17 | use Dwoo\Compiler; |
||
18 | use Dwoo\IPluginProxy; |
||
19 | |||
20 | /** |
||
21 | * PluginProxy class for Zend View. |
||
22 | * |
||
23 | * This software is provided 'as-is', without any express or implied warranty. |
||
24 | * In no event will the authors be held liable for any damages arising from the |
||
25 | * use of this software. |
||
26 | * |
||
27 | * @author Denis Arh <[email protected]> |
||
28 | * @author Jordi Boggiano <[email protected]> |
||
29 | * @copyright Copyright (c) 2008, Denis Arh, Jordi Boggiano |
||
30 | * @license http://dwoo.org/LICENSE Modified BSD License |
||
31 | * |
||
32 | * @link http://dwoo.org/ |
||
33 | * |
||
34 | * @version 1.0.0 |
||
35 | * @date 2008-10-23 |
||
36 | */ |
||
37 | class Dwoo_Adapters_ZendFramework_PluginProxy implements IPluginProxy |
||
0 ignored issues
–
show
|
|||
38 | { |
||
39 | /** |
||
40 | * reference to the zend view owning this proxy. |
||
41 | * |
||
42 | * @var Zend_View_Interface |
||
43 | */ |
||
44 | public $view; |
||
45 | |||
46 | /** |
||
47 | * Dwoo_Adapters_ZendFramework_PluginProxy's constructor. |
||
48 | * |
||
49 | * @param Zend_View_Interface $view |
||
50 | */ |
||
51 | public function __construct(Zend_View_Interface $view) |
||
52 | { |
||
53 | $this->view = $view; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Called from Dwoo_Compiler to check if the requested plugin is available. |
||
58 | * |
||
59 | * @param string $name |
||
60 | * |
||
61 | * @return bool |
||
62 | */ |
||
63 | public function handles($name) |
||
64 | { |
||
65 | try { |
||
66 | $this->view->getHelper($name); |
||
67 | } catch (Zend_Loader_PluginLoader_Exception $e) { |
||
68 | return false; |
||
69 | } |
||
70 | |||
71 | return true; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * returns the code (as a string) to call the plugin |
||
76 | * (this will be executed at runtime inside the Dwoo class). |
||
77 | * |
||
78 | * @param string $name the plugin name |
||
79 | * @param array $params a parameter array, array key "*" is the rest array |
||
80 | * |
||
81 | * @return string |
||
82 | */ |
||
83 | public function getCode($name, $params) |
||
84 | { |
||
85 | return '$this->getPluginProxy()->view->'.$name.'('.Compiler::implode_r($params).')'; |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * returns a callback to the plugin, this is used with the reflection API to |
||
90 | * find out about the plugin's parameter names etc. |
||
91 | * |
||
92 | * should you need a rest array (i.e. for ZendFramework helpers) without the |
||
93 | * possibility to edit the plugin's code, you can provide a callback to some |
||
94 | * other function with the correct parameter signature, i.e. : |
||
95 | * <code> |
||
96 | * return array($this, "callbackHelper"); |
||
97 | * // and callbackHelper would be as such: |
||
98 | * public function callbackHelper(array $rest=array()){} |
||
99 | * </code> |
||
100 | * |
||
101 | * @param string $name the plugin name |
||
102 | * |
||
103 | * @return callback |
||
104 | */ |
||
105 | public function getCallback($name) |
||
106 | { |
||
107 | return array($this->view->getHelper($name), $name); |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * returns some code that will check if the plugin is loaded and if not load it |
||
112 | * this is optional, if your plugins are autoloaded or whatever, just return an |
||
113 | * empty string. |
||
114 | * |
||
115 | * @param string $name the plugin name |
||
116 | * |
||
117 | * @return string |
||
118 | */ |
||
119 | public function getLoader($name) |
||
120 | { |
||
121 | return ''; |
||
122 | } |
||
123 | } |
||
124 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.