Commit 46a9d175 authored by Patrick Müller's avatar Patrick Müller

feat: global flag to disable media cache creation cms-import#15

parent ad3aaa01
......@@ -37,6 +37,16 @@ class Media extends QUI\QDOM
*/
protected static $mediaPermissions = null;
/**
* This flag indicates if the creation of media item/folder cache is disabled
* when createCache() is called.
*
* This should only be set to true if a lot of media items are created (e.g. in a mass import).
*
* @var bool
*/
public static $globalDisableMediaCacheCreation = false;
/**
* constructor
*
......
......@@ -7,6 +7,7 @@
namespace QUI\Projects\Media;
use QUI;
use QUI\Projects\Media;
/**
* Class ExternalImage
......@@ -147,6 +148,10 @@ class ExternalImage implements QUI\Interfaces\Projects\Media\File
*/
public function createCache()
{
if (Media::$globalDisableMediaCacheCreation) {
return false;
}
return $this->createSizeCache();
}
......
......@@ -7,6 +7,7 @@
namespace QUI\Projects\Media;
use QUI;
use QUI\Projects\Media;
use QUI\Utils\System\File as QUIFile;
/**
......@@ -28,6 +29,10 @@ class File extends Item implements QUI\Interfaces\Projects\Media\File
*/
public function createCache()
{
if (Media::$globalDisableMediaCacheCreation) {
return false;
}
if (!$this->getAttribute('active')) {
return false;
}
......
......@@ -1204,6 +1204,10 @@ class Folder extends Item implements QUI\Interfaces\Projects\Media\File
*/
public function createCache()
{
if (Media::$globalDisableMediaCacheCreation) {
return false;
}
if (!$this->getAttribute('active')) {
return true;
}
......
......@@ -109,6 +109,10 @@ class Image extends Item implements QUI\Interfaces\Projects\Media\File
*/
public function createCache()
{
if (Media::$globalDisableMediaCacheCreation) {
return false;
}
return $this->createSizeCache();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment