コード例 #1
0
ファイル: config.php プロジェクト: liammartens/xtend
    } else {
        die("Configuration key not found");
    }
});
/**
 * Sets a configuration value
 */
Workbench::register('^config ([a-zA-Z]+) (.*)$', function ($argv) {
    $key = $argv[1];
    $value = $argv[2];
    $conf = Core\App::config()->file('App.configuration.json');
    $configuration = json_decode($conf->read(), true);
    if (isset($configuration[$key])) {
        if ($value === 'true' || $value === 'false') {
            $value = boolval($value);
        } elseif (is_numeric($value)) {
            $value = intval($value);
        }
        $configuration[$key] = $value;
        $conf->write(json_encode($configuration));
        // if environment changes , update db.yml
        if ($key == 'environment') {
            $db_file = Core\App::config()->file('ORM.db.yml');
            $db = Spyc::YAMLLoad((string) $db_file);
            $db['environments']['default_database'] = $value;
            $db_file->write(Spyc::YAMLDump($db, 4, false, true));
        }
    } else {
        die("Configuration key not found");
    }
});
コード例 #2
0
ファイル: init.php プロジェクト: liammartens/xtend
<?php

namespace Application;

use xTend\Workbench\Workbench;
Workbench::register('^init$', function ($argv) {
    $configuration_file = Core\App::config()->file('Sessions.sessions.json');
    $configuration = json_decode($configuration_file->read(), true);
    // set values
    $configuration['sessionName'] = sha1(random_bytes(8));
    $configuration['initiatedKey'] = sha1(random_bytes(8));
    $configuration['userAgentKey'] = sha1(random_bytes(8));
    $configuration['salt'] = sha1(random_bytes(8));
    $configuration['userSessionsKey'] = sha1(random_bytes(8));
    $configuration['userCookiesKey'] = sha1(random_bytes(8));
    // write configuration
    $configuration_file->write(json_encode($configuration));
}, 'init');
Workbench::register('^init show$', function ($argv) {
    $configuration_file = Core\App::config()->file('Sessions.sessions.json');
    $configuration = json_decode($configuration_file->read(), true);
    echo "\n";
    foreach ($configuration as $key => $value) {
        echo str_pad($key, 30) . $value . "\n";
    }
    echo "\n";
}, 'init show');
コード例 #3
0
ファイル: wow.php プロジェクト: liammartens/xtend
<?php

namespace Application;

use xTend\Workbench\Workbench;
/**
 * Sets the wow flavor
 */
Workbench::register('wow:flavor (HTML|AT_SIGN|COMBINED)', function ($argv) {
    $file = Core\App::config()->file('Wow.Flavor.php');
    $file->write('<?php
    /**
    * Sets the current Wow flavor
    * and initializes the Wow engine
    */
    namespace ' . Workbench::namespace(Workbench::get('application')) . ';
    use ' . Workbench::namespace(Workbench::get('application')) . '\\Core\\Wow;
    Wow::flavor(Wow::' . $argv[1] . ');
    Wow::start();');
}, 'wow:flavor');
コード例 #4
0
ファイル: phinx.php プロジェクト: liammartens/xtend
/**
 * Executes phinx command
 *
 * @param $argv array
 */
Workbench::register('^phinx', function ($argv) {
    if (count($argv) > 1) {
        $config_param = false;
        foreach ($argv as $arg) {
            if (substr($arg, 0, 16) == '--configuration=' || $arg == '-c' || $arg == '--configuration') {
                $config_param = true;
                break;
            }
        }
        if ($config_param === false) {
            $argv[] = '-c';
            $argv[] = '' . Core\App::config()->file('ORM.db.yml');
        }
    }
    // create directory and exclude file
    $directory = Core\App::config()->directory('ORM.db');
    if (!$directory->exists()) {
        $directory->create();
    }
    $exclude_file = Core\App::config()->file('ORM.db..exclude', 1);
    if (!$exclude_file->exists()) {
        $exclude_file->write("");
    }
    $_SERVER['argv'] = $argv;
    require __DIR__ . '/../Phinx/robmorgan-phinx/bin/phinx';
});