示例#1
0
 public static function generateXfcpClass($clazz, $realClazz, DevHelper_Config_Base $config)
 {
     $ghostClazz = str_replace($config->getClassPrefix(), $config->getClassPrefix() . '_DevHelper_XFCP', $clazz);
     $ghostPath = DevHelper_Generator_File::getClassPath($ghostClazz);
     if (file_exists($ghostPath)) {
         // ghost file exists, yay!
         return true;
     }
     $ghostContents = "<?php\n\nclass XFCP_{$clazz} extends {$realClazz}\n{\n}\n";
     return DevHelper_Generator_File::filePutContents($ghostPath, $ghostContents);
 }
示例#2
0
 public static function getClassName($addOnId, $subClassName = false, DevHelper_Config_Base $config = null)
 {
     static $classNames = array();
     $hash = $addOnId . $subClassName;
     if (empty($classNames[$hash])) {
         if ($subClassName === 'DevHelper_Config') {
             $tmp = $addOnId;
             $tmp = preg_replace('/[^a-zA-Z_0-9]/', '', $tmp);
             // read root directory (./library), trying to pickup matched directory name
             $tmp = self::getClassNameInDirectory(XenForo_Autoloader::getInstance()->getRootDir(), $tmp);
             $className = $tmp . '_DevHelper_Config';
         } else {
             if ($config === null) {
                 throw new XenForo_Exception(sprintf('%s requires $config when $subClassName=%s', __METHOD__, $subClassName));
             }
             $className = rtrim(sprintf('%s_%s', $config->getClassPrefix(), $subClassName), '_');
         }
         $classNames[$hash] = $className;
     }
     return $classNames[$hash];
 }