/** * 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; }
/** * Adds a package object. * * @param PackageInterface $package Package object. * @return $this */ public function add(PackageInterface $package) { $this->packages[$package->getType()][$package->getId()] = $package; return $this; }