public function setUp()
 {
     parent::setUp();
     $this->alternateBasePath = $this->getCurrentAbsolutePath() . "/_fakewebroot";
     Config::inst()->update('SilverStripe\\Control\\Director', 'alternate_base_folder', $this->alternateBasePath);
     $this->alternateBaseSavePath = TEMP_FOLDER . '/i18nTextCollectorTest_webroot';
     Filesystem::makeFolder($this->alternateBaseSavePath);
     // Push a class and template loader running from the fake webroot onto
     // the stack.
     $this->manifest = new ClassManifest($this->alternateBasePath, false, true, false);
     // Replace old template loader with new one with alternate base path
     $this->_oldLoader = ThemeResourceLoader::instance();
     ThemeResourceLoader::set_instance(new ThemeResourceLoader($this->alternateBasePath));
 }
Exemplo n.º 2
0
 public function setUp()
 {
     parent::setUp();
     $this->alternateBasePath = $this->getCurrentAbsolutePath() . DIRECTORY_SEPARATOR . "_fakewebroot";
     $this->alternateBaseSavePath = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'i18nTextCollectorTest_webroot';
     FileSystem::makeFolder($this->alternateBaseSavePath);
     Config::inst()->update('Director', 'alternate_base_folder', $this->alternateBasePath);
     // Replace old template loader with new one with alternate base path
     $this->_oldLoader = ThemeResourceLoader::instance();
     ThemeResourceLoader::set_instance($loader = new ThemeResourceLoader($this->alternateBasePath));
     $loader->addSet('$default', new ThemeManifest($this->alternateBasePath, project(), false, true));
     $this->_oldTheme = Config::inst()->get('SSViewer', 'theme');
     Config::inst()->update('SSViewer', 'theme', 'testtheme1');
     $this->originalLocale = i18n::get_locale();
     // Override default adapter to avoid cached translations between tests.
     // Emulates behaviour in i18n::get_translators()
     $this->origAdapter = i18n::get_translator('core');
     $adapter = new Zend_Translate(array('adapter' => 'i18nRailsYamlAdapter', 'locale' => i18n::default_locale(), 'disableNotices' => true));
     i18n::register_translator($adapter, 'core');
     $adapter->removeCache();
     i18n::include_by_locale('en');
 }
 /**
  * @param string $identifier A template name without '.ss' extension or path
  * @param string $type The template type, either "main", "Includes" or "Layout"
  *
  * @return string Full system path to a template file
  */
 public static function getTemplateFileByType($identifier, $type = null)
 {
     return ThemeResourceLoader::instance()->findTemplate(['type' => $type, $identifier], self::get_themes());
 }
 /**
  * Pushes a class and template manifest instance that include tests onto the
  * top of the loader stacks.
  */
 public static function use_test_manifest()
 {
     $flush = true;
     if (isset($_GET['flush']) && $_GET['flush'] === '0') {
         $flush = false;
     }
     $classManifest = new SS_ClassManifest(BASE_PATH, true, $flush);
     SS_ClassLoader::instance()->pushManifest($classManifest, false);
     SapphireTest::set_test_class_manifest($classManifest);
     ThemeResourceLoader::instance()->addSet('$default', new ThemeManifest(BASE_PATH, project(), true, $flush));
     Config::inst()->pushConfigStaticManifest(new SS_ConfigStaticManifest(BASE_PATH, true, $flush));
     // Invalidate classname spec since the test manifest will now pull out new subclasses for each internal class
     // (e.g. Member will now have various subclasses of DataObjects that implement TestOnly)
     DataObject::reset();
 }
 /**
  * Registers the given themeable javascript as required.
  *
  * A javascript file in the current theme path name 'themename/javascript/$name.js' is first searched for,
  * and it that doesn't exist and the module parameter is set then a javascript file with that name in
  * the module is used.
  *
  * @param string $name   The name of the file - eg '/js/File.js' would have the name 'File'
  * @param string $type  Comma-separated list of types to use in the script tag
  *                       (e.g. 'text/javascript,text/ecmascript')
  */
 public function themedJavascript($name, $type = null)
 {
     $path = ThemeResourceLoader::instance()->findThemedJavascript($name, SSViewer::get_themes());
     if ($path) {
         $opts = [];
         if ($type) {
             $opts['type'] = $type;
         }
         $this->javascript($path, $opts);
     } else {
         throw new \InvalidArgumentException("The javascript file doesn't exists. Please check if the file {$name}.js exists in any " . "context or search for themedJavascript references calling this file in your templates.");
     }
 }
 /**
  * Get location of all editor.css files
  *
  * @return array
  */
 protected function getEditorCSS()
 {
     $editor = array();
     // Add standard editor.css
     $editor[] = Director::absoluteURL(FRAMEWORK_ADMIN_DIR . '/client/dist/styles/editor.css');
     // Themed editor.css
     $themedEditor = ThemeResourceLoader::instance()->findThemedCSS('editor', SSViewer::get_themes());
     if ($themedEditor) {
         $editor[] = Director::absoluteURL($themedEditor, Director::BASE);
     }
     return $editor;
 }