Example #1
0
 /**
  * Loads a package object.
  * 
  * @param PackageInterface $package Package object to load.
  * @return $this
  */
 public function load(PackageInterface $package)
 {
     $path = rtrim($package->getPath(), '/\\') . '/';
     // Include a file in base directory with same name as package, if it exists
     \Phpf\App::includeInScope($path . basename($path) . '.php', true);
     // Include a 'bootstrap.php' file if exists
     \Phpf\App::includeInScope($path . 'bootstrap.php', true);
     // Include config files provided by package
     foreach ($this->config['files'] as $file) {
         \Phpf\App::includeInScope($path . ltrim($file, '/\\'), true);
     }
     // Add directories provided by package
     foreach ($this->config['dirs'] as $group => $dir) {
         $dir = trim($dir, '/\\');
         if (is_dir($path . $dir)) {
             $this->app->get('filesystem')->add($path . $dir . '/', $group);
         }
     }
     // Set the package to loaded
     $package->setLoaded(true);
     return $this;
 }
Example #2
0
 /**
  * Constructor
  * 
  * @param \Phpf\App $app Application instance.
  * @return void
  */
 public function __construct(App $app)
 {
     $this->app = $app;
     $this->loader = new Loader($app);
     $this->config = $app->get('config')->get('packages');
 }
Example #3
0
/**
 * Add a route endpoint.
 */
function endpoint($path, Closure $closure)
{
    \Phpf\App::instance()->get('router')->endpoint($path, $closure);
}