Introduce a CmsObject interface

This will be useful to decouple ComponentPartial and Asset objects from their Halcyon counterparts
An Asset is technically not a template, it may be hosted via a CDN or others
A ComponentPartial is also different, it is read only and doesn't require caching
This commit is contained in:
Samuel Georges 2016-03-09 20:51:04 +11:00
parent a6b007e55c
commit d65bc5c2ad
2 changed files with 41 additions and 2 deletions

View File

@ -0,0 +1,39 @@
<?php namespace Cms\Contracts;
interface CmsObject
{
/**
* Loads the template.
*
* @param string $hostObj
* @param string $fileName
* @return mixed
*/
public static function load($hostObj, $fileName);
/**
* Loads and caches the template.
*
* @param string $hostObj
* @param string $fileName
* @return mixed
*/
public static function loadCached($hostObj, $fileName);
/**
* Returns the local file path to the template.
*
* @param string $fileName
* @return string
*/
// public static function getFilePath($fileName = null);
/**
* Returns the Twig content string.
*
* @return string
*/
public function getTwigContent();
}

View File

@ -2,7 +2,7 @@
use Event;
use Twig_LoaderInterface;
use Cms\Classes\CmsObject;
use Cms\Contracts\CmsObject;
/**
* This class implements a Twig template loader for the CMS.
@ -19,7 +19,7 @@ class Loader implements Twig_LoaderInterface
/**
* Sets a CMS object to load the template from.
* @param \Cms\Classes\CmsObject $obj Specifies the CMS object.
* @param \Cms\Contracts\CmsObject $obj Specifies the CMS object.
*/
public function setObject(CmsObject $obj)
{