Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

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

LazyLoadingGhostFactory.php

Zuletzt modifiziert: 02.04.2025, 15:04 - Dateigröße: 3.46 KiB


01  <?php
02   
03  declare(strict_types=1);
04   
05  namespace ProxyManager\Factory;
06   
07  use Closure;
08  use ProxyManager\Proxy\GhostObjectInterface;
09  use ProxyManager\ProxyGenerator\LazyLoadingGhostGenerator;
10  use ProxyManager\ProxyGenerator\ProxyGeneratorInterface;
11  use ProxyManager\Signature\Exception\InvalidSignatureException;
12  use ProxyManager\Signature\Exception\MissingSignatureException;
13   
14  /**
15   * Factory responsible of producing ghost instances
16   *
17   * @author Marco Pivetta <ocramius@gmail.com>
18   * @license MIT
19   */
20  class LazyLoadingGhostFactory extends AbstractBaseFactory
21  {
22      /**
23       * @var \ProxyManager\ProxyGenerator\LazyLoadingGhostGenerator|null
24       */
25      private $generator;
26   
27      /**
28       * {@inheritDoc}
29       */
30      protected function getGenerator() : ProxyGeneratorInterface
31      {
32          return $this->generator ?: $this->generator = new LazyLoadingGhostGenerator();
33      }
34   
35      /**
36       * Creates a new lazy proxy instance of the given class with
37       * the given initializer
38       *
39       * Please refer to the following documentation when using this method:
40       *
41       * @link https://github.com/Ocramius/ProxyManager/blob/master/docs/lazy-loading-ghost-object.md
42       *
43       * @param string  $className   name of the class to be proxied
44       * @param Closure $initializer initializer to be passed to the proxy. The initializer closure should have following
45       *                             signature:
46       *
47       *                             <code>
48       *                             $initializer = function (
49       *                                 GhostObjectInterface $proxy,
50       *                                 string $method,
51       *                                 array $parameters,
52       *                                 & $initializer,
53       *                                 array $properties
54       *                             ) {};
55       *                             </code>
56       *
57       *                             Where:
58       *                              - $proxy is the proxy instance on which the initializer is acting
59       *                              - $method is the name of the method that triggered the lazy initialization
60       *                              - $parameters are the parameters that were passed to $method
61       *                              - $initializer by-ref initializer - should be assigned null in the initializer body
62       *                              - $properties a by-ref map of the properties of the object, indexed by PHP
63       *                                            internal property name. Assign values to it to initialize the
64       *                                            object state
65       *
66       * @param mixed[] $proxyOptions a set of options to be used when generating the proxy. Currently supports only
67       *                              key "skippedProperties", which allows to skip lazy-loading of some properties.
68       *                              "skippedProperties" is a string[], containing a list of properties referenced
69       *                              via PHP's internal property name (i.e. "\0ClassName\0propertyName")
70       *
71       * @throws MissingSignatureException
72       * @throws InvalidSignatureException
73       * @throws \OutOfBoundsException
74       */
75      public function createProxy(
76          string $className,
77          Closure $initializer,
78          array $proxyOptions = []
79      ) : GhostObjectInterface {
80          $proxyClassName = $this->generateProxy($className, $proxyOptions);
81   
82          return $proxyClassName::staticProxyConstructor($initializer);
83      }
84  }
85