Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
AccessInterceptorScopeLocalizerGenerator.php
01 <?php
02 /*
03 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
04 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
05 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
06 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
07 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
08 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
09 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 *
15 * This software consists of voluntary contributions made by many individuals
16 * and is licensed under the MIT license.
17 */
18
19 namespace ProxyManager\ProxyGenerator;
20
21 use ProxyManager\Generator\Util\ClassGeneratorUtils;
22 use ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodPrefixInterceptor;
23 use ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodSuffixInterceptor;
24 use ProxyManager\ProxyGenerator\AccessInterceptor\PropertyGenerator\MethodPrefixInterceptors;
25 use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor;
26 use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\InterceptedMethod;
27 use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicClone;
28 use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicGet;
29 use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicIsset;
30 use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicSet;
31 use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicSleep;
32 use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicUnset;
33 use ProxyManager\ProxyGenerator\Assertion\CanProxyAssertion;
34 use ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter;
35 use ReflectionClass;
36 use ReflectionMethod;
37 use Zend\Code\Generator\ClassGenerator;
38 use Zend\Code\Generator\MethodGenerator;
39 use Zend\Code\Reflection\MethodReflection;
40
41 /**
42 * Generator for proxies implementing {@see \ProxyManager\Proxy\ValueHolderInterface}
43 * and localizing scope of the proxied object at instantiation
44 *
45 * {@inheritDoc}
46 *
47 * @author Marco Pivetta <ocramius@gmail.com>
48 * @license MIT
49 */
50 class AccessInterceptorScopeLocalizerGenerator implements ProxyGeneratorInterface
51 {
52 /**
53 * {@inheritDoc}
54 */
55 public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator)
56 {
57 CanProxyAssertion::assertClassCanBeProxied($originalClass, false);
58
59 $classGenerator->setExtendedClass($originalClass->getName());
60 $classGenerator->setImplementedInterfaces(array('ProxyManager\\Proxy\\AccessInterceptorInterface'));
61 $classGenerator->addPropertyFromGenerator($prefixInterceptors = new MethodPrefixInterceptors());
62 $classGenerator->addPropertyFromGenerator($suffixInterceptors = new MethodPrefixInterceptors());
63
64 array_map(
65 function (MethodGenerator $generatedMethod) use ($originalClass, $classGenerator) {
66 ClassGeneratorUtils::addMethodIfNotFinal($originalClass, $classGenerator, $generatedMethod);
67 },
68 array_merge(
69 array_map(
70 function (ReflectionMethod $method) use ($prefixInterceptors, $suffixInterceptors) {
71 return InterceptedMethod::generateMethod(
72 new MethodReflection($method->getDeclaringClass()->getName(), $method->getName()),
73 $prefixInterceptors,
74 $suffixInterceptors
75 );
76 },
77 ProxiedMethodsFilter::getProxiedMethods(
78 $originalClass,
79 array('__get', '__set', '__isset', '__unset', '__clone', '__sleep')
80 )
81 ),
82 array(
83 new Constructor($originalClass, $prefixInterceptors, $suffixInterceptors),
84 new SetMethodPrefixInterceptor($prefixInterceptors),
85 new SetMethodSuffixInterceptor($suffixInterceptors),
86 new MagicGet($originalClass, $prefixInterceptors, $suffixInterceptors),
87 new MagicSet($originalClass, $prefixInterceptors, $suffixInterceptors),
88 new MagicIsset($originalClass, $prefixInterceptors, $suffixInterceptors),
89 new MagicUnset($originalClass, $prefixInterceptors, $suffixInterceptors),
90 new MagicSleep($originalClass, $prefixInterceptors, $suffixInterceptors),
91 new MagicClone($originalClass, $prefixInterceptors, $suffixInterceptors),
92 )
93 )
94 );
95 }
96 }
97