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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

LazyLoadingGhostGenerator.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 5.67 KiB


 001  <?php
 002  /*
 003   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 004   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 005   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 006   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 007   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 008   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 009   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 010   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 011   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 012   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 013   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 014   *
 015   * This software consists of voluntary contributions made by many individuals
 016   * and is licensed under the MIT license.
 017   */
 018   
 019  namespace ProxyManager\ProxyGenerator;
 020   
 021  use ProxyManager\Generator\Util\ClassGeneratorUtils;
 022  use ProxyManager\ProxyGenerator\Assertion\CanProxyAssertion;
 023  use ProxyManager\ProxyGenerator\LazyLoading\MethodGenerator\Constructor;
 024  use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\CallInitializer;
 025  use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\GetProxyInitializer;
 026  use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\InitializeProxy;
 027  use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\IsProxyInitialized;
 028  use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\LazyLoadingMethodInterceptor;
 029  use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicClone;
 030  use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicGet;
 031  use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicIsset;
 032  use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicSet;
 033  use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicSleep;
 034  use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicUnset;
 035  use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\SetProxyInitializer;
 036  use ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator\InitializationTracker;
 037  use ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator\InitializerProperty;
 038  use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesDefaults;
 039  use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap;
 040  use ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter;
 041  use ReflectionClass;
 042  use ReflectionMethod;
 043  use Zend\Code\Generator\ClassGenerator;
 044  use Zend\Code\Generator\MethodGenerator;
 045  use Zend\Code\Reflection\MethodReflection;
 046   
 047  /**
 048   * Generator for proxies implementing {@see \ProxyManager\Proxy\GhostObjectInterface}
 049   *
 050   * {@inheritDoc}
 051   *
 052   * @author Marco Pivetta <ocramius@gmail.com>
 053   * @license MIT
 054   */
 055  class LazyLoadingGhostGenerator implements ProxyGeneratorInterface
 056  {
 057      /**
 058       * {@inheritDoc}
 059       */
 060      public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator)
 061      {
 062          CanProxyAssertion::assertClassCanBeProxied($originalClass);
 063   
 064          $interfaces          = array('ProxyManager\\Proxy\\GhostObjectInterface');
 065          $publicProperties    = new PublicPropertiesMap($originalClass);
 066          $publicPropsDefaults = new PublicPropertiesDefaults($originalClass);
 067   
 068          if ($originalClass->isInterface()) {
 069              $interfaces[] = $originalClass->getName();
 070          } else {
 071              $classGenerator->setExtendedClass($originalClass->getName());
 072          }
 073   
 074          $classGenerator->setImplementedInterfaces($interfaces);
 075          $classGenerator->addPropertyFromGenerator($initializer = new InitializerProperty());
 076          $classGenerator->addPropertyFromGenerator($initializationTracker = new InitializationTracker());
 077          $classGenerator->addPropertyFromGenerator($publicProperties);
 078          $classGenerator->addPropertyFromGenerator($publicPropsDefaults);
 079   
 080          $init = new CallInitializer($initializer, $publicPropsDefaults, $initializationTracker);
 081   
 082          array_map(
 083              function (MethodGenerator $generatedMethod) use ($originalClass, $classGenerator) {
 084                  ClassGeneratorUtils::addMethodIfNotFinal($originalClass, $classGenerator, $generatedMethod);
 085              },
 086              array_merge(
 087                  array_map(
 088                      function (ReflectionMethod $method) use ($initializer, $init) {
 089                          return LazyLoadingMethodInterceptor::generateMethod(
 090                              new MethodReflection($method->getDeclaringClass()->getName(), $method->getName()),
 091                              $initializer,
 092                              $init
 093                          );
 094                      },
 095                      ProxiedMethodsFilter::getProxiedMethods($originalClass)
 096                  ),
 097                  array(
 098                      $init,
 099                      new Constructor($originalClass, $initializer),
 100                      new MagicGet($originalClass, $initializer, $init, $publicProperties),
 101                      new MagicSet($originalClass, $initializer, $init, $publicProperties),
 102                      new MagicIsset($originalClass, $initializer, $init, $publicProperties),
 103                      new MagicUnset($originalClass, $initializer, $init, $publicProperties),
 104                      new MagicClone($originalClass, $initializer, $init, $publicProperties),
 105                      new MagicSleep($originalClass, $initializer, $init, $publicProperties),
 106                      new SetProxyInitializer($initializer),
 107                      new GetProxyInitializer($initializer),
 108                      new InitializeProxy($initializer, $init),
 109                      new IsProxyInitialized($initializer),
 110                  )
 111              )
 112          );
 113      }
 114  }
 115