protected function boot(ContainerInterface $container)
{
$config = $container->make('Kraken\\Config\\ConfigInterface');
$factory = $container->make('Kraken\\Runtime\\Command\\CommandFactoryInterface');
$commands = (array) $config->get('command.models');
foreach ($commands as $commandClass) {
if (!class_exists($commandClass)) {
throw new ResourceUndefinedException("Command [{$commandClass}] does not exist.");
}
$factory->define($commandClass, function ($runtime, $context = []) use($commandClass) {
return new $commandClass($runtime, $context);
});
}
$plugins = (array) $config->get('command.plugins');
foreach ($plugins as $pluginClass) {
if (!class_exists($pluginClass)) {
throw new ResourceUndefinedException("FactoryPlugin [{$pluginClass}] does not exist.");
}
$plugin = new $pluginClass();
if (!$plugin instanceof FactoryPluginInterface) {
throw new InvalidArgumentException("FactoryPlugin [{$pluginClass}] does not implement FactoryPluginInterface.");
}
$plugin->registerPlugin($factory);
}
}