コード例 #1
0
ファイル: FileHelperTest.php プロジェクト: nagyist/tao-core
 public function testRelPath()
 {
     $testDir = tao_helpers_File::createTempDir();
     $this->assertTrue(mkdir($testDir . 'sub' . DIRECTORY_SEPARATOR));
     $path = $testDir . 'sub';
     $this->assertEquals('sub', \tao_helpers_File::getRelPath($testDir, $path));
     $path = $testDir . 'sub' . DIRECTORY_SEPARATOR;
     $this->assertEquals('..' . DIRECTORY_SEPARATOR, \tao_helpers_File::getRelPath($path, $testDir));
     $this->assertTrue(tao_helpers_File::delTree($testDir));
     $this->assertFalse(is_dir($testDir));
 }
コード例 #2
0
 /**
  * Adds sample code for theme support
  */
 protected function addSampleTheme()
 {
     // replacements
     $values = array('{themeLabel}' => $this->label . ' default theme', '{themeId}' => StringUtils::camelize($this->label . ' default theme'), '{platformTheme}' => StringUtils::camelize($this->label . ' default theme', true));
     $pathValues = array();
     foreach ($values as $key => $value) {
         $pathValues[trim($key, '{}')] = $value;
     }
     // copy templates
     $samplePath = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDevTools')->getDir() . 'models' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
     $paths = array(array('model', 'theme', '*.sample'), array('scripts', 'install', '*.sample'), array('views', 'templates', 'themes', 'platform', 'themeId', '*.sample'), array('views', 'scss', 'themes', 'items', '*.sample'), array('views', 'scss', 'themes', 'platform', 'themeId', '*.sample'));
     $templates = array();
     foreach ($paths as $path) {
         $templates = array_merge($templates, glob($samplePath . implode(DIRECTORY_SEPARATOR, $path)));
     }
     foreach ($templates as $template) {
         $template = \tao_helpers_File::getRelPath($samplePath, $template);
         $template = substr($template, 0, strrpos($template, '.'));
         $this->copyFile($template, str_replace(array_keys($pathValues), $pathValues, $template), $values);
     }
 }