Beispiel #1
0
 private function loadHelpers(Job $job)
 {
     $helperConfiguration = $job->configuration->getSubConfiguration('helpers');
     $helperFolders = $helperConfiguration->get('folders');
     if ($helperFolders) {
         $helperFolders = Tools::singleOrMultipleValuesToArray($helperFolders);
         foreach ($helperFolders as $helperFolder) {
             AutoLoader::registerNamespace('', $this->basePath . $helperFolder);
         }
     }
     foreach ($helperConfiguration->configuration as $helperId => $helper) {
         if ($helperId == 'folders') {
             continue;
         }
         $helperConfig = new Configuration($helper);
         $helperClass = $helperConfig->getString('type');
         if (!$helperClass || !$helperConfig->getBool('enabled', true)) {
             continue;
         }
         /** @var Helper $helper */
         $helper = new $helperClass($this, $helperConfig, $job, $helperId);
         $helper->init();
         $job->helpers[$helperId] = $helper;
     }
     $job->events->trigger(self::E_HELPERS_LOADED);
 }
Beispiel #2
0
 public function importPluginNamespace($type)
 {
     // Add plugin path to auto loading
     if (!class_exists('Grout\\' . $type)) {
         $directory = $this->path . 'plugins/' . str_replace('\\', '/', $type) . '/';
         AutoLoader::registerNamespace('Grout\\' . $type . '\\', $directory);
         AutoLoader::registerNamespace('Grout\\' . $type . '\\', $directory . 'source/');
     }
 }
Beispiel #3
0
use Cyantree\Grout\AutoLoader;
// Catch startup error
$startupError = error_get_last();
while (ob_get_level()) {
    ob_end_clean();
}
$isConsole = php_sapi_name() == 'cli';
// Update configuration to fit your setup
$basePath = realpath(dirname(__FILE__)) . '/';
$init = array('frameworkPath' => $basePath, 'dataPath' => $basePath . 'data/', 'bootstrap' => array('module' => 'AppModule', 'config' => array('config' => null)));
chdir($init['frameworkPath']);
// Init auto loader
require_once $init['frameworkPath'] . 'vendor/autoload.php';
AutoLoader::init();
if (is_dir('source/')) {
    AutoLoader::registerNamespace('', 'source/');
}
// Setup request and application
App::initEnvironment();
$app = new App();
$app->dataPath = $init['dataPath'];
if ($isConsole) {
    $bootstrap = new ConsoleBootstrap($app);
    $bootstrap->frameworkPath = $init['frameworkPath'];
    $request = $bootstrap->init();
} else {
    $bootstrap = new Bootstrap($app);
    $bootstrap->frameworkPath = $init['frameworkPath'];
    $bootstrap->usesModRewrite = true;
    $bootstrap->checkForMagicQuotes = true;
    $request = $bootstrap->init();