コード例 #1
0
 /**
  * Search files that may contain translatable strings
  *
  * @return void
  */
 protected function _searchFiles()
 {
     $pattern = false;
     if (!empty($this->_exclude)) {
         $exclude = [];
         foreach ($this->_exclude as $e) {
             if (DS !== '\\' && $e[0] !== DS) {
                 $e = DS . $e;
             }
             $exclude[] = preg_quote($e, '/');
         }
         $pattern = '/' . implode('|', $exclude) . '/';
     }
     foreach ($this->_paths as $path) {
         $Folder = new Folder($path);
         $files = $Folder->findRecursive('.*\\.(php|ctp|thtml|inc|tpl)', true);
         if (!empty($pattern)) {
             foreach ($files as $i => $file) {
                 if (preg_match($pattern, $file)) {
                     unset($files[$i]);
                 }
             }
             $files = array_values($files);
         }
         $this->_files = array_merge($this->_files, $files);
     }
 }
コード例 #2
0
 /**
  * testFindRecursive method
  *
  * @return void
  */
 public function testFindRecursive()
 {
     $Folder = new Folder(CAKE);
     $result = $Folder->findRecursive('(config|paths)\\.php');
     $expected = array(CAKE . 'Config' . DS . 'config.php');
     $this->assertSame(array(), array_diff($expected, $result));
     $this->assertSame(array(), array_diff($expected, $result));
     $result = $Folder->findRecursive('(config|woot)\\.php', true);
     $expected = array(CAKE . 'Config' . DS . 'config.php');
     $this->assertSame($expected, $result);
     $path = TMP . 'tests' . DS;
     $Folder = new Folder($path, true);
     $Folder->create($path . 'sessions');
     $Folder->create($path . 'testme');
     $Folder->cd($path . 'testme');
     $File = new File($Folder->pwd() . DS . 'paths.php');
     $File->create();
     $Folder->cd($path . 'sessions');
     $result = $Folder->findRecursive('paths\\.php');
     $expected = array();
     $this->assertSame($expected, $result);
     $Folder->cd($path . 'testme');
     $File = new File($Folder->pwd() . DS . 'my.php');
     $File->create();
     $Folder->cd($path);
     $result = $Folder->findRecursive('(paths|my)\\.php');
     $expected = array($path . 'testme' . DS . 'my.php', $path . 'testme' . DS . 'paths.php');
     $this->assertSame(sort($expected), sort($result));
     $result = $Folder->findRecursive('(paths|my)\\.php', true);
     $expected = array($path . 'testme' . DS . 'my.php', $path . 'testme' . DS . 'paths.php');
     $this->assertSame($expected, $result);
 }