Example #1
0
 /**
  * Core autoload method
  *
  * This method loads general class and interface files from the
  * ae/classes/ path. Each underscore in the name of the class will be
  * treaded as a subdirectory of the classes directory. File should have
  * .class.[extension] suffix to be loaded.
  *
  * So a class named AeHello_World (or just Hello_World, see {@link
  * AeCore::getClassPath() getClassPath()} method for more details) should
  * have ae/classes/hello/world.class.php as its path to be successfully
  * loaded by this autoload method.
  *
  * @see AeAutoload
  * @see AeAutoload::tryFile()
  *
  * @param string $class class name
  * 
  * @return bool true if the class file has been successfully found and
  *              loaded. False otherwise
  */
 public static function autoload($class)
 {
     if (class_exists($class, false) || interface_exists($class, false)) {
         return true;
     }
     $file = self::getClassPath($class);
     if (!$file) {
         // Not an internal class
         return false;
     }
     $file = $file . '.class';
     return AeAutoload::findFile($file);
 }
Example #2
0
 /**
  * Exception autoload method
  *
  * This method loads exception class files from the ae/classes/ path.
  * Since most exception classes are declared inside the general class files,
  * this method also converts the class name to the respective general class,
  * to autodetect that class's path:
  * <code> throw new AeFooBarBazException('Not found', 404);
  * // Will search for the AeFoo_Bar_Baz class
  * // inside the ae/classes/foo/bar/baz.class.php file</code>
  *
  * @see AeAutoload
  * @see AeAutoload::extensions()
  *
  * @param string $class class name
  *
  * @return bool true if the class file has been successfully found and
  *              loaded. False otherwise
  */
 public static function autoload($class)
 {
     if (class_exists($class, false) || interface_exists($class, false)) {
         return true;
     }
     if (substr($class, -9) != 'Exception' || substr($class, 0, 2) != 'Ae') {
         return false;
     }
     $class = preg_replace('#([a-z])([A-Z])#', '\\1_\\2', substr($class, 2, -9));
     $file = AeCore::getClassPath('Ae' . $class);
     if (!$file) {
         // Not an internal exception class
         return false;
     }
     $file = $file . '.class';
     return AeAutoload::findFile($file);
 }