Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
kiss291323003 committed Jan 21, 2019
1 parent 998b77b commit 3b8ed8a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace EasySwoole\Component\Context;


interface ContextHandlerInterface
interface ContextItemHandlerInterface
{
function onContextCreate();
function onDestroy($context);
Expand Down
6 changes: 3 additions & 3 deletions src/Context/ContextManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ContextManager

private $deferList = [];

public function registerItemHandler($key, ContextHandlerInterface $handler):ContextManager
public function registerItemHandler($key, ContextItemHandlerInterface $handler):ContextManager
{
$this->contextHandler[$key] = $handler;
return $this;
Expand All @@ -46,7 +46,7 @@ public function get($key,$cid = null)
return $this->context[$cid][$key];
}
if(isset($this->contextHandler[$key])){
/** @var ContextHandlerInterface $handler */
/** @var ContextItemHandlerInterface $handler */
$handler = $this->contextHandler[$key];
$this->context[$cid][$key] = $handler->onContextCreate();
return $this->context[$cid][$key];
Expand All @@ -59,7 +59,7 @@ public function unset($key,$cid = null)
$cid = $this->getCid($cid);
if(isset($this->context[$cid][$key])){
if(isset($this->contextHandler[$key])){
/** @var ContextHandlerInterface $handler */
/** @var ContextItemHandlerInterface $handler */
$handler = $this->contextHandler[$key];
$item = $this->context[$cid][$key];
unset($this->context[$cid][$key]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
namespace EasySwoole\Component\Tests;


use EasySwoole\Component\Context\ContextHandlerInterface;
use EasySwoole\Component\Context\ContextItemHandlerInterface;
use EasySwoole\Utility\Random;

class ContextContextHandler implements ContextHandlerInterface
class ContextContextItemHandler implements ContextItemHandlerInterface
{

function onContextCreate()
Expand Down
2 changes: 1 addition & 1 deletion tests/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ContextTest extends TestCase
{
function __construct(?string $name = null, array $data = [], string $dataName = '')
{
ContextManager::getInstance()->registerItemHandler('handler',new ContextContextHandler());
ContextManager::getInstance()->registerItemHandler('handler',new ContextContextItemHandler());
parent::__construct($name, $data, $dataName);
}

Expand Down

0 comments on commit 3b8ed8a

Please sign in to comment.