protected function getSubDirectoriesInfos($rootDir, $infoFilename)
 {
     if ($rootDir[0] == '~') {
         if (DIRECTORY_SEPARATOR == '\\') {
             $rootDir = $_SERVER['USERPROFILE'] . substr($rootDir, 1);
         } else {
             $rootDir = $_SERVER['HOME'] . substr($rootDir, 1);
         }
     }
     $infos = array();
     $it = new \FilesystemIterator($rootDir);
     foreach ($it as $subDir) {
         if ($it->isDot() || !$it->isDir()) {
             continue;
         }
         $defaultInfo = array('name' => $subDir->getFilename(), 'description' => '', 'dir' => $subDir->getPathname(), 'source' => $subDir->getPathname());
         $infoPath = $subDir->getPathname() . DIRECTORY_SEPARATOR . $infoFilename;
         if (is_file($infoPath)) {
             $infos[] = array_merge($defaultInfo, Yaml::parse($infoPath));
         } else {
             $infos[] = $defaultInfo;
         }
     }
     return $infos;
 }
Beispiel #2
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 #3
0
 /**
  * Register the routes
  * 
  * @return \App
  */
 public function setRoutes()
 {
     $routesFiles = array();
     if (file_exists($routesFolder = $this->getAppDir() . '/config/routes')) {
         $fsi = new \FilesystemIterator($routesFolder);
         while ($fsi->valid()) {
             if ($fsi->isDir()) {
                 $ffsi = new \FilesystemIterator($routesFolder . '/' . $fsi->getFilename());
                 while ($ffsi->valid()) {
                     if (preg_match('/[a-zA-Z0-9_]+\\.php/i', $ffsi->getFilename())) {
                         $routesFiles[] = $routesFolder . '/' . $fsi->getFilename() . '/' . $ffsi->getFilename();
                     }
                     $ffsi->next();
                 }
             } else {
                 if (preg_match('/[a-zA-Z0-9_]+\\.php/i', $fsi->getFilename())) {
                     $routesFiles[] = $routesFolder . '/' . $fsi->getFilename();
                 }
             }
             $fsi->next();
         }
     }
     foreach ($this->setModules() as $module) {
         $extension = $module->getModuleExtension();
         if (is_object($extension) && $extension instanceof MVCExtension) {
             foreach ($extension->loadRoutes() as $routeModule) {
                 $routesFiles[] = $routeModule;
             }
         }
     }
     return $routesFiles;
 }
Beispiel #4
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;
         }
     }
 }
 /**
  * Load routes of the Module
  * 
  * @return array
  */
 public function loadRoutes()
 {
     $routesFiles = array();
     if (file_exists($routesFolder = $this->configDir . '/routes')) {
         $fsi = new \FilesystemIterator($routesFolder);
         while ($fsi->valid()) {
             if ($fsi->isDir()) {
                 $ffsi = new \FilesystemIterator($routesFolder . '/' . $fsi->getFilename());
                 while ($ffsi->valid()) {
                     if (preg_match('/[a-zA-Z0-9_]+\\.php/i', $ffsi->getFilename())) {
                         $routesFiles[] = $routesFolder . '/' . $fsi->getFilename() . '/' . $ffsi->getFilename();
                     }
                     $ffsi->next();
                 }
             } else {
                 if (preg_match('/[a-zA-Z0-9_]+\\.php/i', $fsi->getFilename())) {
                     $routesFiles[] = $routesFolder . '/' . $fsi->getFilename();
                 }
             }
             $fsi->next();
         }
     }
     return $routesFiles;
 }
Beispiel #6
0
 /**
  * Register the routes
  * 
  * @return \App
  */
 protected function registerRoutes()
 {
     # Local var required
     $app = $this->application;
     if (file_exists($routesFolder = $this->getAppDir() . '/config/routes')) {
         $fsi = new \FilesystemIterator($routesFolder);
         while ($fsi->valid()) {
             if ($fsi->isDir()) {
                 $ffsi = new \FilesystemIterator($routesFolder . '/' . $fsi->getFilename());
                 while ($ffsi->valid()) {
                     if (preg_match('/[a-zA-Z0-9_]+\\.php/i', $ffsi->getFilename())) {
                         require_once $routesFolder . '/' . $fsi->getFilename() . '/' . $ffsi->getFilename();
                     }
                     $ffsi->next();
                 }
             } else {
                 if (preg_match('/[a-zA-Z0-9_]+\\.php/i', $ffsi->getFilename())) {
                     require_once $routesFolder . '/' . $ffsi->getFilename();
                 }
             }
             $fsi->next();
         }
     }
     return $this;
 }
Beispiel #7
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>
Beispiel #8
0
<?php

/**
 * @package WordPress
 * @subpackage Greg_Foot
 *
 * SOURCE: http://wordpress.stackexchange.com/questions/1403/organizing-code-in-your-wordpress-themes-functions-php-file
 *
 * USEFUL LOCATIONS:
 * home_url()
 * plugin_dir_url()
 * plugin_dir_path()
 * admin_url()
 * get_template_directory()
 * get_template_directory_uri()
 * get_stylesheet_directory()
 * get_stylesheet_directory_uri()
 *
**/
// PHP 5.3+
$files = new \FilesystemIterator(__DIR__ . '/functions', \FilesystemIterator::SKIP_DOTS);
foreach ($files as $file) {
    /** @noinspection PhpIncludeInspection */
    if ($file->getFilename() == '.DS_Store') {
        continue;
    }
    !$files->isDir() and (include $files->getRealPath());
}