Browse Source

Issue #15957: dropped deprecated View properties (#15961)

See also #15120
tags/3.0.0-alpha1
Pavel Ivanov 7 years ago committed by Alexander Makarov
parent
commit
0babc4b299
  1. 46
      framework/base/View.php
  2. 2
      tests/framework/base/ViewTest.php

46
framework/base/View.php

@ -86,22 +86,13 @@ class View extends Component implements DynamicContentAwareInterface
*/
public $blocks;
/**
* @var array|DynamicContentAwareInterface[] a list of currently active dynamic content class instances.
* This property is used internally to implement the dynamic content caching feature. Do not modify it directly.
* @internal
* @deprecated Since 2.0.14. Do not use this property directly. Use methods [[getDynamicContents()]],
* [[pushDynamicContent()]], [[popDynamicContent()]] instead.
* @var DynamicContentAwareInterface[] a list of currently active dynamic content class instances.
*/
public $cacheStack = [];
private $_cacheStack = [];
/**
* @var array a list of placeholders for embedding dynamic contents. This property
* is used internally to implement the content caching feature. Do not modify it directly.
* @internal
* @deprecated Since 2.0.14. Do not use this property directly. Use methods [[getDynamicPlaceholders()]],
* [[setDynamicPlaceholders()]], [[addDynamicPlaceholder()]] instead.
* @var array a list of placeholders for embedding dynamic contents.
*/
public $dynamicPlaceholders = [];
private $_dynamicPlaceholders = [];
/**
* @var array the view files currently being rendered. There may be multiple view files being
* rendered at a moment because one view may be rendered within another.
@ -370,8 +361,9 @@ class View extends Component implements DynamicContentAwareInterface
if (!empty($params)) {
$statements = 'extract(unserialize(\'' . str_replace(['\\', '\'' ], ['\\\\', '\\\'' ], serialize($params)) . '\'));' . $statements;
}
if (!empty($this->cacheStack)) {
$n = count($this->dynamicPlaceholders);
if (!empty($this->_cacheStack)) {
$n = count($this->_dynamicPlaceholders);
$placeholder = "<![CDATA[YII-DYNAMIC-$n]]>";
$this->addDynamicPlaceholder($placeholder, $statements);
@ -386,7 +378,7 @@ class View extends Component implements DynamicContentAwareInterface
*/
public function getDynamicPlaceholders()
{
return $this->dynamicPlaceholders;
return $this->_dynamicPlaceholders;
}
/**
@ -394,7 +386,7 @@ class View extends Component implements DynamicContentAwareInterface
*/
public function setDynamicPlaceholders($placeholders)
{
$this->dynamicPlaceholders = $placeholders;
$this->_dynamicPlaceholders = $placeholders;
}
/**
@ -402,16 +394,12 @@ class View extends Component implements DynamicContentAwareInterface
*/
public function addDynamicPlaceholder($placeholder, $statements)
{
foreach ($this->cacheStack as $cache) {
if ($cache instanceof DynamicContentAwareInterface) {
$cache->addDynamicPlaceholder($placeholder, $statements);
} else {
// TODO: Remove in 2.1
$cache->dynamicPlaceholders[$placeholder] = $statements;
}
foreach ($this->_cacheStack as $cache) {
$cache->addDynamicPlaceholder($placeholder, $statements);
}
$this->dynamicPlaceholders[$placeholder] = $statements;
}
$this->_dynamicPlaceholders[$placeholder] = $statements;
}
/**
* Evaluates the given PHP statements.
@ -431,7 +419,7 @@ class View extends Component implements DynamicContentAwareInterface
*/
public function getDynamicContents()
{
return $this->cacheStack;
return $this->_cacheStack;
}
/**
@ -442,7 +430,7 @@ class View extends Component implements DynamicContentAwareInterface
*/
public function pushDynamicContent(DynamicContentAwareInterface $instance)
{
$this->cacheStack[] = $instance;
$this->_cacheStack[] = $instance;
}
/**
@ -452,7 +440,7 @@ class View extends Component implements DynamicContentAwareInterface
*/
public function popDynamicContent()
{
array_pop($this->cacheStack);
array_pop($this->_cacheStack);
}
/**

2
tests/framework/base/ViewTest.php

@ -88,7 +88,7 @@ PHP
}
$this->assertEquals([
'<![CDATA[YII-DYNAMIC-0]]>' => $statement
], $view->dynamicPlaceholders);
], $view->getDynamicPlaceholders());
}
public function testRenderDynamic_StatementWithThisVariable()

Loading…
Cancel
Save