"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.10/core/lib/Drupal/Core/Extension/ThemeHandlerInterface.php" (26 Nov 2020, 7679 Bytes) of package /linux/www/drupal-8.9.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ThemeHandlerInterface.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Drupal\Core\Extension;
    4 
    5 /**
    6  * Manages the list of available themes.
    7  */
    8 interface ThemeHandlerInterface {
    9 
   10   /**
   11    * Installs a given list of themes.
   12    *
   13    * @param array $theme_list
   14    *   An array of theme names.
   15    * @param bool $install_dependencies
   16    *   (optional) If TRUE, dependencies will automatically be installed in the
   17    *   correct order. This incurs a significant performance cost, so use FALSE
   18    *   if you know $theme_list is already complete and in the correct order.
   19    *
   20    * @return bool
   21    *   Whether any of the given themes have been installed.
   22    *
   23    * @throws \Drupal\Core\Extension\ExtensionNameLengthException
   24    *   Thrown when the theme name is to long.
   25    *
   26    * @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.
   27    *   Use the theme_installer service instead.
   28    *
   29    * @see https://www.drupal.org/node/3017233
   30    * @see \Drupal\Core\Extension\ThemeInstallerInterface::install()
   31    */
   32   public function install(array $theme_list, $install_dependencies = TRUE);
   33 
   34   /**
   35    * Uninstalls a given list of themes.
   36    *
   37    * Uninstalling a theme removes all related configuration (like blocks) and
   38    * invokes the 'themes_uninstalled' hook.
   39    *
   40    * @param array $theme_list
   41    *   The themes to uninstall.
   42    *
   43    * @throws \Drupal\Core\Extension\Exception\UninstalledExtensionException
   44    *   Thrown when you try to uninstall a theme that wasn't installed.
   45    *
   46    * @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.
   47    *   Use the theme_installer service instead.
   48    *
   49    * @see https://www.drupal.org/node/3017233
   50    * @see hook_themes_uninstalled()
   51    * @see \Drupal\Core\Extension\ThemeInstallerInterface::uninstall()
   52    */
   53   public function uninstall(array $theme_list);
   54 
   55   /**
   56    * Returns a list of currently installed themes.
   57    *
   58    * @return \Drupal\Core\Extension\Extension[]
   59    *   An associative array of the currently installed themes. The keys are the
   60    *   themes' machine names and the values are Extension objects having the
   61    *   following properties:
   62    *   - filename: The filepath and name of the .info.yml file.
   63    *   - name: The machine name of the theme.
   64    *   - status: 1 for installed, 0 for uninstalled themes.
   65    *   - info: The contents of the .info.yml file.
   66    *   - stylesheets: A two dimensional array, using the first key for the
   67    *     media attribute (e.g. 'all'), the second for the name of the file
   68    *     (e.g. style.css). The value is a complete filepath (e.g.
   69    *     themes/bartik/style.css). Not set if no stylesheets are defined in the
   70    *     .info.yml file.
   71    *   - scripts: An associative array of JavaScripts, using the filename as key
   72    *     and the complete filepath as value. Not set if no scripts are defined
   73    *     in the .info.yml file.
   74    *   - prefix: The base theme engine prefix.
   75    *   - engine: The machine name of the theme engine.
   76    *   - base_theme: If this is a sub-theme, the machine name of the base theme
   77    *     defined in the .info.yml file. Otherwise, the element is not set.
   78    *   - base_themes: If this is a sub-theme, an associative array of the
   79    *     base-theme ancestors of this theme, starting with this theme's base
   80    *     theme, then the base theme's own base theme, etc. Each entry has an
   81    *     array key equal to the theme's machine name, and a value equal to the
   82    *     human-readable theme name; if a theme with matching machine name does
   83    *     not exist in the system, the value will instead be NULL (and since the
   84    *     system would not know whether that theme itself has a base theme, that
   85    *     will end the array of base themes). This is not set if the theme is not
   86    *     a sub-theme.
   87    *   - sub_themes: An associative array of themes on the system that are
   88    *     either direct sub-themes (that is, they declare this theme to be
   89    *     their base theme), direct sub-themes of sub-themes, etc. The keys are
   90    *     the themes' machine names, and the values are the themes'
   91    *     human-readable names. This element is not set if there are no themes on
   92    *     the system that declare this theme as their base theme.
   93    */
   94   public function listInfo();
   95 
   96   /**
   97    * Adds a theme extension to the internal listing.
   98    *
   99    * @param \Drupal\Core\Extension\Extension $theme
  100    *   The theme extension.
  101    */
  102   public function addTheme(Extension $theme);
  103 
  104   /**
  105    * Refreshes the theme info data of currently installed themes.
  106    *
  107    * Modules can alter theme info, so this is typically called after a module
  108    * has been installed or uninstalled.
  109    */
  110   public function refreshInfo();
  111 
  112   /**
  113    * Resets the internal state of the theme handler.
  114    */
  115   public function reset();
  116 
  117   /**
  118    * Scans and collects theme extension data and their engines.
  119    *
  120    * @return \Drupal\Core\Extension\Extension[]
  121    *   An associative array of theme extensions.
  122    */
  123   public function rebuildThemeData();
  124 
  125   /**
  126    * Finds all the base themes for the specified theme.
  127    *
  128    * Themes can inherit templates and function implementations from earlier
  129    * themes.
  130    *
  131    * @param \Drupal\Core\Extension\Extension[] $themes
  132    *   An array of available themes.
  133    * @param string $theme
  134    *   The name of the theme whose base we are looking for.
  135    *
  136    * @return array
  137    *   Returns an array of all of the theme's ancestors; the first element's
  138    *   value will be NULL if an error occurred.
  139    */
  140   public function getBaseThemes(array $themes, $theme);
  141 
  142   /**
  143    * Gets the human readable name of a given theme.
  144    *
  145    * @param string $theme
  146    *   The machine name of the theme which title should be shown.
  147    *
  148    * @return string
  149    *   Returns the human readable name of the theme.
  150    *
  151    * @throws \Drupal\Core\Extension\Exception\UnknownExtensionException
  152    *   When the specified theme does not exist.
  153    */
  154   public function getName($theme);
  155 
  156   /**
  157    * Returns the default theme.
  158    *
  159    * @return string
  160    *   The default theme.
  161    */
  162   public function getDefault();
  163 
  164   /**
  165    * Sets a new default theme.
  166    *
  167    * @param string $theme
  168    *   The new default theme.
  169    *
  170    * @return $this
  171    *
  172    * @deprecated in drupal:8.2.0 and is removed from drupal:9.0.0. Use the
  173    *   configuration system to edit the system.theme config directly.
  174    *
  175    * @see https://www.drupal.org/node/3082630
  176    */
  177   public function setDefault($theme);
  178 
  179   /**
  180    * Returns an array of directories for all installed themes.
  181    *
  182    * Useful for tasks such as finding a file that exists in all theme
  183    * directories.
  184    *
  185    * @return array
  186    */
  187   public function getThemeDirectories();
  188 
  189   /**
  190    * Determines whether a given theme is installed.
  191    *
  192    * @param string $theme
  193    *   The name of the theme (without the .theme extension).
  194    *
  195    * @return bool
  196    *   TRUE if the theme is installed.
  197    */
  198   public function themeExists($theme);
  199 
  200   /**
  201    * Returns a theme extension object from the currently active theme list.
  202    *
  203    * @param string $name
  204    *   The name of the theme to return.
  205    *
  206    * @return \Drupal\Core\Extension\Extension
  207    *   An extension object.
  208    *
  209    * @throws \Drupal\Core\Extension\Extension\UnknownExtensionException
  210    *   Thrown when the requested theme does not exist.
  211    */
  212   public function getTheme($name);
  213 
  214   /**
  215    * Determines if a theme should be shown in the user interface.
  216    *
  217    * To be shown in the UI the theme has to be installed. If the theme is hidden
  218    * it will not be shown unless it is the default or admin theme.
  219    *
  220    * @param string $name
  221    *   The name of the theme to check.
  222    *
  223    * @return bool
  224    *   TRUE if the theme should be shown in the UI, FALSE if not.
  225    */
  226   public function hasUi($name);
  227 
  228 }