diff --git a/src/View/SSTemplateParseException.php b/src/View/SSTemplateParseException.php index b3665abef6c..b5a4d65fd88 100644 --- a/src/View/SSTemplateParseException.php +++ b/src/View/SSTemplateParseException.php @@ -3,11 +3,14 @@ namespace SilverStripe\View; use Exception; +use SilverStripe\Dev\Deprecation; /** * This is the exception raised when failing to parse a template. Note that we don't currently do any static analysis, * so we can't know if the template will run, just if it's malformed. It also won't catch mistakes that still look * valid. + * + * @deprecated 5.4.0 Will be renamed to SilverStripe\TemplateEngine\Exception\SSTemplateParseException */ class SSTemplateParseException extends Exception { @@ -19,6 +22,11 @@ class SSTemplateParseException extends Exception */ public function __construct($message, $parser) { + Deprecation::noticeWithNoReplacment( + '5.4.0', + 'Will be renamed to SilverStripe\TemplateEngine\Exception\SSTemplateParseException', + Deprecation::SCOPE_CLASS + ); $prior = substr($parser->string ?? '', 0, $parser->pos); preg_match_all('/\r\n|\r|\n/', $prior ?? '', $matches); diff --git a/src/View/SSTemplateParser.peg b/src/View/SSTemplateParser.peg index 76c40ed98e5..098ce52b1eb 100644 --- a/src/View/SSTemplateParser.peg +++ b/src/View/SSTemplateParser.peg @@ -33,6 +33,7 @@ namespace SilverStripe\View; use SilverStripe\Core\Injector\Injector; use Parser; use InvalidArgumentException; +use SilverStripe\Dev\Deprecation; // We want this to work when run by hand too if (defined('THIRDPARTY_PATH')) { @@ -72,6 +73,8 @@ if (defined('THIRDPARTY_PATH')) { * * Angle Bracket: angle brackets "<" and ">" are used to eat whitespace between template elements * N: eats white space including newlines (using in legacy _t support) + * + * @deprecated 5.4.0 Will be renamed to SilverStripe\TemplateEngine\SSTemplateParser */ class SSTemplateParser extends Parser implements TemplateParser { @@ -119,6 +122,11 @@ class SSTemplateParser extends Parser implements TemplateParser */ function construct($matchrule, $name, $arguments = null) { + Deprecation::noticeWithNoReplacment( + '5.4.0', + 'Will be renamed to SilverStripe\TemplateEngine\SSTemplateParser', + Deprecation::SCOPE_CLASS + ); $res = parent::construct($matchrule, $name, $arguments); if (!isset($res['php'])) { $res['php'] = ''; diff --git a/src/View/SSTemplateParser.php b/src/View/SSTemplateParser.php index c7c273414a9..3a586ba806a 100644 --- a/src/View/SSTemplateParser.php +++ b/src/View/SSTemplateParser.php @@ -12,6 +12,7 @@ use SilverStripe\Core\Injector\Injector; use Parser; use InvalidArgumentException; +use SilverStripe\Dev\Deprecation; // We want this to work when run by hand too if (defined('THIRDPARTY_PATH')) { @@ -51,6 +52,8 @@ * * Angle Bracket: angle brackets "<" and ">" are used to eat whitespace between template elements * N: eats white space including newlines (using in legacy _t support) + * + * @deprecated 5.4.0 Will be renamed to SilverStripe\TemplateEngine\SSTemplateParser */ class SSTemplateParser extends Parser implements TemplateParser { @@ -98,6 +101,11 @@ public function __construct($closedBlocks = [], $openBlocks = []) */ function construct($matchrule, $name, $arguments = null) { + Deprecation::noticeWithNoReplacment( + '5.4.0', + 'Will be renamed to SilverStripe\TemplateEngine\SSTemplateParser', + Deprecation::SCOPE_CLASS + ); $res = parent::construct($matchrule, $name, $arguments); if (!isset($res['php'])) { $res['php'] = ''; diff --git a/src/View/SSViewer.php b/src/View/SSViewer.php index d8c14248852..92d28f8843f 100644 --- a/src/View/SSViewer.php +++ b/src/View/SSViewer.php @@ -87,7 +87,7 @@ class SSViewer implements Flushable * * @config * @var string - * @deprecated 5.4.0 Will be moved to SilverStripe\View\SSTemplateEngine.global_key + * @deprecated 5.4.0 Will be moved to SilverStripe\TemplateEngine\SSTemplateEngine.global_key */ private static $global_key = '$CurrentReadingMode, $CurrentUser.ID'; @@ -136,7 +136,7 @@ class SSViewer implements Flushable * List of items being processed * * @var array - * @deprecated 5.4.0 Will be moved to SilverStripe\View\SSTemplateEngine + * @deprecated 5.4.0 Will be moved to SilverStripe\TemplateEngine\SSTemplateEngine */ protected static $topLevel = []; @@ -144,7 +144,7 @@ class SSViewer implements Flushable * List of templates to select from * * @var array - * @deprecated 5.4.0 Will be moved to SilverStripe\View\SSTemplateEngine + * @deprecated 5.4.0 Will be moved to SilverStripe\TemplateEngine\SSTemplateEngine */ protected $templates = null; @@ -152,7 +152,7 @@ class SSViewer implements Flushable * Absolute path to chosen template file * * @var string - * @deprecated 5.4.0 Will be moved to SilverStripe\View\SSTemplateEngine + * @deprecated 5.4.0 Will be moved to SilverStripe\TemplateEngine\SSTemplateEngine */ protected $chosen = null; @@ -160,7 +160,7 @@ class SSViewer implements Flushable * Templates to use when looking up 'Layout' or 'Content' * * @var array - * @deprecated 5.4.0 Will be moved to SilverStripe\View\SSTemplateEngine + * @deprecated 5.4.0 Will be moved to SilverStripe\TemplateEngine\SSTemplateEngine */ protected $subTemplates = []; @@ -171,13 +171,13 @@ class SSViewer implements Flushable /** * @var TemplateParser - * @deprecated 5.4.0 Will be moved to SilverStripe\View\SSTemplateEngine + * @deprecated 5.4.0 Will be moved to SilverStripe\TemplateEngine\SSTemplateEngine */ protected $parser; /** * @var CacheInterface - * @deprecated 5.4.0 Will be moved to SilverStripe\View\SSTemplateEngine + * @deprecated 5.4.0 Will be moved to SilverStripe\TemplateEngine\SSTemplateEngine */ protected $partialCacheStore = null; @@ -216,11 +216,11 @@ public function __construct($templates, TemplateParser $parser = null) /** * Triggered early in the request when someone requests a flush. - * @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::flush() + * @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::flush() */ public static function flush() { - Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::flush()'); + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::flush()'); SSViewer::flush_template_cache(true); SSViewer::flush_cacheblock_cache(true); } @@ -231,11 +231,11 @@ public static function flush() * @param string $content The template content * @param bool|void $cacheTemplate Whether or not to cache the template from string * @return SSViewer - * @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::renderString() + * @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::renderString() */ public static function fromString($content, $cacheTemplate = null) { - Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::renderString()'); + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::renderString()'); $viewer = SSViewer_FromString::create($content); if ($cacheTemplate !== null) { $viewer->setCacheTemplate($cacheTemplate); @@ -400,11 +400,11 @@ public static function setRewriteHashLinksDefault($rewrite) /** * @param string|array $templates - * @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::setTemplate() + * @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::setTemplate() */ public function setTemplate($templates) { - Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::setTemplate()'); + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::setTemplate()'); $this->templates = $templates; $this->chosen = $this->chooseTemplate($templates); $this->subTemplates = []; @@ -427,11 +427,11 @@ public static function chooseTemplate($templates) * Set the template parser that will be used in template generation * * @param TemplateParser $parser - * @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::setParser() + * @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::setParser() */ public function setParser(TemplateParser $parser) { - Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::setParser()'); + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::setParser()'); $this->parser = $parser; } @@ -439,11 +439,11 @@ public function setParser(TemplateParser $parser) * Returns the parser that is set for template generation * * @return TemplateParser - * @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::getParser() + * @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::getParser() */ public function getParser() { - Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::getParser()'); + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::getParser()'); if (!$this->parser) { $this->setParser(Injector::inst()->get('SilverStripe\\View\\SSTemplateParser')); } @@ -456,11 +456,11 @@ public function getParser() * @param array|string $templates * * @return bool - * @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::hasTemplate() + * @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::hasTemplate() */ public static function hasTemplate($templates) { - Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::hasTemplate()'); + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::hasTemplate()'); return (bool)ThemeResourceLoader::inst()->findTemplate($templates, SSViewer::get_themes()); } @@ -504,11 +504,11 @@ public static function getTemplateFileByType($identifier, $type = null) * * @param bool $force Set this to true to force a re-flush. If left to false, flushing * may only be performed once a request. - * @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::flushTemplateCache() + * @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::flushTemplateCache() */ public static function flush_template_cache($force = false) { - Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::flushTemplateCache()'); + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::flushTemplateCache()'); if (!SSViewer::$template_cache_flushed || $force) { $dir = dir(TEMP_PATH); while (false !== ($file = $dir->read())) { @@ -527,11 +527,11 @@ public static function flush_template_cache($force = false) * * @param bool $force Set this to true to force a re-flush. If left to false, flushing * may only be performed once a request. - * @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::flushCacheBlockCache() + * @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::flushCacheBlockCache() */ public static function flush_cacheblock_cache($force = false) { - Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::flushCacheBlockCache()'); + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::flushCacheBlockCache()'); if (!SSViewer::$cacheblock_cache_flushed || $force) { $cache = Injector::inst()->get(CacheInterface::class . '.cacheblock'); $cache->clear(); @@ -545,11 +545,11 @@ public static function flush_cacheblock_cache($force = false) * Set the cache object to use when storing / retrieving partial cache blocks. * * @param CacheInterface $cache - * @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::setPartialCacheStore() + * @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::setPartialCacheStore() */ public function setPartialCacheStore($cache) { - Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::setPartialCacheStore()'); + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::setPartialCacheStore()'); $this->partialCacheStore = $cache; } @@ -557,11 +557,11 @@ public function setPartialCacheStore($cache) * Get the cache object to use when storing / retrieving partial cache blocks. * * @return CacheInterface - * @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::getPartialCacheStore() + * @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::getPartialCacheStore() */ public function getPartialCacheStore() { - Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::getPartialCacheStore()'); + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::getPartialCacheStore()'); if ($this->partialCacheStore) { return $this->partialCacheStore; } @@ -591,11 +591,11 @@ public function includeRequirements($incl = true) * @param array $underlay Any variables to layer underneath the scope * @param SSViewer_Scope|null $inheritedScope The current scope of a parent template including a sub-template * @return string The result of executing the template - * @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::includeGeneratedTemplate() + * @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::includeGeneratedTemplate() */ protected function includeGeneratedTemplate($cacheFile, $item, $overlay, $underlay, $inheritedScope = null) { - Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::includeGeneratedTemplate()'); + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::includeGeneratedTemplate()'); if (isset($_GET['showtemplate']) && $_GET['showtemplate'] && Permission::check('ADMIN')) { $lines = file($cacheFile ?? ''); echo "

Template: $cacheFile

"; @@ -724,11 +724,11 @@ public function process($item, $arguments = null, $inheritedScope = null) * @param string $subtemplate Sub-template to use * * @return array|null - * @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::getSubtemplateFor() + * @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::getSubtemplateFor() */ protected function getSubtemplateFor($subtemplate) { - Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::getSubtemplateFor()'); + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::getSubtemplateFor()'); // Get explicit subtemplate name if (isset($this->subTemplates[$subtemplate])) { return $this->subTemplates[$subtemplate]; @@ -766,13 +766,13 @@ function ($template) { * @param bool $globalRequirements * * @return string Evaluated result - * @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::execute_template() + * @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::execute_template() */ public static function execute_template($template, $data, $arguments = null, $scope = null, $globalRequirements = false) { Deprecation::noticeWithNoReplacment( '5.4.0', - 'Will be replaced with SilverStripe\View\SSTemplateEngine::execute_template()' + 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::execute_template()' ); $v = SSViewer::create($template); @@ -803,11 +803,11 @@ public static function execute_template($template, $data, $arguments = null, $sc * @param bool $globalRequirements * * @return string Evaluated result - * @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::renderString() + * @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::renderString() */ public static function execute_string($content, $data, $arguments = null, $globalRequirements = false) { - Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::renderString()'); + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::renderString()'); $v = SSViewer::fromString($content); if ($globalRequirements) { @@ -832,11 +832,11 @@ public static function execute_string($content, $data, $arguments = null, $globa * @param string $content The template contents * @param string $template The template file name * @return string - * @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::parseTemplateContent() + * @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::parseTemplateContent() */ public function parseTemplateContent($content, $template = "") { - Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::parseTemplateContent()'); + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::parseTemplateContent()'); return $this->getParser()->compileString( $content, $template, diff --git a/src/View/SSViewer_BasicIteratorSupport.php b/src/View/SSViewer_BasicIteratorSupport.php index 074c8d71dc8..80d6574a4a6 100644 --- a/src/View/SSViewer_BasicIteratorSupport.php +++ b/src/View/SSViewer_BasicIteratorSupport.php @@ -2,9 +2,13 @@ namespace SilverStripe\View; +use SilverStripe\Dev\Deprecation; + /** * Defines an extra set of basic methods that can be used in templates * that are not defined on sub-classes of {@link ViewableData}. + * + * @deprecated 5.4.0 Will be renamed to SilverStripe\TemplateEngine\BasicIteratorSupport */ class SSViewer_BasicIteratorSupport implements TemplateIteratorProvider { @@ -18,6 +22,15 @@ class SSViewer_BasicIteratorSupport implements TemplateIteratorProvider */ protected $iteratorTotalItems; + public function __construct() + { + Deprecation::noticeWithNoReplacment( + '5.4.0', + 'Will be renamed to SilverStripe\TemplateEngine\BasicIteratorSupport', + Deprecation::SCOPE_CLASS + ); + } + /** * @return array */ diff --git a/src/View/SSViewer_DataPresenter.php b/src/View/SSViewer_DataPresenter.php index 75ce2abc866..e09fe83f146 100644 --- a/src/View/SSViewer_DataPresenter.php +++ b/src/View/SSViewer_DataPresenter.php @@ -12,7 +12,7 @@ * data that is scope-independant (like BaseURL), or type-specific data that is layered on top cross-cut like * (like $FirstLast etc). * - * @deprecated 5.4.0 Will be merged into SilverStripe\View\SSViewer_Scope + * @deprecated 5.4.0 Will be merged into SilverStripe\TemplateEngine\ScopeManager */ class SSViewer_DataPresenter extends SSViewer_Scope { diff --git a/src/View/SSViewer_FromString.php b/src/View/SSViewer_FromString.php index e0259f69215..23b808179e6 100644 --- a/src/View/SSViewer_FromString.php +++ b/src/View/SSViewer_FromString.php @@ -7,7 +7,7 @@ /** * Special SSViewer that will process a template passed as a string, rather than a filename. - * @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::renderString() + * @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::renderString() */ class SSViewer_FromString extends SSViewer { @@ -41,7 +41,7 @@ public function __construct($content, TemplateParser $parser = null) { Deprecation::noticeWithNoReplacment( '5.4.0', - 'Will be replaced with SilverStripe\View\SSTemplateEngine::renderString()', + 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::renderString()', Deprecation::SCOPE_CLASS ); if ($parser) { diff --git a/src/View/SSViewer_Scope.php b/src/View/SSViewer_Scope.php index 1dea7f94b58..8fda08c94e5 100644 --- a/src/View/SSViewer_Scope.php +++ b/src/View/SSViewer_Scope.php @@ -30,6 +30,8 @@ * We also keep the index of the current starting point for lookups. A lookup is a sequence of obj calls - * when in a loop or with tag the end result becomes the new scope, but for injections, we throw away the lookup * and revert back to the original scope once we've got the value we're after + * + * @deprecated 5.4.0 Will be renamed to SilverStripe\TemplateEngine\ScopeManager */ class SSViewer_Scope { @@ -113,6 +115,11 @@ class SSViewer_Scope */ public function __construct($item, SSViewer_Scope $inheritedScope = null) { + Deprecation::noticeWithNoReplacment( + '5.4.0', + 'Will be renamed to SilverStripe\TemplateEngine\ScopeManager', + Deprecation::SCOPE_CLASS + ); $this->item = $item; $this->itemIterator = ($inheritedScope) ? $inheritedScope->itemIterator : null; diff --git a/src/View/TemplateIteratorProvider.php b/src/View/TemplateIteratorProvider.php index f2930bc62fd..40014bfc771 100644 --- a/src/View/TemplateIteratorProvider.php +++ b/src/View/TemplateIteratorProvider.php @@ -7,6 +7,8 @@ * scope in a template that returns values dependent on the state of the iterator of the current scope. * * SSViewer_BasicIteratorSupport is an example of this. See also @TemplateGlobalProvider + * + * @deprecated 5.4.0 Will be renamed to SilverStripe\TemplateEngine\TemplateIteratorProvider */ interface TemplateIteratorProvider { diff --git a/src/View/TemplateParser.php b/src/View/TemplateParser.php index 0af2e69a457..854d96ebb33 100644 --- a/src/View/TemplateParser.php +++ b/src/View/TemplateParser.php @@ -4,6 +4,8 @@ /** * This interface needs to be implemented by any template parser that is used in SSViewer + * + * @deprecated 5.4.0 Will be renamed to SilverStripe\TemplateEngine\TemplateParser */ interface TemplateParser {