Gdn::factoryExists PHP Method

factoryExists() public static method

Checks whether or not a factory alias exists.
See also: Gdn_Factory::Exists()
public static factoryExists ( string $Alias ) : boolean
$Alias string The alias of the factory to check for.
return boolean Whether or not a factory definintion exists.
    public static function factoryExists($Alias)
    {
        return self::factory()->exists($Alias);
    }

Usage Example

Esempio n. 1
0
 /**
  *
  */
 public function getImports()
 {
     if (!isset($this->Uses) || !is_array($this->Uses)) {
         return;
     }
     // Load any classes in the uses array and make them properties of this class
     foreach ($this->Uses as $Class) {
         if (strlen($Class) >= 4 && substr_compare($Class, 'Gdn_', 0, 4) == 0) {
             $Property = substr($Class, 4);
         } else {
             $Property = $Class;
         }
         // Find the class and instantiate an instance..
         if (Gdn::factoryExists($Property)) {
             $this->{$Property} = Gdn::Factory($Property);
         }
         if (Gdn::factoryExists($Class)) {
             // Instantiate from the factory.
             $this->{$Property} = Gdn::factory($Class);
         } elseif (class_exists($Class)) {
             // Instantiate as an object.
             $ReflectionClass = new ReflectionClass($Class);
             // Is this class a singleton?
             if ($ReflectionClass->implementsInterface("ISingleton")) {
                 eval('$this->' . $Property . ' = ' . $Class . '::GetInstance();');
             } else {
                 $this->{$Property} = new $Class();
             }
         } else {
             trigger_error(errorMessage('The "' . $Class . '" class could not be found.', $this->ClassName, '__construct'), E_USER_ERROR);
         }
     }
 }