/** * Возвращает код advice секции для auto pointcut * * @param string $class * @param string $method * @param string $autoPointcut * @return Miaox_Aop_Advice */ public function &getAdviceFromAutoPointcut($class, $method, $autoPointcut) { $advice = new Miaox_Aop_Advice(); $a =& $this->_weave->getAdviceFromAutoPointcut($class, $method, $autoPointcut); $code = $a->getData(); // Does it has any code to replace? if (strlen($code) > 0) { // PHP Code Cruncher if ($this->_compact) { $code = Miaox_Aop_CodeCruncher::process($code); } else { $code = "\r\n" . $code . "\r\n"; } // Add an informative text $code = "/* AOP \"" . $autoPointcut . "\" Auto Code */ " . $code . " "; } $advice->addData($code); return $advice; }
/** * Получение имени файла в зависимости от $this->_$recompile и наличия * изменений в файлах классов, аспектов * * @param string $filePath * путь к исходному классу * @param string|Miaox_Aop_Weave|Uniora_Tools_Aop_Aspect|array $weave * можно использовать: имя xml файла, папку с xml файлами * (добавяться все файлы xml вместе с поддиректориями), * Uniora_Tools_Aop_Aspect, массив из предыдущих вариантов, * Uniora_Tools_Aop_Weave * @return string */ public function getCompiledFilename($filePath, $weave = "./") { // Check if file to be compiled exists if (!file_exists($filePath)) { throw new Miaox_Aop_Exception("[ Aspect Error ]: File " . $filePath . " does not exist!"); } // Correcting aspects typing if (!$weave instanceof Miaox_Aop_Weave) { $weave = new Miaox_Aop_Weave($weave); } $dir = Miaox_Aop_File::getCacheDirName($filePath, $this->_cache); // Retrieving information // Defining Last Modified Date $lastModified = filemtime($filePath); if ($lastModified < $weave->getLastModified()) { $lastModified = $weave->getLastModified(); } // Compiled Class File - ".php" added to enable correctly Server File // Type Handler $compiledClassFile = Miaox_Aop_File::getCompiledClassFile($filePath); $compiledClassFilename = $dir . DIRECTORY_SEPARATOR . $compiledClassFile; // Checking if is necessary to compile file // First condition: No aspects defined // Second condition: Compiled file does not exist // Third condition: Compiled file is older than one ( or more ) of the // aspects // Fourth condition: Programmer defined to recompile if (!$weave->hasAspects() || !file_exists($compiledClassFilename) || filemtime($compiledClassFilename) <= $lastModified || $this->_recompile) { $this->_compile($filePath, $compiledClassFilename, $weave); } // Check if the compiled file exists if (file_exists($compiledClassFilename)) { // Load the compiled file return $compiledClassFilename; } else { if ($weave->hasAspects() === false) { // Load original file ( no aspects defined ) return $filePath; } else { throw new Miaox_Aop_Exception("[ Aspect Error ]: Compiled File " . $compiledClassFilename . " [ From Original: " . $filePath . " ] could not be loaded!"); } } }