Allow CmsObjects to define their own Twig cache key
This commit is contained in:
parent
4922d6d284
commit
6e7fa7de88
|
|
@ -373,7 +373,7 @@ class FormController extends ControllerBehavior
|
|||
protected function createModel()
|
||||
{
|
||||
$class = $this->config->modelClass;
|
||||
$model = new $class();
|
||||
$model = new $class;
|
||||
return $model;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -224,6 +224,21 @@ class CmsObject extends HalcyonModel implements CmsObjectContract
|
|||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key used by the Twig cache.
|
||||
* @return string
|
||||
*/
|
||||
public function getTwigCacheKey()
|
||||
{
|
||||
$key = $this->getFilePath();
|
||||
|
||||
if ($event = $this->fireEvent('cmsObject.getTwigCacheKey', compact('key'), true)) {
|
||||
$key = $event;
|
||||
}
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
//
|
||||
// Internals
|
||||
//
|
||||
|
|
|
|||
|
|
@ -167,6 +167,15 @@ class ComponentPartial extends Extendable implements CmsObjectContract
|
|||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key used by the Twig cache.
|
||||
* @return string
|
||||
*/
|
||||
public function getTwigCacheKey()
|
||||
{
|
||||
return $this->getFilePath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file name.
|
||||
* @return string
|
||||
|
|
|
|||
|
|
@ -54,4 +54,10 @@ interface CmsObject
|
|||
*/
|
||||
public function getTwigContent();
|
||||
|
||||
}
|
||||
/**
|
||||
* Returns the key used by the Twig cache.
|
||||
* @return string
|
||||
*/
|
||||
public function getTwigCacheKey();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class Loader implements Twig_LoaderInterface
|
|||
*/
|
||||
public function getCacheKey($name)
|
||||
{
|
||||
return $this->obj->getFilePath();
|
||||
return $this->obj->getTwigCacheKey();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue