From d871f4067b0935df0c1d728a649b8cdf411efeb4 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:34:49 +1300 Subject: [PATCH] API Deprecate API which is moving into its own module (#11454) --- src/View/SSTemplateParseException.php | 8 +++ src/View/SSTemplateParser.peg | 8 +++ src/View/SSTemplateParser.php | 8 +++ src/View/SSViewer.php | 74 +++++++++++----------- src/View/SSViewer_BasicIteratorSupport.php | 13 ++++ src/View/SSViewer_DataPresenter.php | 2 +- src/View/SSViewer_FromString.php | 4 +- src/View/SSViewer_Scope.php | 7 ++ src/View/TemplateIteratorProvider.php | 2 + src/View/TemplateParser.php | 2 + 10 files changed, 88 insertions(+), 40 deletions(-) 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 "