/**
  * Returns the \Doctrine\ORM\EntityRepository object for the given entity.
  *
  * In case no extension namespace is provided, the given entity is considered
  * belonging to the core module.
  * Otherwise the given entity is considered belonging to the given extension.
  *
  * @param string $entityName Name of the entity to return the EntityRepository for
  * @param string|null $extensionNamespace Namespace of the extension the given entity belongs to
  * @return \Doctrine\ORM\EntityRepository
  */
 public function getRepository(string $entityName, string $extensionNamespace = null)
 {
     // consider entity belonging to core module if no extension namespace is given
     if ($extensionNamespace === null) {
         $extensionNamespace = CoreModule::getNamespace();
     }
     // return the entity repository via it's alias
     return $this->getEntityManager()->getRepository($extensionNamespace . ':' . $entityName);
 }
 /**
  * Returns an internal URL based on the current base URL and the given
  * module namespace.
  *
  * E.g. EnvironmentUtil::getInternalUrl('/foo', 'Bar') -> http://example.com/acp/Bar/foo
  *
  * @param string $moduleInternalPath Path within the module
  * @param string $moduleNamespace Namespace of the module to return the URL for
  * @return \Ableron\Lib\Net\Uri
  */
 public static function getInternalUrl(string $moduleInternalPath, string $moduleNamespace = null)
 {
     // get module repository
     /** @var \Ableron\Modules\Core\Model\Repositories\ModuleRepository $moduleRepository */
     $moduleRepository = Application::getPersistenceManager()->getRepository('ModuleEntity');
     // get module
     $module = $moduleRepository->findModuleByNamespace($moduleNamespace === null ? CoreModule::getNamespace() : $moduleNamespace);
     // build and return URL
     return new Uri(rtrim(self::getBaseUrl()->toString() . (Application::getRequestHandler()->isFrontendRequest() ? $module->getFrontendBasePath() : $module->getBackendBasePath()), '/') . $moduleInternalPath);
 }
 /**
  * Sends a response to the client indicating a fatal system error.
  *
  * @return void
  */
 public function sendResponseSystemError()
 {
     $this->sendResponse(new HttpResponse(HttpResponse::STATUS_INTERNAL_SERVER_ERROR, new InternetMediaType('text', 'html', array('charset' => 'utf-8')), file_get_contents(sprintf('%s/%s/Pages/%s/Templates/SystemErrorPage.tpl', ABLERON_MODULE_DIR, CoreModule::getNamespace(), Application::getRequestHandler()->isFrontendRequest() ? 'Frontend' : 'Backend'))));
 }
 public function testGetNamespace()
 {
     $this->assertSame('Core', CoreModule::getNamespace());
     $this->assertSame('BruteForceProtector', BruteForceProtectorPlugin::getNamespace());
 }
 /**
  * Installs extensions (modules and plugins).
  *
  * @throws \Ableron\Core\Exception\SystemException
  * @return void
  */
 private function installExtensions()
 {
     // install all available modules (except core module which has already been installed)
     foreach (Application::getModuleManager()->getModules() as $module) {
         if ($module::getNamespace() !== CoreModule::getNamespace()) {
             try {
                 Application::getModuleManager()->install(ClassUtil::getInstance(sprintf('Ableron\\Modules\\%s\\Module', $module::getNamespace())));
             } catch (SystemException $e) {
                 $this->getInstaller()->addException(new SystemException(sprintf('Unable to install module "%s"', $module::getNamespace()), 0, E_USER_WARNING, __FILE__, __LINE__, $e));
             }
         }
     }
     // install all available plugins
     foreach (Application::getPluginManager()->getPlugins() as $plugin) {
         try {
             Application::getPluginManager()->install(ClassUtil::getInstance(sprintf('Ableron\\Plugins\\%s\\Plugin', $plugin::getNamespace())));
         } catch (SystemException $e) {
             $this->getInstaller()->addException(new SystemException(sprintf('Unable to install plugin "%s"', $plugin::getNamespace()), 0, E_USER_WARNING, __FILE__, __LINE__, $e));
         }
     }
 }