Skip to content

Commit d871f40

Browse files
API Deprecate API which is moving into its own module (#11454)
1 parent d110c9e commit d871f40

10 files changed

+88
-40
lines changed

src/View/SSTemplateParseException.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
namespace SilverStripe\View;
44

55
use Exception;
6+
use SilverStripe\Dev\Deprecation;
67

78
/**
89
* This is the exception raised when failing to parse a template. Note that we don't currently do any static analysis,
910
* so we can't know if the template will run, just if it's malformed. It also won't catch mistakes that still look
1011
* valid.
12+
*
13+
* @deprecated 5.4.0 Will be renamed to SilverStripe\TemplateEngine\Exception\SSTemplateParseException
1114
*/
1215
class SSTemplateParseException extends Exception
1316
{
@@ -19,6 +22,11 @@ class SSTemplateParseException extends Exception
1922
*/
2023
public function __construct($message, $parser)
2124
{
25+
Deprecation::noticeWithNoReplacment(
26+
'5.4.0',
27+
'Will be renamed to SilverStripe\TemplateEngine\Exception\SSTemplateParseException',
28+
Deprecation::SCOPE_CLASS
29+
);
2230
$prior = substr($parser->string ?? '', 0, $parser->pos);
2331

2432
preg_match_all('/\r\n|\r|\n/', $prior ?? '', $matches);

src/View/SSTemplateParser.peg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ namespace SilverStripe\View;
3333
use SilverStripe\Core\Injector\Injector;
3434
use Parser;
3535
use InvalidArgumentException;
36+
use SilverStripe\Dev\Deprecation;
3637

3738
// We want this to work when run by hand too
3839
if (defined('THIRDPARTY_PATH')) {
@@ -72,6 +73,8 @@ if (defined('THIRDPARTY_PATH')) {
7273
*
7374
* Angle Bracket: angle brackets "<" and ">" are used to eat whitespace between template elements
7475
* N: eats white space including newlines (using in legacy _t support)
76+
*
77+
* @deprecated 5.4.0 Will be renamed to SilverStripe\TemplateEngine\SSTemplateParser
7578
*/
7679
class SSTemplateParser extends Parser implements TemplateParser
7780
{
@@ -119,6 +122,11 @@ class SSTemplateParser extends Parser implements TemplateParser
119122
*/
120123
function construct($matchrule, $name, $arguments = null)
121124
{
125+
Deprecation::noticeWithNoReplacment(
126+
'5.4.0',
127+
'Will be renamed to SilverStripe\TemplateEngine\SSTemplateParser',
128+
Deprecation::SCOPE_CLASS
129+
);
122130
$res = parent::construct($matchrule, $name, $arguments);
123131
if (!isset($res['php'])) {
124132
$res['php'] = '';

src/View/SSTemplateParser.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use SilverStripe\Core\Injector\Injector;
1313
use Parser;
1414
use InvalidArgumentException;
15+
use SilverStripe\Dev\Deprecation;
1516

1617
// We want this to work when run by hand too
1718
if (defined('THIRDPARTY_PATH')) {
@@ -51,6 +52,8 @@
5152
*
5253
* Angle Bracket: angle brackets "<" and ">" are used to eat whitespace between template elements
5354
* N: eats white space including newlines (using in legacy _t support)
55+
*
56+
* @deprecated 5.4.0 Will be renamed to SilverStripe\TemplateEngine\SSTemplateParser
5457
*/
5558
class SSTemplateParser extends Parser implements TemplateParser
5659
{
@@ -98,6 +101,11 @@ public function __construct($closedBlocks = [], $openBlocks = [])
98101
*/
99102
function construct($matchrule, $name, $arguments = null)
100103
{
104+
Deprecation::noticeWithNoReplacment(
105+
'5.4.0',
106+
'Will be renamed to SilverStripe\TemplateEngine\SSTemplateParser',
107+
Deprecation::SCOPE_CLASS
108+
);
101109
$res = parent::construct($matchrule, $name, $arguments);
102110
if (!isset($res['php'])) {
103111
$res['php'] = '';

src/View/SSViewer.php

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class SSViewer implements Flushable
8787
*
8888
* @config
8989
* @var string
90-
* @deprecated 5.4.0 Will be moved to SilverStripe\View\SSTemplateEngine.global_key
90+
* @deprecated 5.4.0 Will be moved to SilverStripe\TemplateEngine\SSTemplateEngine.global_key
9191
*/
9292
private static $global_key = '$CurrentReadingMode, $CurrentUser.ID';
9393

@@ -136,31 +136,31 @@ class SSViewer implements Flushable
136136
* List of items being processed
137137
*
138138
* @var array
139-
* @deprecated 5.4.0 Will be moved to SilverStripe\View\SSTemplateEngine
139+
* @deprecated 5.4.0 Will be moved to SilverStripe\TemplateEngine\SSTemplateEngine
140140
*/
141141
protected static $topLevel = [];
142142

143143
/**
144144
* List of templates to select from
145145
*
146146
* @var array
147-
* @deprecated 5.4.0 Will be moved to SilverStripe\View\SSTemplateEngine
147+
* @deprecated 5.4.0 Will be moved to SilverStripe\TemplateEngine\SSTemplateEngine
148148
*/
149149
protected $templates = null;
150150

151151
/**
152152
* Absolute path to chosen template file
153153
*
154154
* @var string
155-
* @deprecated 5.4.0 Will be moved to SilverStripe\View\SSTemplateEngine
155+
* @deprecated 5.4.0 Will be moved to SilverStripe\TemplateEngine\SSTemplateEngine
156156
*/
157157
protected $chosen = null;
158158

159159
/**
160160
* Templates to use when looking up 'Layout' or 'Content'
161161
*
162162
* @var array
163-
* @deprecated 5.4.0 Will be moved to SilverStripe\View\SSTemplateEngine
163+
* @deprecated 5.4.0 Will be moved to SilverStripe\TemplateEngine\SSTemplateEngine
164164
*/
165165
protected $subTemplates = [];
166166

@@ -171,13 +171,13 @@ class SSViewer implements Flushable
171171

172172
/**
173173
* @var TemplateParser
174-
* @deprecated 5.4.0 Will be moved to SilverStripe\View\SSTemplateEngine
174+
* @deprecated 5.4.0 Will be moved to SilverStripe\TemplateEngine\SSTemplateEngine
175175
*/
176176
protected $parser;
177177

178178
/**
179179
* @var CacheInterface
180-
* @deprecated 5.4.0 Will be moved to SilverStripe\View\SSTemplateEngine
180+
* @deprecated 5.4.0 Will be moved to SilverStripe\TemplateEngine\SSTemplateEngine
181181
*/
182182
protected $partialCacheStore = null;
183183

@@ -216,11 +216,11 @@ public function __construct($templates, TemplateParser $parser = null)
216216

217217
/**
218218
* Triggered early in the request when someone requests a flush.
219-
* @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::flush()
219+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::flush()
220220
*/
221221
public static function flush()
222222
{
223-
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::flush()');
223+
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::flush()');
224224
SSViewer::flush_template_cache(true);
225225
SSViewer::flush_cacheblock_cache(true);
226226
}
@@ -231,11 +231,11 @@ public static function flush()
231231
* @param string $content The template content
232232
* @param bool|void $cacheTemplate Whether or not to cache the template from string
233233
* @return SSViewer
234-
* @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::renderString()
234+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::renderString()
235235
*/
236236
public static function fromString($content, $cacheTemplate = null)
237237
{
238-
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::renderString()');
238+
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::renderString()');
239239
$viewer = SSViewer_FromString::create($content);
240240
if ($cacheTemplate !== null) {
241241
$viewer->setCacheTemplate($cacheTemplate);
@@ -400,11 +400,11 @@ public static function setRewriteHashLinksDefault($rewrite)
400400

401401
/**
402402
* @param string|array $templates
403-
* @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::setTemplate()
403+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::setTemplate()
404404
*/
405405
public function setTemplate($templates)
406406
{
407-
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::setTemplate()');
407+
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::setTemplate()');
408408
$this->templates = $templates;
409409
$this->chosen = $this->chooseTemplate($templates);
410410
$this->subTemplates = [];
@@ -427,23 +427,23 @@ public static function chooseTemplate($templates)
427427
* Set the template parser that will be used in template generation
428428
*
429429
* @param TemplateParser $parser
430-
* @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::setParser()
430+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::setParser()
431431
*/
432432
public function setParser(TemplateParser $parser)
433433
{
434-
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::setParser()');
434+
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::setParser()');
435435
$this->parser = $parser;
436436
}
437437

438438
/**
439439
* Returns the parser that is set for template generation
440440
*
441441
* @return TemplateParser
442-
* @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::getParser()
442+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::getParser()
443443
*/
444444
public function getParser()
445445
{
446-
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::getParser()');
446+
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::getParser()');
447447
if (!$this->parser) {
448448
$this->setParser(Injector::inst()->get('SilverStripe\\View\\SSTemplateParser'));
449449
}
@@ -456,11 +456,11 @@ public function getParser()
456456
* @param array|string $templates
457457
*
458458
* @return bool
459-
* @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::hasTemplate()
459+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::hasTemplate()
460460
*/
461461
public static function hasTemplate($templates)
462462
{
463-
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::hasTemplate()');
463+
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::hasTemplate()');
464464
return (bool)ThemeResourceLoader::inst()->findTemplate($templates, SSViewer::get_themes());
465465
}
466466

@@ -504,11 +504,11 @@ public static function getTemplateFileByType($identifier, $type = null)
504504
*
505505
* @param bool $force Set this to true to force a re-flush. If left to false, flushing
506506
* may only be performed once a request.
507-
* @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::flushTemplateCache()
507+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::flushTemplateCache()
508508
*/
509509
public static function flush_template_cache($force = false)
510510
{
511-
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::flushTemplateCache()');
511+
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::flushTemplateCache()');
512512
if (!SSViewer::$template_cache_flushed || $force) {
513513
$dir = dir(TEMP_PATH);
514514
while (false !== ($file = $dir->read())) {
@@ -527,11 +527,11 @@ public static function flush_template_cache($force = false)
527527
*
528528
* @param bool $force Set this to true to force a re-flush. If left to false, flushing
529529
* may only be performed once a request.
530-
* @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::flushCacheBlockCache()
530+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::flushCacheBlockCache()
531531
*/
532532
public static function flush_cacheblock_cache($force = false)
533533
{
534-
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::flushCacheBlockCache()');
534+
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::flushCacheBlockCache()');
535535
if (!SSViewer::$cacheblock_cache_flushed || $force) {
536536
$cache = Injector::inst()->get(CacheInterface::class . '.cacheblock');
537537
$cache->clear();
@@ -545,23 +545,23 @@ public static function flush_cacheblock_cache($force = false)
545545
* Set the cache object to use when storing / retrieving partial cache blocks.
546546
*
547547
* @param CacheInterface $cache
548-
* @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::setPartialCacheStore()
548+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::setPartialCacheStore()
549549
*/
550550
public function setPartialCacheStore($cache)
551551
{
552-
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::setPartialCacheStore()');
552+
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::setPartialCacheStore()');
553553
$this->partialCacheStore = $cache;
554554
}
555555

556556
/**
557557
* Get the cache object to use when storing / retrieving partial cache blocks.
558558
*
559559
* @return CacheInterface
560-
* @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::getPartialCacheStore()
560+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::getPartialCacheStore()
561561
*/
562562
public function getPartialCacheStore()
563563
{
564-
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::getPartialCacheStore()');
564+
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::getPartialCacheStore()');
565565
if ($this->partialCacheStore) {
566566
return $this->partialCacheStore;
567567
}
@@ -591,11 +591,11 @@ public function includeRequirements($incl = true)
591591
* @param array $underlay Any variables to layer underneath the scope
592592
* @param SSViewer_Scope|null $inheritedScope The current scope of a parent template including a sub-template
593593
* @return string The result of executing the template
594-
* @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::includeGeneratedTemplate()
594+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::includeGeneratedTemplate()
595595
*/
596596
protected function includeGeneratedTemplate($cacheFile, $item, $overlay, $underlay, $inheritedScope = null)
597597
{
598-
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::includeGeneratedTemplate()');
598+
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::includeGeneratedTemplate()');
599599
if (isset($_GET['showtemplate']) && $_GET['showtemplate'] && Permission::check('ADMIN')) {
600600
$lines = file($cacheFile ?? '');
601601
echo "<h2>Template: $cacheFile</h2>";
@@ -724,11 +724,11 @@ public function process($item, $arguments = null, $inheritedScope = null)
724724
* @param string $subtemplate Sub-template to use
725725
*
726726
* @return array|null
727-
* @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::getSubtemplateFor()
727+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::getSubtemplateFor()
728728
*/
729729
protected function getSubtemplateFor($subtemplate)
730730
{
731-
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::getSubtemplateFor()');
731+
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::getSubtemplateFor()');
732732
// Get explicit subtemplate name
733733
if (isset($this->subTemplates[$subtemplate])) {
734734
return $this->subTemplates[$subtemplate];
@@ -766,13 +766,13 @@ function ($template) {
766766
* @param bool $globalRequirements
767767
*
768768
* @return string Evaluated result
769-
* @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::execute_template()
769+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::execute_template()
770770
*/
771771
public static function execute_template($template, $data, $arguments = null, $scope = null, $globalRequirements = false)
772772
{
773773
Deprecation::noticeWithNoReplacment(
774774
'5.4.0',
775-
'Will be replaced with SilverStripe\View\SSTemplateEngine::execute_template()'
775+
'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::execute_template()'
776776
);
777777
$v = SSViewer::create($template);
778778

@@ -803,11 +803,11 @@ public static function execute_template($template, $data, $arguments = null, $sc
803803
* @param bool $globalRequirements
804804
*
805805
* @return string Evaluated result
806-
* @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::renderString()
806+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::renderString()
807807
*/
808808
public static function execute_string($content, $data, $arguments = null, $globalRequirements = false)
809809
{
810-
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::renderString()');
810+
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::renderString()');
811811
$v = SSViewer::fromString($content);
812812

813813
if ($globalRequirements) {
@@ -832,11 +832,11 @@ public static function execute_string($content, $data, $arguments = null, $globa
832832
* @param string $content The template contents
833833
* @param string $template The template file name
834834
* @return string
835-
* @deprecated 5.4.0 Will be replaced with SilverStripe\View\SSTemplateEngine::parseTemplateContent()
835+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::parseTemplateContent()
836836
*/
837837
public function parseTemplateContent($content, $template = "")
838838
{
839-
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\View\SSTemplateEngine::parseTemplateContent()');
839+
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with SilverStripe\TemplateEngine\SSTemplateEngine::parseTemplateContent()');
840840
return $this->getParser()->compileString(
841841
$content,
842842
$template,

src/View/SSViewer_BasicIteratorSupport.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
namespace SilverStripe\View;
44

5+
use SilverStripe\Dev\Deprecation;
6+
57
/**
68
* Defines an extra set of basic methods that can be used in templates
79
* that are not defined on sub-classes of {@link ViewableData}.
10+
*
11+
* @deprecated 5.4.0 Will be renamed to SilverStripe\TemplateEngine\BasicIteratorSupport
812
*/
913
class SSViewer_BasicIteratorSupport implements TemplateIteratorProvider
1014
{
@@ -18,6 +22,15 @@ class SSViewer_BasicIteratorSupport implements TemplateIteratorProvider
1822
*/
1923
protected $iteratorTotalItems;
2024

25+
public function __construct()
26+
{
27+
Deprecation::noticeWithNoReplacment(
28+
'5.4.0',
29+
'Will be renamed to SilverStripe\TemplateEngine\BasicIteratorSupport',
30+
Deprecation::SCOPE_CLASS
31+
);
32+
}
33+
2134
/**
2235
* @return array
2336
*/

src/View/SSViewer_DataPresenter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* data that is scope-independant (like BaseURL), or type-specific data that is layered on top cross-cut like
1313
* (like $FirstLast etc).
1414
*
15-
* @deprecated 5.4.0 Will be merged into SilverStripe\View\SSViewer_Scope
15+
* @deprecated 5.4.0 Will be merged into SilverStripe\TemplateEngine\ScopeManager
1616
*/
1717
class SSViewer_DataPresenter extends SSViewer_Scope
1818
{

0 commit comments

Comments
 (0)