Beispiel #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $arr = array();
     $names = array();
     $collections = false;
     if (is_dir(DIR_REPOSITORY)) {
         $it = new \FilesystemIterator(DIR_REPOSITORY, \FilesystemIterator::SKIP_DOTS);
         while ($it->valid()) {
             if (!$it->isDot() && !$it->isDir()) {
                 $nm = $it->getBasename('.php');
                 $cl = '\\Repository\\' . $nm;
                 if (class_exists($cl)) {
                     $names[] = $nm;
                     $arr[] = "  /** @return {$cl} */\n" . "  public function " . StaticStringy::camelize($nm) . "()\n" . "  {\n" . "    return \$this->getRepository('{$nm}');\n" . "  }";
                     $collections .= "    \$this->setRepositoryClass('{$nm}', '{$cl}');\n";
                 }
             }
             $it->next();
         }
     }
     $code = "<?php\n\nnamespace Base;\n\n" . "/** Этот файл сгенерирован автоматически командой db:manager */\n" . "class Manager extends \\SQRT\\DB\\Manager\n{\n" . "  function __construct()\n" . "  {\n" . "    \$this->addConnection(DB_HOST, DB_USER, DB_PASS, DB_NAME);\n" . "    \$this->setPrefix(PREFIX);\n" . ($collections ? "\n" . $collections : '') . "  }\n\n" . join("\n\n", $arr) . "\n" . "}";
     $file = DIR_APP . '/Base/Manager.php';
     file_put_contents($file, $code);
     if (!empty($names)) {
         $output->writeln(sprintf('<info>Менеджер БД обновлен, список коллекций: %s</info>', join(', ', $names)));
     } else {
         $output->writeln('<info>Первичная инициализация менеджера БД</info>');
     }
 }
Beispiel #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $db = new \Base\Manager();
     $limit = 10;
     $arr = array();
     if (is_dir(DIR_SCHEMA)) {
         $it = new \FilesystemIterator(DIR_SCHEMA, \FilesystemIterator::SKIP_DOTS);
         while ($it->valid()) {
             if (!$it->isDot() && !$it->isDir()) {
                 $nm = $it->getBasename('.php');
                 $cl = 'Schema\\' . $nm;
                 if (class_exists($cl)) {
                     $arr[$nm] = new $cl($db);
                 }
             }
             $it->next();
         }
     }
     $db->query('DROP TABLE IF EXISTS ' . $db->getPrefix() . 'phinxlog');
     while ($limit--) {
         /** @var $schema Schema */
         foreach ($arr as $nm => $schema) {
             try {
                 $db->query('DROP TABLE IF EXISTS ' . $db->getPrefix() . $schema->getTable());
                 $output->writeln(sprintf('<info>Таблица %s сброшена</info>', $nm));
                 unset($arr[$nm]);
             } catch (\Exception $e) {
             }
         }
         if (empty($arr)) {
             $output->writeln(sprintf('<info>Все таблицы сброшены.</info>'));
             break;
         }
     }
 }
 /**
  * @param string $dir
  */
 public static function addResourceDir($dir)
 {
     if (in_array($dir, static::$dirs)) {
         return;
     }
     $iterator = new \FilesystemIterator($dir, \FilesystemIterator::SKIP_DOTS);
     foreach ($iterator as $value) {
         if (!$iterator->isFile()) {
             continue;
         }
         list($domain, $locale, $format) = explode('.', $iterator->getBasename(), 3);
         static::$translator->addResource($format, $iterator->getRealPath(), $locale, $domain);
     }
     static::$dirs[] = $dir;
 }
Beispiel #4
0
<!DOCTYPE html>
<html>
<head>
	<title>Aulas do Wallace Maxters</title>
</head>
<body>
	<h1>Aulas do Wallace Maxters  - Iterator</h1>
	<code>
	<?php 
$files = new FilesystemIterator(__DIR__, FilesystemIterator::CURRENT_AS_SELF);
foreach ($files as $fullpath => $value) {
    if ($fullpath === __FILE__ || $files->isDir()) {
        continue;
    }
    echo "<a href={$value}>{$files->getBasename()}</a><br/>";
}
?>
	</code>
</body>
</html>