[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 9 * 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\Factory; 20 21 use ProxyManager\Configuration; 22 use ProxyManager\Generator\ClassGenerator; 23 use ProxyManager\Version; 24 use ReflectionClass; 25 26 /** 27 * Base factory common logic 28 * 29 * @author Marco Pivetta <ocramius@gmail.com> 30 * @license MIT 31 */ 32 abstract class AbstractBaseFactory 33 { 34 /** 35 * @var \ProxyManager\Configuration 36 */ 37 protected $configuration; 38 39 /** 40 * Cached checked class names 41 * 42 * @var string[] 43 */ 44 private $checkedClasses = array(); 45 46 /** 47 * @param \ProxyManager\Configuration $configuration 48 */ 49 public function __construct(Configuration $configuration = null) 50 { 51 $this->configuration = $configuration ?: new Configuration(); 52 } 53 54 /** 55 * Generate a proxy from a class name 56 * @param string $className 57 * @return string proxy class name 58 */ 59 protected function generateProxy($className) 60 { 61 if (isset($this->checkedClasses[$className])) { 62 return $this->checkedClasses[$className]; 63 } 64 65 $proxyParameters = array( 66 'className' => $className, 67 'factory' => get_class($this), 68 'proxyManagerVersion' => Version::VERSION 69 ); 70 $proxyClassName = $this 71 ->configuration 72 ->getClassNameInflector() 73 ->getProxyClassName($className, $proxyParameters); 74 75 if (! class_exists($proxyClassName)) { 76 $this->generateProxyClass($proxyClassName, $className, $proxyParameters); 77 } 78 79 $this 80 ->configuration 81 ->getSignatureChecker() 82 ->checkSignature(new ReflectionClass($proxyClassName), $proxyParameters); 83 84 return $this->checkedClasses[$className] = $proxyClassName; 85 } 86 87 /** 88 * @return \ProxyManager\ProxyGenerator\ProxyGeneratorInterface 89 */ 90 abstract protected function getGenerator(); 91 92 /** 93 * Generates the provided `$proxyClassName` from the given `$className` and `$proxyParameters` 94 * @param string $proxyClassName 95 * @param string $className 96 * @param array $proxyParameters 97 * 98 * @return void 99 */ 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 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |