Edit File by line
/home/barbar84/www/wp-conte.../plugins/worker/src/MWP/Worker
File: RequestStack.php
<?php
[0] Fix | Delete
/*
[1] Fix | Delete
* This file is part of the ManageWP Worker plugin.
[2] Fix | Delete
*
[3] Fix | Delete
* (c) ManageWP LLC <contact@managewp.com>
[4] Fix | Delete
*
[5] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[6] Fix | Delete
* file that was distributed with this source code.
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
class MWP_Worker_RequestStack
[10] Fix | Delete
{
[11] Fix | Delete
/**
[12] Fix | Delete
* @var MWP_Worker_Request[]
[13] Fix | Delete
*/
[14] Fix | Delete
private $requests = array();
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Pushes a Request on the stack.
[18] Fix | Delete
*
[19] Fix | Delete
* This method should generally not be called directly as the stack
[20] Fix | Delete
* management should be taken care of by the application itself.
[21] Fix | Delete
*/
[22] Fix | Delete
public function push(MWP_Worker_Request $request)
[23] Fix | Delete
{
[24] Fix | Delete
$this->requests[] = $request;
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* Pops the current request from the stack.
[29] Fix | Delete
*
[30] Fix | Delete
* This operation lets the current request go out of scope.
[31] Fix | Delete
*
[32] Fix | Delete
* This method should generally not be called directly as the stack
[33] Fix | Delete
* management should be taken care of by the application itself.
[34] Fix | Delete
*
[35] Fix | Delete
* @return MWP_Worker_Request|null
[36] Fix | Delete
*/
[37] Fix | Delete
public function pop()
[38] Fix | Delete
{
[39] Fix | Delete
if (!$this->requests) {
[40] Fix | Delete
return null;
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
return array_pop($this->requests);
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* @return MWP_Worker_Request|null
[48] Fix | Delete
*/
[49] Fix | Delete
public function getCurrentRequest()
[50] Fix | Delete
{
[51] Fix | Delete
$lastRequest = end($this->requests);
[52] Fix | Delete
[53] Fix | Delete
return $lastRequest ? $lastRequest : null;
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Gets the master Request.
[58] Fix | Delete
*
[59] Fix | Delete
* @return MWP_Worker_Request|null
[60] Fix | Delete
*/
[61] Fix | Delete
public function getMasterRequest()
[62] Fix | Delete
{
[63] Fix | Delete
if (!$this->requests) {
[64] Fix | Delete
return null;
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
return $this->requests[0];
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
/**
[71] Fix | Delete
* Returns the parent request of the current.
[72] Fix | Delete
*
[73] Fix | Delete
* If current Request is the master request, it returns null.
[74] Fix | Delete
*
[75] Fix | Delete
* @return MWP_Worker_Request|null
[76] Fix | Delete
*/
[77] Fix | Delete
public function getParentRequest()
[78] Fix | Delete
{
[79] Fix | Delete
$pos = count($this->requests) - 2;
[80] Fix | Delete
[81] Fix | Delete
if (!isset($this->requests[$pos])) {
[82] Fix | Delete
return null;
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
return $this->requests[$pos];
[86] Fix | Delete
}
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function