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 |
AbstractBaseFactory.php
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\Factory;
020
021 use ProxyManager\Configuration;
022 use ProxyManager\Generator\ClassGenerator;
023 use ProxyManager\Version;
024 use ReflectionClass;
025
026 /**
027 * Base factory common logic
028 *
029 * @author Marco Pivetta <ocramius@gmail.com>
030 * @license MIT
031 */
032 abstract class AbstractBaseFactory
033 {
034 /**
035 * @var \ProxyManager\Configuration
036 */
037 protected $configuration;
038
039 /**
040 * Cached checked class names
041 *
042 * @var string[]
043 */
044 private $checkedClasses = array();
045
046 /**
047 * @param \ProxyManager\Configuration $configuration
048 */
049 public function __construct(Configuration $configuration = null)
050 {
051 $this->configuration = $configuration ?: new Configuration();
052 }
053
054 /**
055 * Generate a proxy from a class name
056 * @param string $className
057 * @return string proxy class name
058 */
059 protected function generateProxy($className)
060 {
061 if (isset($this->checkedClasses[$className])) {
062 return $this->checkedClasses[$className];
063 }
064
065 $proxyParameters = array(
066 'className' => $className,
067 'factory' => get_class($this),
068 'proxyManagerVersion' => Version::VERSION
069 );
070 $proxyClassName = $this
071 ->configuration
072 ->getClassNameInflector()
073 ->getProxyClassName($className, $proxyParameters);
074
075 if (! class_exists($proxyClassName)) {
076 $this->generateProxyClass($proxyClassName, $className, $proxyParameters);
077 }
078
079 $this
080 ->configuration
081 ->getSignatureChecker()
082 ->checkSignature(new ReflectionClass($proxyClassName), $proxyParameters);
083
084 return $this->checkedClasses[$className] = $proxyClassName;
085 }
086
087 /**
088 * @return \ProxyManager\ProxyGenerator\ProxyGeneratorInterface
089 */
090 abstract protected function getGenerator();
091
092 /**
093 * Generates the provided `$proxyClassName` from the given `$className` and `$proxyParameters`
094 * @param string $proxyClassName
095 * @param string $className
096 * @param array $proxyParameters
097 *
098 * @return void
099 */
100 private function generateProxyClass($proxyClassName, $className, array $proxyParameters)
101 {
102 $className = $this->configuration->getClassNameInflector()->getUserClassName($className);
103 $phpClass = new ClassGenerator($proxyClassName);
104
105 $this->getGenerator()->generate(new ReflectionClass($className), $phpClass);
106
107 $phpClass = $this->configuration->getClassSignatureGenerator()->addSignature($phpClass, $proxyParameters);
108
109 $this->configuration->getGeneratorStrategy()->generate($phpClass);
110 $this->configuration->getProxyAutoloader()->__invoke($proxyClassName);
111 }
112 }
113