Пример #1
0
 /**
  * @todo this actually tests the file-not-found logic, not the file-found-
  * but-class-not-there logic.  fix that.  :-/
  */
 public function testAutoload_noSuchClass()
 {
     try {
         Solar_Class::autoload('No_Such_Class');
         $this->fail('Should throw exception when class does not exist.');
     } catch (Exception $e) {
         $this->assertInstance($e, 'Solar_Exception');
     }
 }
Пример #2
0
 /**
  * 
  * Convenience method to instantiate and configure an object.
  * 
  * @param string $class The class name.
  * 
  * @param array $config Configuration value overrides, if any.
  * 
  * @return object A new instance of the requested class.
  * 
  */
 public static function factory($class, $config = null)
 {
     Solar_Class::autoload($class);
     $obj = new $class($config);
     // is it an object factory?
     if ($obj instanceof Solar_Factory) {
         // return an instance from the object factory
         return $obj->factory();
     }
     // return the object itself
     return $obj;
 }