Merge pull request #6583 from robbieaverill/bugfix/remove-theme-dir

API Remove ViewableData::ThemeDir, update changelog to reflect suggested replacement
This commit is contained in:
Damian Mooyman 2017-02-02 12:57:20 +13:00 committed by GitHub
commit 8d5ff9b2fe
3 changed files with 21 additions and 35 deletions

View File

@ -211,13 +211,17 @@ and production environments.
You can also combine CSS files into a media-specific stylesheets as you would with the `Requirements::css` call - use
the third paramter of the `combine_files` function:
:::php
$printStylesheets = array(
"$themeDir/css/print_HomePage.css",
"$themeDir/css/print_Page.css",
);
```php
$loader = ThemeResourceLoader::instance();
$themes = SSViewer::get_themes();
Requirements::combine_files('print.css', $printStylesheets, 'print');
$printStylesheets = array(
$loader->findThemedCSS('print_HomePage.css', $themes),
$loader->findThemedCSS('print_Page.css', $themes)
);
Requirements::combine_files('print.css', $printStylesheets, 'print');
```
By default, all requirements files are flushed (deleted) when ?flush querystring parameter is set.
This can be disabled by setting the `Requirements.disable_flush_combined` config to `true`.
@ -232,13 +236,17 @@ the destination location of the resulting combined CSS.
You can also add the 'async' and/or 'defer' attributes to combined Javascript files as you would with the
`Requirements::javascript` call - use the third paramter of the `combine_files` function:
:::php
$scripts = array(
"$themeDir/javascript/some_script.js",
"$themeDir/javascript/some_other_script.js",
);
```php
$loader = ThemeResourceLoader::instance();
$themes = SSViewer::get_themes();
Requirements::combine_files('scripts.js', $scripts, array('async' => true, 'defer' => true));
$scripts = array(
$loader->findThemedJavascript('some_script.js', $themes),
$loader->findThemedJavascript('some_other_script.js', $themes)
);
Requirements::combine_files('scripts.js', $scripts, array('async' => true, 'defer' => true));
```
## Clearing assets

View File

@ -976,6 +976,7 @@ specific functions.
[oscarotero/Embed](https://github.com/oscarotero/Embed) as a dependency.
* Removed TextParser and BBCodeParser. These are available in an archived module,
[silverstripe-archive/bbcodeparser](https://github.com/silverstripe-archive/silverstripe-bbcodeparser)
* Removed `ViewableData::ThemeDir`. Use `ThemeResourceLoader::findThemedResource` in conjunction with `SSViewer::get_themes` instead.
#### <a name="overview-general-deprecated"></a>General and Core Deprecated API

View File

@ -546,29 +546,6 @@ class ViewableData extends Object implements IteratorAggregate
return $this;
}
/**
* Return the directory if the current active theme (relative to the site root).
*
* This method is useful for things such as accessing theme images from your template without hardcoding the theme
* page - e.g. <img src="$ThemeDir/images/something.gif">.
*
* This method should only be used when a theme is currently active. However, it will fall over to the current
* project directory.
*
* @param string $subtheme the subtheme path to get
* @return string
*/
public function ThemeDir($subtheme = null)
{
if (Config::inst()->get('SilverStripe\\View\\SSViewer', 'theme_enabled')
&& $theme = Config::inst()->get('SilverStripe\\View\\SSViewer', 'theme')
) {
return THEMES_DIR . "/$theme" . ($subtheme ? "_$subtheme" : null);
}
return project();
}
/**
* Get part of the current classes ancestry to be used as a CSS class.
*