示例#1
0
 /**
  * Override match()
  *
  * If matched, set the matches in the route
  *
  * @param array $params
  * @return array|null
  */
 public function match($params)
 {
     $matches = parent::match($params);
     if (is_array($matches)) {
         $this->matches = $matches;
     }
     return $matches;
 }
 /**
  * @dataProvider routeFiltersProvider
  * @param string $routeDefinition
  * @param array $filters
  * @param array $arguments
  * @param array $params
  */
 public function testParamsCanBeFiltered($routeDefinition, $filters, $arguments, $params)
 {
     $matcher = new DefaultRouteMatcher($routeDefinition, array(), array(), array(), $filters);
     $match = $matcher->match($arguments);
     if (null === $match) {
         $this->fail("Route '{$routeDefinition}' must match.'");
     }
     $this->assertInternalType('array', $match);
     foreach ($params as $key => $value) {
         $this->assertEquals($value, isset($match[$key]) ? $match[$key] : null, $value === null ? "Param {$key} is not present" : "Param {$key} is present and is equal to {$value}");
     }
 }
示例#3
0
 public function run($commandString = array())
 {
     if ($commandString) {
         if (!is_array($commandString)) {
             $commandString = 'models ' . $commandString;
         }
         $commandString = explode(' ', $commandString);
     } else {
         $commandString = $_SERVER['argv'];
     }
     if (count($commandString) < 2) {
         return $this->showUsage();
     }
     $params = new DefaultRouteMatcher("[--output-dir=] " . "[--deploy-dir=] " . "[--config=] " . "[--db-host=] " . "[--db-schema=]  " . "[--db-user=] " . "[--db-password=] " . "[--deploy=] " . "[--verbose] " . "[--help] " . "[--force] " . "[--erase] " . "[--cache-dir=] ");
     $argv = $commandString;
     array_shift($argv);
     $consoleParams = $params->match($argv);
     $host = isset($consoleParams['db-host']) ? $consoleParams['db-host'] : '127.0.0.1';
     $dbSchema = isset($consoleParams['db-schema']) ? $consoleParams['db-schema'] : 'test';
     $user = isset($consoleParams['db-user']) ? $consoleParams['db-user'] : '******';
     $password = isset($consoleParams['db-password']) ? $consoleParams['db-password'] : '';
     $dsn = "mysql:host=" . $host . ';' . 'dbname=' . $dbSchema . ';' . 'charset=utf8';
     $configParams = ArrayUtils::filterByOriginalArray($consoleParams, array('output-dir', 'deploy-dir', 'config', 'verbose', 'erase', 'force'));
     $config = new Config($configParams);
     $db = new Mysql($dsn, $user, $password);
     $generator = new Generator($config, $db);
     $generator->run();
 }