MediaWiki  master
DeferredUpdatesScopeStack.php
Go to the documentation of this file.
1 <?php
30  private $stack;
31 
32  public function __construct() {
33  $this->stack = [ DeferredUpdatesScope::newRootScope() ];
34  }
35 
39  public function current() {
40  return $this->stack[count( $this->stack ) - 1];
41  }
42 
50  public function descend( $activeStage, DeferrableUpdate $update ) {
51  $scope = DeferredUpdatesScope::newChildScope( $activeStage, $update, $this->current() );
52  $this->stack[count( $this->stack )] = $scope;
53 
54  return $scope;
55  }
56 
62  public function ascend() {
63  if ( count( $this->stack ) <= 1 ) {
64  throw new LogicException( "Cannot pop root stack scope; something is out of sync" );
65  }
66 
67  return array_pop( $this->stack );
68  }
69 
75  public function getRecursiveDepth() {
76  return count( $this->stack ) - 1;
77  }
78 }
DeferredUpdatesScopeStack\getRecursiveDepth
getRecursiveDepth()
Get the depth of the scope stack below the root scope.
Definition: DeferredUpdatesScopeStack.php:75
DeferredUpdatesScopeStack\ascend
ascend()
Pop the innermost scope from the stack.
Definition: DeferredUpdatesScopeStack.php:62
DeferredUpdatesScopeStack\$stack
DeferredUpdatesScope[] $stack
Stack of root scope and any recursive scopes.
Definition: DeferredUpdatesScopeStack.php:30
DeferredUpdatesScopeStack\descend
descend( $activeStage, DeferrableUpdate $update)
Make a new child scope, push it onto the stack, and return it.
Definition: DeferredUpdatesScopeStack.php:50
DeferredUpdatesScopeStack
DeferredUpdates helper class for tracking DeferrableUpdate::doUpdate() nesting levels caused by neste...
Definition: DeferredUpdatesScopeStack.php:28
DeferredUpdatesScope
DeferredUpdates helper class for managing DeferrableUpdate::doUpdate() nesting levels caused by neste...
Definition: DeferredUpdatesScope.php:30
DeferredUpdatesScopeStack\current
current()
Definition: DeferredUpdatesScopeStack.php:39
DeferrableUpdate
Interface that deferrable updates should implement.
Definition: DeferrableUpdate.php:11
DeferredUpdatesScopeStack\__construct
__construct()
Definition: DeferredUpdatesScopeStack.php:32
DeferredUpdatesScope\newChildScope
static newChildScope( $activeStage, DeferrableUpdate $update, DeferredUpdatesScope $parentScope)
Definition: DeferredUpdatesScope.php:69
DeferredUpdatesScope\newRootScope
static newRootScope()
Definition: DeferredUpdatesScope.php:59