/** * Fires the script in module/$module/package/$script.php and its events. * * @param string $bundle * @param string $script * * @throws BundleNotFoundException * @return bool */ protected function firePackageManager($bundleName, $script) { $bundle = $this->jarves->getBundle($bundleName); if ($bundle) { $namespace = $bundle->getNamespace(); } else { if (class_exists($bundleName)) { $reflection = new \ReflectionClass($bundleName); $namespace = $reflection->getNamespaceName(); } else { throw new BundleNotFoundException(sprintf('Bundle `%s` not found.', $bundleName)); } } $packageManagerClass = $namespace . '\\PackageManger'; if (class_exists($packageManagerClass)) { $packageManager = new $packageManagerClass($this->jarves); if ($packageManager instanceof ContainerAwareInterface) { $packageManager->setContainer($this->jarves->getContainer()); } if (method_exists($packageManager, $script)) { $packageManager->{$script}(); } else { $this->jarves->getLogger()->debug(sprintf('PackageManager of Bundle `%s` does not have the method `%s`', $bundle, $script)); } } else { $this->jarves->getLogger()->debug(sprintf('PackageManager class `%s` of Bundle `%s` does not exist', $packageManagerClass, $bundleName)); } return true; }