Пример #1
0
 protected function load_class($class, $params = NULL, $object_name = NULL)
 {
     // Get the class name, and while we're at it trim any slashes.
     // The directory path can be included as part of the class name,
     // but we don't want a leading slash
     $class = str_replace('.php', '', trim($class, '/'));
     // Was the path included with the class name?
     // We look for a slash to determine this
     if (($last_slash = strrpos($class, '/')) !== FALSE) {
         // Extract the path
         $subdir = substr($class, 0, ++$last_slash);
         // Get the filename from the path
         $class = substr($class, $last_slash);
     } else {
         $subdir = '';
     }
     $class = ucfirst($class);
     $subclass = self::$base . '/Library/' . $subdir . $class . '.php';
     include_once $subclass;
     if (empty($object_name)) {
         $object_name = strtolower($class);
     }
     // Don't overwrite existing properties
     $ypf = \Ypf\Ypf::getInstance();
     if (isset($ypf->{$object_name})) {
         trigger_error("Resource '" . $object_name . "' already exists and is not a " . $class . " instance.");
     }
     // Instantiate the class
     $ypf->{$object_name} = isset($params) ? new $class($params) : new $class();
 }
Пример #2
0
 public function __construct()
 {
     self::$container = \Ypf\Ypf::getContainer();
 }
Пример #3
0
 protected function action($action, $args = array())
 {
     return \Ypf\Ypf::getInstance()->execute($action, $args);
 }