Moved the |media twig filter from the CMS module to the System module

This commit is contained in:
Luke Towers 2017-09-27 22:15:01 -06:00
parent de747f98b3
commit 08f9cd8448
3 changed files with 12 additions and 21 deletions

View File

@ -1191,16 +1191,6 @@ class Controller
return $_url;
}
/**
* Converts supplied file to a URL relative to the media library.
* @param string $file Specifies the media-relative file
* @return string
*/
public function mediaUrl($file = null)
{
return MediaLibrary::url($file);
}
/**
* Returns a routing parameter.
* @param string $name Routing parameter name.

View File

@ -59,7 +59,6 @@ class Extension extends Twig_Extension
return [
new Twig_SimpleFilter('page', [$this, 'pageFilter'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('theme', [$this, 'themeFilter'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('media', [$this, 'mediaFilter'], ['is_safe' => ['html']]),
];
}
@ -176,16 +175,6 @@ class Extension extends Twig_Extension
return $this->controller->themeUrl($url);
}
/**
* Converts supplied file to a URL relative to the media library.
* @param string $file Specifies the media-relative file
* @return string
*/
public function mediaFilter($file)
{
return $this->controller->mediaUrl($file);
}
/**
* Opens a layout block.
* @param string $name Specifies the block name

View File

@ -6,6 +6,7 @@ use Twig_TokenParser;
use Twig_SimpleFilter;
use Twig_SimpleFunction;
use ApplicationException;
use System\Classes\MediaLibary;
use System\Classes\MarkupManager;
/**
@ -56,6 +57,7 @@ class Extension extends Twig_Extension
{
$filters = [
new Twig_SimpleFilter('app', [$this, 'appFilter'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('media', [$this, 'mediaFilter'], ['is_safe' => ['html']]),
];
/*
@ -92,4 +94,14 @@ class Extension extends Twig_Extension
{
return Url::to($url);
}
/**
* Converts supplied file to a URL relative to the media library.
* @param string $file Specifies the media-relative file
* @return string
*/
public function mediaFilter($file)
{
return MediaLibrary::url($file);
}
}