Example #1
0
 /**
  * @param $class
  * @return bool|string
  */
 public static function getClassFile($class)
 {
     $class = ltrim($class, '\\');
     if (preg_match('{^TAO\\\\CachedInfoblock\\\\([^\\\\]+)$}', $class, $m)) {
         $name = self::unchunkCap($m[1]);
         $path = self::localDir("cache/infoblock/{$name}.php");
         if (!is_file($path)) {
             $id = self::getInfoblockId($name);
             if (!$id) {
                 print "Infoblock {$name} not found!";
                 die;
             }
             $content = \TAO\InfoblockExport::run($id, true);
             $dir = dirname($path);
             if (!is_dir($dir)) {
                 mkdir($dir, 0777, true);
             }
             file_put_contents($path, $content);
         }
         return $path;
     } elseif (preg_match('{^App\\\\Forms\\\\([^\\\\]+)$}', $class, $m)) {
         $name = $m[1];
         return \TAO\Form::formClassFile($name);
     } elseif (preg_match('{^TAO\\\\Bundle\\\\([^\\\\]+)\\\\(.+)$}', $class, $m)) {
         $bundle = $m[1];
         $name = str_replace('\\', '/', $m[2]);
         $path = self::taoDir("bundles/{$bundle}/lib/{$name}.php");
         return $path;
     } elseif (preg_match('{^App\\\\Bundle\\\\([^\\\\]+)\\\\(.+)$}', $class, $m)) {
         $bundle = $m[1];
         $name = str_replace('\\', '/', $m[2]);
         $path = self::localDir("bundles/{$bundle}/lib/{$name}.php");
         return $path;
     } elseif (preg_match('{^TAO\\\\([^\\\\]+)$}', $class, $m)) {
         $name = self::unchunkCap($m[1]);
         return self::taoDir("lib/{$name}.php");
     } elseif (preg_match('{^App\\\\(.+)$}', $class, $m)) {
         $name = str_replace('\\', '/', $m[1]);
         return self::localDir("lib/{$name}.php");
     } elseif ($class == 'TAO\\CLI') {
         return self::taoDir("lib/cli.php");
     }
     return false;
 }