mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #7461 from open-sausages/pulls/4.0/fix-icon-urls
Fix references to resource paths / urls
This commit is contained in:
commit
7afab3043d
@ -4,6 +4,7 @@ namespace SilverStripe\Core\Manifest;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\View\TemplateGlobalProvider;
|
||||
|
||||
/**
|
||||
@ -22,6 +23,10 @@ class ModuleResourceLoader implements TemplateGlobalProvider
|
||||
*/
|
||||
public function resolvePath($resource)
|
||||
{
|
||||
// Skip blank resources
|
||||
if (empty($resource)) {
|
||||
return null;
|
||||
}
|
||||
$resourceObj = $this->resolveResource($resource);
|
||||
if ($resourceObj instanceof ModuleResource) {
|
||||
return $resourceObj->getRelativePath();
|
||||
@ -37,11 +42,18 @@ class ModuleResourceLoader implements TemplateGlobalProvider
|
||||
*/
|
||||
public function resolveURL($resource)
|
||||
{
|
||||
$resourceObj = $this->resolveResource($resource);
|
||||
if ($resourceObj instanceof ModuleResource) {
|
||||
return $resourceObj->getURL();
|
||||
// Skip blank resources
|
||||
if (empty($resource)) {
|
||||
return null;
|
||||
}
|
||||
return $resource;
|
||||
|
||||
// Resolve resource to reference
|
||||
$resource = $this->resolveResource($resource);
|
||||
|
||||
// Resolve resource to url
|
||||
/** @var ResourceURLGenerator $generator */
|
||||
$generator = Injector::inst()->get(ResourceURLGenerator::class);
|
||||
return $generator->urlForResource($resource);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,9 +40,8 @@ class CMSSecurity extends Security
|
||||
SSViewer::set_themes(LeftAndMain::config()->uninherited('admin_themes'));
|
||||
|
||||
// Core styles / vendor scripts
|
||||
$admin = ModuleLoader::getModule('silverstripe/admin');
|
||||
Requirements::javascript($admin->getRelativeResourcePath('client/dist/js/vendor.js'));
|
||||
Requirements::css($admin->getRelativeResourcePath('client/dist/styles/bundle.css'));
|
||||
Requirements::javascript('silverstripe/admin: client/dist/js/vendor.js');
|
||||
Requirements::css('silverstripe/admin: client/dist/styles/bundle.css');
|
||||
}
|
||||
|
||||
public function login($request = null, $service = Authenticator::CMS_LOGIN)
|
||||
|
@ -989,6 +989,8 @@ class Requirements_Backend
|
||||
*/
|
||||
public function add_i18n_javascript($langDir, $return = false)
|
||||
{
|
||||
$langDir = ModuleResourceLoader::singleton()->resolvePath($langDir);
|
||||
|
||||
$files = array();
|
||||
$base = Director::baseFolder() . '/';
|
||||
|
||||
|
@ -11,6 +11,7 @@ use SilverStripe\Assets\Tests\Storage\AssetStoreTest\TestAssetStore;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Manifest\ModuleLoader;
|
||||
use SilverStripe\Core\Manifest\ModuleManifest;
|
||||
use SilverStripe\Core\Manifest\ModuleResourceLoader;
|
||||
use SilverStripe\Dev\CSSContentParser;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
|
||||
@ -68,12 +69,9 @@ class HTMLEditorFieldTest extends FunctionalTest
|
||||
public function testCasting()
|
||||
{
|
||||
// Shim TinyMCE so silverstripe/admin doesn't have to be installed
|
||||
$framework = ModuleLoader::getModule('silverstripe/framework');
|
||||
TinyMCEConfig::config()->set(
|
||||
'base_dir',
|
||||
$framework->getRelativeResourcePath(
|
||||
'tests/php/Forms/HTMLEditor/TinyMCECombinedGeneratorTest/tinymce'
|
||||
)
|
||||
'silverstripe/framework: tests/php/Forms/HTMLEditor/TinyMCECombinedGeneratorTest/tinymce'
|
||||
);
|
||||
HtmlEditorField::config()->set('use_gzip', false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user