Exemplo n.º 1
0
 public function setUp()
 {
     $this->testDatabase = 'yentu_rollback_test';
     parent::setup();
     $this->createDb($GLOBALS['DB_NAME']);
     $this->initDb($GLOBALS['DB_FULL_DSN'], file_get_contents("tests/sql/{$GLOBALS['DRIVER']}/pre_rollback.sql"));
     $this->connect($GLOBALS['DB_FULL_DSN']);
     $this->setupStreams();
     $init = new \yentu\commands\Init();
     $init->createConfigFile(array('driver' => $GLOBALS['DRIVER'], 'host' => $GLOBALS['DB_HOST'], 'dbname' => $GLOBALS["DB_NAME"], 'user' => $GLOBALS['DB_USER'], 'password' => $GLOBALS['DB_PASSWORD'], 'file' => $GLOBALS['DB_FILE']));
     Config::readPath(\yentu\Yentu::getPath('config'), 'yentu');
 }
Exemplo n.º 2
0
 public function run($options)
 {
     if (isset($options['config'])) {
         Config::readPath($options['config'], 'ajumamoro');
     }
     if ($options['daemon'] === true) {
         ClearIce::output("Starting ajumamoro daemon ... ");
         Logger::init(Config::get('ajumamoro:log_file', './ajumamoro.log'), 'ajumamoro');
         if ($this->checkExistingInstance() === false) {
             $pid = $this->startDaemon($options);
             ClearIce::output($pid > 0 ? "OK [PID:{$pid}]\n" : "Failed\n");
         } else {
             ClearIce::output("Failed\nAn instance already exists.\n");
         }
     } else {
         Logger::init('php://output', 'ajumamoro');
         Runner::mainLoop();
     }
 }
Exemplo n.º 3
0
 public static function init($namespace)
 {
     self::$namespace = $namespace;
     self::$prefix = Config::get('app.prefix');
     self::$prefix = (self::$prefix == '' ? '' : '/') . self::$prefix;
     self::setupAutoloader();
     logger\Logger::init('logs/app.log');
     Config::readPath(self::$configPath, 'ntentan');
     kaikai\Cache::init();
     panie\InjectionContainer::bind(ModelClassResolverInterface::class)->to(ClassNameResolver::class);
     panie\InjectionContainer::bind(ModelJoinerInterface::class)->to(ClassNameResolver::class);
     panie\InjectionContainer::bind(TableNameResolverInterface::class)->to(nibii\Resolver::class);
     panie\InjectionContainer::bind(ComponentResolverInterface::class)->to(ClassNameResolver::class);
     panie\InjectionContainer::bind(ControllerClassResolverInterface::class)->to(ClassNameResolver::class);
     panie\InjectionContainer::bind(controllers\RouterInterface::class)->to(DefaultRouter::class);
     if (Config::get('ntentan:db.driver')) {
         panie\InjectionContainer::bind(DriverAdapter::class)->to(Resolver::getDriverAdapterClassName());
         panie\InjectionContainer::bind(atiaa\Driver::class)->to(atiaa\Db::getDefaultDriverClassName());
     }
     Controller::setComponentResolverParameters(['type' => 'component', 'namespaces' => [$namespace, 'controllers\\components']]);
     nibii\RecordWrapper::setComponentResolverParameters(['type' => 'behaviour', 'namespaces' => [$namespace, 'nibii\\behaviours']]);
     controllers\ModelBinderRegister::setDefaultBinderClass(controllers\model_binders\DefaultModelBinder::class);
     controllers\ModelBinderRegister::register(utils\filesystem\UploadedFile::class, controllers\model_binders\UploadedFileBinder::class);
 }
Exemplo n.º 4
0
Arquivo: cli.php Projeto: codogh/yentu
ClearIce::setFootnote("Report bugs to jainooson@gmail.com");
ClearIce::setUsage("[command] [options]");
ClearIce::addHelp();
ClearIce::setStrict(true);
$options = ClearIce::parse();
if (isset($options['verbose'])) {
    ClearIce::setOutputLevel($options['verbose']);
}
try {
    if (isset($options['__command__'])) {
        if (isset($options['home'])) {
            Yentu::setDefaultHome($options['home']);
        }
        $class = "\\yentu\\commands\\" . ucfirst($options['__command__']);
        unset($options['__command__']);
        Config::readPath(Yentu::getPath('config'), 'yentu');
        $command = new $class();
        $command->run($options);
    } else {
        ClearIce::output(ClearIce::getHelpMessage());
    }
} catch (\yentu\exceptions\CommandException $e) {
    ClearIce::resetOutputLevel();
    ClearIce::error("Error! " . $e->getMessage() . "\n");
} catch (\ntentan\atiaa\exceptions\DatabaseDriverException $e) {
    ClearIce::resetOutputLevel();
    ClearIce::error("Database driver failed: " . $e->getMessage() . "\n");
    Yentu::reverseCommand($command);
} catch (\yentu\exceptions\DatabaseManipulatorException $e) {
    ClearIce::resetOutputLevel();
    ClearIce::error("Failed to perform database action: " . $e->getMessage() . "\n");
Exemplo n.º 5
0
 public function run($options = array())
 {
     Yentu::greet();
     if (file_exists(Yentu::getPath(''))) {
         throw new CommandException("Could not initialize yentu. Your project has already been initialized with yentu.");
     } else {
         if (!is_writable(dirname(Yentu::getPath('')))) {
             throw new CommandException("Your current directory is not writable.");
         }
     }
     $params = $this->getParams($options);
     if (count($params) == 0 && defined('STDOUT')) {
         global $argv;
         throw new CommandException("You didn't provide any parameters for initialization. Please execute " . "`{$argv[0]} init -i` to initialize yentu interractively. " . "You can also try `{$argv[0]} init --help` for more information.");
     }
     $this->createConfigFile($params);
     Config::readPath(Yentu::getPath('config'), 'yentu');
     $db = \yentu\DatabaseManipulator::create($params);
     if ($db->getAssertor()->doesTableExist('yentu_history')) {
         throw new CommandException("Could not initialize yentu. Your database has already been initialized with yentu.");
     }
     $db->createHistory();
     $db->disconnect();
     ClearIce::output("Yentu successfully initialized.\n");
 }
Exemplo n.º 6
0
 public function testConfigFile()
 {
     Config::readPath(__DIR__ . '/../fixtures/config/file.php');
     $this->assertEquals(true, Config::get('dump'));
 }