예제 #1
0
파일: Mosaic.php 프로젝트: cyantree/mosaic
 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);
 }
예제 #2
0
파일: App.php 프로젝트: cyantree/grout
 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/');
     }
 }
예제 #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();
예제 #4
0
파일: mosaic.php 프로젝트: cyantree/mosaic
<?php

use Cyantree\Grout\AutoLoader;
use Cyantree\Grout\Filter\ArrayFilter;
use Cyantree\Mosaic\Outputs\ReadableOutput;
use Cyantree\Mosaic\Outputs\JsonOutput;
use Cyantree\Mosaic\Mosaic;
require_once __DIR__ . '/../../../autoload.php';
ini_set('memory_limit', '1024M');
AutoLoader::init();
$options = new ArrayFilter(getopt('f:c:j:o:', ['debug']));
$outputMode = $options->get('o', 'readable');
$s = new Mosaic();
$s->debug = $options->has('debug');
$s->basePath = realpath(dirname($options->needs('f'))) . '/';
$s->applicationPath = __DIR__ . '/../src/';
$s->configuration->load($options->needs('f'));
if ($options->has('c')) {
    $s->configuration->extend(json_decode(rawurldecode($options->get('c'))));
}
if ($options->has('j')) {
    $includedJobs = explode(',', $options->get('j'));
} else {
    $includedJobs = null;
}
$jobs = $s->compile($includedJobs);
switch ($outputMode) {
    case 'json':
        $output = new JsonOutput();
        break;
    default: