Module: Deprecate asset support

This commit is contained in:
Johannes Meyer 2020-11-17 11:13:21 +01:00
parent a370a99fb4
commit be99703a67
1 changed files with 17 additions and 0 deletions

View File

@ -560,10 +560,16 @@ class Module
* @param string $path The file's path, relative to the module's asset or base directory * @param string $path The file's path, relative to the module's asset or base directory
* @param string $from The module's name * @param string $from The module's name
* *
* @deprecated Deprecated with v2.9, don't use and depend on a library instead
* @return $this * @return $this
*/ */
protected function requireCssFile($path, $from) protected function requireCssFile($path, $from)
{ {
Logger::warning(
'Module assets are deprecated since v2.9. Please check if the module "%s" provides a library instead.',
$from
);
$module = self::get($from); $module = self::get($from);
$cssAssetDir = join(DIRECTORY_SEPARATOR, [$module->assetDir, 'css']); $cssAssetDir = join(DIRECTORY_SEPARATOR, [$module->assetDir, 'css']);
foreach ($module->getCssAssets() as $assetPath) { foreach ($module->getCssAssets() as $assetPath) {
@ -638,10 +644,16 @@ class Module
* @param string $path The file's path, relative to the module's asset or base directory * @param string $path The file's path, relative to the module's asset or base directory
* @param string $from The module's name * @param string $from The module's name
* *
* @deprecated Deprecated with v2.9, don't use and depend on a library instead
* @return $this * @return $this
*/ */
protected function requireJsFile($path, $from) protected function requireJsFile($path, $from)
{ {
Logger::warning(
'Module assets are deprecated since v2.9. Please check if the module "%s" provides a library instead.',
$from
);
$module = self::get($from); $module = self::get($from);
$jsAssetDir = join(DIRECTORY_SEPARATOR, [$module->assetDir, 'js']); $jsAssetDir = join(DIRECTORY_SEPARATOR, [$module->assetDir, 'js']);
foreach ($module->getJsAssets() as $assetPath) { foreach ($module->getJsAssets() as $assetPath) {
@ -1386,6 +1398,11 @@ class Module
return $this; return $this;
} }
Logger::warning(
'Module assets are deprecated since v2.9. Please provide a library'
. ' for the parts you want to make available to other modules.'
);
$listAssets = function ($type) { $listAssets = function ($type) {
$dir = join(DIRECTORY_SEPARATOR, [$this->assetDir, $type]); $dir = join(DIRECTORY_SEPARATOR, [$this->assetDir, $type]);
if (! is_dir($dir)) { if (! is_dir($dir)) {