public function deactivateAction($bundle)
{
Manager::prepareName($bundle);
$this->get('logger')->alert('DEACTIVATE BUNDLE ' . $bundle);
if (0 === stripos($bundle, 'Jarves\\')) {
throw new \RuntimeException('Can not disabled Jarves bundle for security reasons.');
}
$appKernelPath = new \ReflectionClass('AppKernel');
$file = $appKernelPath->getFileName();
$content = file_get_contents($file);
if (!class_exists($bundle)) {
throw new \RuntimeException('Bundle does not exist.');
}
if (false === stripos($content, 'new ' . $bundle) && false === stripos($content, 'new \\' . $bundle)) {
throw new \RuntimeException('Bundle not registered');
}
$searchBundle = 'new ' . $bundle . '()';
$content = preg_replace('/^[\\s\\t]*' . preg_quote($searchBundle) . '\\s*\\,?$/m', '', $content);
return !!file_put_contents($file, $content);
}