octicon-rss(16/)
You've already forked yii2
mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-10 02:13:17 +08:00
Add ensureBehaviors() to detachBehavior*()
Need to add ensureBehaviors() to detachBehavior*(). The intent may be to detach behaviors defined in behaviors(). In the original implementation, if these behaviors() are not yet attached, they can not selectively be detached.
This commit is contained in:
octicon-git-branch(16/)
octicon-tag(16/)
octicon-diff(16/tw-mr-1) 1 changed files with 2 additions and 0 deletions
@@ -496,6 +496,7 @@ class Component extends Object
|
|||||||
*/
|
*/
|
||||||
public function detachBehavior($name)
|
public function detachBehavior($name)
|
||||||
{
|
{
|
||||||
|
$this->ensureBehaviors();
|
||||||
if (isset($this->_behaviors[$name])) {
|
if (isset($this->_behaviors[$name])) {
|
||||||
$behavior = $this->_behaviors[$name];
|
$behavior = $this->_behaviors[$name];
|
||||||
unset($this->_behaviors[$name]);
|
unset($this->_behaviors[$name]);
|
||||||
@@ -511,6 +512,7 @@ class Component extends Object
|
|||||||
*/
|
*/
|
||||||
public function detachBehaviors()
|
public function detachBehaviors()
|
||||||
{
|
{
|
||||||
|
$this->ensureBehaviors();
|
||||||
if ($this->_behaviors !== null) {
|
if ($this->_behaviors !== null) {
|
||||||
foreach ($this->_behaviors as $name => $behavior) {
|
foreach ($this->_behaviors as $name => $behavior) {
|
||||||
$this->detachBehavior($name);
|
$this->detachBehavior($name);
|
||||||
|
|||||||
Reference in New Issue
Block a user