コード例 #1
0
 /**
  * Find the paths to all the installed shell themes in the app.
  *
  * Bake themes are directories not named `skel` inside a `Console/Templates` path.
  * They are listed in this order: app -> plugin -> default
  *
  * @return array Array of bake themes that are installed.
  */
 protected function _findThemes()
 {
     $paths = App::path('Console');
     $plugins = App::objects('plugin');
     foreach ($plugins as $plugin) {
         $paths[] = $this->_pluginPath($plugin) . 'Console/';
     }
     $core = current(App::core('Console'));
     $Folder = new Folder($core . 'Templates/default');
     $contents = $Folder->read();
     $themeFolders = $contents[0];
     $paths[] = $core;
     foreach ($paths as $i => $path) {
         $paths[$i] = rtrim($path, DS) . DS;
     }
     $this->_io->verbose('Found the following bake themes:');
     $themes = [];
     foreach ($paths as $path) {
         $Folder = new Folder($path . 'Templates', false);
         $contents = $Folder->read();
         $subDirs = $contents[0];
         foreach ($subDirs as $dir) {
             $Folder = new Folder($path . 'Templates/' . $dir);
             $contents = $Folder->read();
             $subDirs = $contents[0];
             if (array_intersect($contents[0], $themeFolders)) {
                 $templateDir = $path . 'Templates/' . $dir . DS;
                 $themes[$dir] = $templateDir;
                 $this->_io->verbose(sprintf("- %s -> %s", $dir, $templateDir));
             }
         }
     }
     return $themes;
 }
コード例 #2
0
ファイル: TestSuite.php プロジェクト: ripzappa0924/carte0.0.1
 /**
  * Adds all the files in a directory to the test suite. Does not recurse through directories.
  *
  * @param string $directory The directory to add tests from.
  * @return void
  */
 public function addTestDirectory($directory = '.')
 {
     $Folder = new Folder($directory);
     list(, $files) = $Folder->read(true, true, true);
     foreach ($files as $file) {
         if (substr($file, -4) === '.php') {
             $this->addTestFile($file);
         }
     }
 }
コード例 #3
0
 /**
  * testFolderReadWithHiddenFiles method
  *
  * @return void
  */
 public function testFolderReadWithHiddenFiles()
 {
     $this->skipIf(!is_writable(TMP), 'Cant test Folder::read with hidden files unless the tmp folder is writable.');
     $path = TMP . 'tests/';
     $Folder = new Folder($path . 'folder_tree_hidden', true, 0777);
     mkdir($Folder->path . DS . '.svn');
     mkdir($Folder->path . DS . 'some_folder');
     touch($Folder->path . DS . 'not_hidden.txt');
     touch($Folder->path . DS . '.hidden.txt');
     $expected = array(array('some_folder'), array('not_hidden.txt'));
     $result = $Folder->read(true, true);
     $this->assertEquals($expected, $result);
     $expected = array(array('.svn', 'some_folder'), array('.hidden.txt', 'not_hidden.txt'));
     $result = $Folder->read(true);
     $this->assertEquals($expected, $result);
 }
コード例 #4
0
ファイル: TestTask.php プロジェクト: ripzappa0924/carte0.0.1
 /**
  * Get the possible classes for a given type.
  *
  * @param string $namespace The namespace fragment to look for classes in.
  * @return array
  */
 protected function _getClassOptions($namespace)
 {
     $classes = [];
     $base = APP;
     if ($this->plugin) {
         $base = Plugin::path($this->plugin);
     }
     $path = $base . str_replace('\\', DS, $namespace);
     $folder = new Folder($path);
     list($dirs, $files) = $folder->read();
     foreach ($files as $file) {
         $classes[] = str_replace('.php', '', $file);
     }
     return $classes;
 }