Exemplo n.º 1
0
 public final function getInstance($name, JMPlugin $plugin, $prefix = null)
 {
     if (is_null($prefix)) {
         $prefix = $plugin->get('component') . 'JMResource';
     }
     $type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $name);
     $resourceClass = $prefix . ucfirst($type);
     if (!class_exists($resourceClass)) {
         jimport('joomla.filesystem.path');
         if ($path = JPath::find(self::addIncludePath(), strtolower($type) . '.php')) {
             require_once $path;
             if (!class_exists($resourceClass)) {
                 // Resource class not found
                 return false;
             }
         } else {
             // Resource file not found
             return false;
         }
     }
     $instance = new $resourceClass($plugin);
     return $instance;
 }