vendor/contao/core-bundle/src/Resources/contao/library/Contao/ModuleLoader.php line 53

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of Contao.
  4.  *
  5.  * (c) Leo Feyer
  6.  *
  7.  * @license LGPL-3.0-or-later
  8.  */
  9. namespace Contao;
  10. /**
  11.  * Loads modules based on their autoload.ini configuration
  12.  *
  13.  * The class reads the autoload.ini files of the available modules and returns
  14.  * an array of active modules with their dependencies solved.
  15.  *
  16.  * Usage:
  17.  *
  18.  *     $arrModules = ModuleLoader::getActive();
  19.  *     $arrModules = ModuleLoader::getDisabled();
  20.  *
  21.  * @author Leo Feyer <https://github.com/leofeyer>
  22.  *
  23.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  24.  *             Use the container parameter "kernel.bundles" instead.
  25.  */
  26. class ModuleLoader
  27. {
  28.     /**
  29.      * Old module names
  30.      * @var array
  31.      */
  32.     private static $legacy = array
  33.     (
  34.         'ContaoCoreBundle'       => 'core',
  35.         'ContaoCalendarBundle'   => 'calendar',
  36.         'ContaoCommentsBundle'   => 'comments',
  37.         'ContaoFaqBundle'        => 'faq',
  38.         'ContaoListingBundle'    => 'listing',
  39.         'ContaoNewsBundle'       => 'news',
  40.         'ContaoNewsletterBundle' => 'newsletter'
  41.     );
  42.     /**
  43.      * Return the active modules as array
  44.      *
  45.      * @return array An array of active modules
  46.      *
  47.      * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.
  48.      */
  49.     public static function getActive()
  50.     {
  51.         trigger_deprecation('contao/core-bundle''4.0''Using "Contao\ModuleLoader::getActive()" has been deprecated and will no longer work in Contao 5.0.');
  52.         $bundles array_keys(System::getContainer()->getParameter('kernel.bundles'));
  53.         foreach (static::$legacy as $bundleName => $module)
  54.         {
  55.             if (\in_array($bundleName$bundles))
  56.             {
  57.                 $bundles[] = $module;
  58.             }
  59.         }
  60.         return $bundles;
  61.     }
  62.     /**
  63.      * Return the disabled modules as array
  64.      *
  65.      * @return array An array of disabled modules
  66.      *
  67.      * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.
  68.      */
  69.     public static function getDisabled()
  70.     {
  71.         trigger_deprecation('contao/core-bundle''4.0''Using "Contao\ModuleLoader::getDisabled()" has been deprecated and will no longer work in Contao 5.0.');
  72.         return array();
  73.     }
  74. }
  75. class_alias(ModuleLoader::class, 'ModuleLoader');