Neos\Flow\ObjectManagement\Proxy\Compiler::cacheOriginalClassFileAndProxyCode PHP Method

cacheOriginalClassFileAndProxyCode() protected method

Reads the specified class file, appends ORIGINAL_CLASSNAME_SUFFIX to its class name and stores the result in the proxy classes cache.
protected cacheOriginalClassFileAndProxyCode ( string $className, string $pathAndFilename, string $proxyClassCode ) : void
$className string Short class name of the class to copy
$pathAndFilename string Full path and filename of the original class file
$proxyClassCode string The code that makes up the proxy class
return void
    protected function cacheOriginalClassFileAndProxyCode($className, $pathAndFilename, $proxyClassCode)
    {
        $classCode = file_get_contents($pathAndFilename);
        $classCode = $this->stripOpeningPhpTag($classCode);
        $classNameSuffix = self::ORIGINAL_CLASSNAME_SUFFIX;
        $classCode = preg_replace_callback('/^([a-z\\s]*?)(final\\s+)?(interface|class)\\s+([a-zA-Z0-9_]+)/m', function ($matches) use($pathAndFilename, $classNameSuffix, $proxyClassCode) {
            $classNameAccordingToFileName = basename($pathAndFilename, '.php');
            if ($matches[4] !== $classNameAccordingToFileName) {
                throw new Exception('The name of the class "' . $matches[4] . '" is not the same as the filename which is "' . basename($pathAndFilename) . '". Path: ' . $pathAndFilename, 1398356897);
            }
            return $matches[1] . $matches[3] . ' ' . $matches[4] . $classNameSuffix;
        }, $classCode);
        $classCode = preg_replace('/\\?>[\\n\\s\\r]*$/', '', $classCode);
        $proxyClassCode .= "\n" . '# PathAndFilename: ' . $pathAndFilename;
        $this->classesCache->set(str_replace('\\', '_', $className), $classCode . $proxyClassCode);
    }