Skip to content

Commit

Permalink
changed plugin registration code
Browse files Browse the repository at this point in the history
  • Loading branch information
metalagman committed Aug 2, 2017
1 parent 9d56762 commit 1eff1d8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Kernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,23 @@ public function setPlugins($config)
}

/**
* @param string $className
* @param string $config
* @throws InvalidConfigException
*/
public function registerPlugin($className)
public function registerPlugin($config)
{
if (!class_exists($className)) {
throw new \LogicException("Unknown plugin className {$className}");
$plugin = \Yii::createObject($config);

if (!$plugin instanceof KernelPlugin) {
throw new \LogicException("Wrong plugin configuration");
}

$className = get_class($plugin);

if (isset($this->plugins[$className])) {
return;
}

/** @var KernelPlugin $plugin */
$plugin = \Yii::createObject($className);
$plugin->kernel = $this;
$this->plugins[$className] = $plugin;
$this->plugins[$className]->bootstrap();
Expand Down

0 comments on commit 1eff1d8

Please sign in to comment.