diff --git a/src/Debug/AbstractDebug.php b/src/Debug/AbstractDebug.php index d67683fb..409a55b1 100644 --- a/src/Debug/AbstractDebug.php +++ b/src/Debug/AbstractDebug.php @@ -193,7 +193,8 @@ public function onConfig(Event $event) return; } $event['debug'] = $cfg; - $cfg = $this->container['pluginChannel']->getPropagateValues($event->getValues()); + $cfg = $this->getPlugin('channel')->getPropagateValues($event->getValues()); + unset($cfg['currentSubject'], $cfg['isTarget']); foreach ($channels as $channel) { $channel->config->set($cfg); } @@ -302,7 +303,6 @@ private function bootstrap($cfg) $this->eventManager->addSubscriberInterface($this->container['pluginManager']); $this->addPlugin($this->container['pluginChannel']); - $this->addPlugin($this->container['pluginConfigEvents']); if (!$this->parentInstance) { // we're the root instance diff --git a/src/Debug/Config.php b/src/Debug/Config.php index fac007a8..27fcd186 100644 --- a/src/Debug/Config.php +++ b/src/Debug/Config.php @@ -418,7 +418,7 @@ private function publishConfigEvent(array $configs) Debug::EVENT_CONFIG, $this->debug, \array_merge($configs, array( - 'currentTarget' => $this->debug, + 'currentSubject' => $this->debug, 'isTarget' => true, )) )->getValues(); @@ -427,12 +427,12 @@ private function publishConfigEvent(array $configs) Debug::EVENT_CONFIG, $this->debug, \array_merge($configs, array( - 'currentTarget' => $this->debug->rootInstance, + 'currentSubject' => $this->debug->rootInstance, 'isTarget' => false, )) )->getValues(); } - unset($configs['currentTarget'], $configs['isTarget']); + unset($configs['currentSubject'], $configs['isTarget']); return $configs; } diff --git a/src/Debug/Debug.php b/src/Debug/Debug.php index 467bdeef..ff4ce012 100644 --- a/src/Debug/Debug.php +++ b/src/Debug/Debug.php @@ -7,7 +7,7 @@ * @author Brad Kent * @license http://opensource.org/licenses/MIT MIT * @copyright 2014-2022 Brad Kent - * @version v3.0 + * @version v3.1 * * @link http://www.github.com/bkdotcom/PHPDebugConsole * @link https://developer.mozilla.org/en-US/docs/Web/API/console @@ -82,7 +82,7 @@ class Debug extends AbstractDebug const EVENT_STREAM_WRAP = 'debug.streamWrap'; const META = "\x00meta\x00"; - const VERSION = '3.0.4'; + const VERSION = '3.1'; protected $cfg = array( 'channelIcon' => 'fa fa-list-ul', @@ -143,6 +143,9 @@ class Debug extends AbstractDebug 'output' => false, // output the log? 'outputHeaders' => true, // ie, ChromeLogger and/or firePHP headers 'plugins' => array( + 'configEvents' => array( + 'class' => 'bdk\Debug\Plugin\ConfigEvents', + ), 'internalEvents' => array( 'class' => 'bdk\Debug\Plugin\InternalEvents', ), diff --git a/src/Debug/Plugin/Channel.php b/src/Debug/Plugin/Channel.php index 3f0945aa..432626a1 100644 --- a/src/Debug/Plugin/Channel.php +++ b/src/Debug/Plugin/Channel.php @@ -150,6 +150,8 @@ public function getPropagateValues($cfg) 'channelIcon', 'channelName', 'onBootstrap', + 'onLog', + 'onOutput', 'route', ))); foreach ($cfg as $k => $v) { diff --git a/src/Debug/ServiceProvider.php b/src/Debug/ServiceProvider.php index 5ccbd9c2..07443119 100644 --- a/src/Debug/ServiceProvider.php +++ b/src/Debug/ServiceProvider.php @@ -121,10 +121,6 @@ public function register(Container $container) $container['pluginChannel'] = static function () { return new \bdk\Debug\Plugin\Channel(); }; - $container['pluginConfigEvents'] = static function (Container $container) { - $debug = $container['debug']; - return new \bdk\Debug\Plugin\ConfigEvents($debug); - }; $container['pluginHighlight'] = static function () { return new \bdk\Debug\Plugin\Highlight(); }; diff --git a/tests/Debug/ChannelTest.php b/tests/Debug/ChannelTest.php index 0f341b8d..95873795 100644 --- a/tests/Debug/ChannelTest.php +++ b/tests/Debug/ChannelTest.php @@ -275,8 +275,8 @@ public function testOutput() public function testCreateChannel() { - $channelsBack = $this->helper->getProp($this->debug->pluginChannel, 'channels'); - $this->helper->setProp($this->debug->pluginChannel, 'channels', array()); + $channelsBack = $this->helper->getProp($this->debug->getPlugin('channel'), 'channels'); + $this->helper->setProp($this->debug->getPlugin('channel'), 'channels', array()); $tabby = $this->debug->getChannel('tabby', array( 'channelIcon' => 'fa fa-tabby', 'nested' => false, @@ -311,7 +311,7 @@ public function testCreateChannel() 'general.foo.bar', ), \array_keys($this->debug->getChannels(true, true))); - $this->helper->setProp($this->debug->pluginChannel, 'channels', $channelsBack); + $this->helper->setProp($this->debug->getPlugin('channel'), 'channels', $channelsBack); } public function testGetChannel() @@ -327,8 +327,8 @@ public function testGetChannel() ), )); - $channelsBack = $this->helper->getProp($this->debug->pluginChannel, 'channels'); - $this->helper->setProp($this->debug->pluginChannel, 'channels', array()); + $channelsBack = $this->helper->getProp($this->debug->getPlugin('channel'), 'channels'); + $this->helper->setProp($this->debug->getPlugin('channel'), 'channels', array()); $baz = $this->debug->getChannel('baz'); $baz->getChannel('general.foo.bar', array( 'channelIcon' => 'fa fa-asterisk', @@ -344,7 +344,7 @@ public function testGetChannel() $fork = $this->debug->getChannel('utensil.fork'); self::assertSame('fa fa-fork', $fork->getCfg('channelIcon')); - $this->helper->setProp($this->debug->pluginChannel, 'channels', $channelsBack); + $this->helper->setProp($this->debug->getPlugin('channel'), 'channels', $channelsBack); } protected function genLog(Debug $clearer = null, $bitmask = null, &$info = array()) diff --git a/tests/Debug/ConfigTest.php b/tests/Debug/ConfigTest.php index 677d6879..346bbc72 100644 --- a/tests/Debug/ConfigTest.php +++ b/tests/Debug/ConfigTest.php @@ -327,18 +327,18 @@ public function testOnCfgOnBootstrap() /** * @dataProvider providerOnCfgReplaceSubscriber */ - public function testOnCfgReplaceSubscriber($name, $event) + public function testOnCfgReplaceSubscriber($cfgName, $eventName) { $closure1 = static function () { }; - $this->debug->setCfg($name, $closure1); - $closure2 = static function () { - echo 'you suck!!!' . "\n"; + $this->debug->setCfg($cfgName, $closure1); + $closure2 = static function ($event, $name) { + echo 'closure 2 ' . $event->getSubject()->getCfg('channelName', Debug::CONFIG_DEBUG) . ' ' . $name . "\n"; }; - $this->debug->setCfg($name, $closure2); + $this->debug->setCfg($cfgName, $closure2); $closure1isSub = false; $closure2isSub = false; - foreach ($this->debug->eventManager->getSubscribers($event) as $subInfo) { + foreach ($this->debug->eventManager->getSubscribers($eventName) as $subInfo) { if ($subInfo['callable'] === $closure1) { $closure1isSub = true; } @@ -349,7 +349,9 @@ public function testOnCfgReplaceSubscriber($name, $event) $this->assertFalse($closure1isSub); $this->assertTrue($closure2isSub); - $this->debug->setCfg($name, null); + $this->debug->setCfg($cfgName, null); + + // \bdk\Debug::varDump($eventName, $this->debug->eventManager->getSubscribers($eventName)); } /*