Commit 31adefbd authored by Rajab Natshah's avatar Rajab Natshah
Browse files

Issue #3326408: Remove the Varbase Layout Builder Theme Negotiator

parent ce1841b1
Loading
Loading
Loading
Loading
+0 −133
Original line number Diff line number Diff line
<?php

namespace Drupal\varbase_layout_builder\Theme;

use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Theme\AjaxBasePageNegotiator;
use Drupal\Core\Access\CsrfTokenGenerator;
use Symfony\Component\HttpFoundation\RequestStack;
use Drupal\Core\Extension\ThemeHandlerInterface;

/**
 * Varbase Layout Builder Theme Negotiator.
 */
class VarbaseLayoutBuilderThemeNegotiator extends AjaxBasePageNegotiator {

  /**
   * The CSRF token generator.
   *
   * @var \Drupal\Core\Access\CsrfTokenGenerator
   */
  protected $csrfGenerator;

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * The request stack.
   *
   * @var \Symfony\Component\HttpFoundation\RequestStack
   */
  protected $requestStack;

  /**
   * The theme handler.
   *
   * @var \Drupal\Core\Extension\ThemeHandlerInterface
   */
  protected $themeHandler;

  /**
   * Constructs a new AjaxBasePageNegotiator.
   *
   * @param \Drupal\Core\Access\CsrfTokenGenerator $token_generator
   *   The CSRF token generator.
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory.
   * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
   *   The request stack used to retrieve the current request.
   * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
   *   The theme handler.
   */
  public function __construct(CsrfTokenGenerator $token_generator, ConfigFactoryInterface $config_factory, RequestStack $request_stack, ThemeHandlerInterface $theme_handler) {
    $this->csrfGenerator = $token_generator;
    $this->configFactory = $config_factory;
    $this->requestStack = $request_stack;
    $this->themeHandler = $theme_handler;
  }

  /**
   * Whether this theme negotiator should be used to set the theme.
   *
   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
   *   The route match.
   *
   * @return bool
   *   To proceed with changing the theme.
   */
  public function applies(RouteMatchInterface $route_match) {
    $use_claro = $this->configFactory->get('varbase_layout_builder.settings')->get('use_claro');
    if (isset($use_claro) && $use_claro == 1) {

      $route_name = $route_match->getRouteName();
      if (isset($route_name) && strpos($route_name, 'layout_builder') !== FALSE) {
        if ($this->themeHandler->themeExists('claro')) {
          return TRUE;
        }
      }
    }

    return FALSE;
  }

  /**
   * Determine the active theme for the request.
   *
   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
   *   The route match.
   *
   * @return null|string
   *   The selected active theme.
   */
  public function determineActiveTheme(RouteMatchInterface $route_match) {
    $use_claro = $this->configFactory->get('varbase_layout_builder.settings')->get('use_claro');

    if (isset($use_claro) && $use_claro == 1) {

      $route_name = $route_match->getRouteName();
      if (isset($route_name) && strpos($route_name, 'layout_builder') !== FALSE) {

        if ($this->themeHandler->themeExists('claro')) {
          if ($this->requestStack->getCurrentRequest()->request->get('dialogOptions')) {
            $dialog_options = $this->requestStack->getCurrentRequest()->request->get('dialogOptions')['target'];
          }
          if (isset($dialog_options)) {
            return "claro";
          }
          else {
            $request_query_wrapper_format = $this->requestStack->getCurrentRequest()->query->get('_wrapper_format');
            if (isset($request_query_wrapper_format)) {
              if ($request_query_wrapper_format == 'drupal_dialog.off_canvas') {
                return $this->configFactory->get('system.theme')->get('default');
              }
              else {
                return "claro";
              }
            }
          }
        }
        else {
          return $this->configFactory->get('system.theme')->get('admin');
        }
      }
    }

    return NULL;
  }

}

themes/claro/.csscomb.json

deleted100644 → 0
+0 −482
Original line number Diff line number Diff line
{
  "exclude": [
    "themes/**",
    "tests/**",
    "config/**",
    "node_modules/**",
    "src/**",
    "img/**",
    "images/**",
    "icons/**",
    "js/**",
    "javascript/**",
    "scripts/**",
    ".git/**",
    "css/mixins/**"
  ],
  "always-semicolon": true,
  "block-indent": 2,
  "color-case": "lower",
  "color-shorthand": true,
  "element-case": "lower",
  "eof-newline": true,
  "leading-zero": true,
  "lines-between-rulesets": false,
  "quotes": "double",
  "remove-empty-rulesets": true,
  "sort-order-fallback": "abc",
  "space-after-colon": " ",
  "space-after-combinator": " ",
  "space-after-opening-brace": "\n",
  "space-after-selector-delimiter": "\n",
  "space-before-colon": "",
  "space-before-combinator": " ",
  "space-before-opening-brace": " ",
  "space-before-selector-delimiter": "",
  "space-before-closing-brace": "\n",
  "space-between-declarations": "\n",
  "strip-spaces": true,
  "tab-size": 2,
  "unitless-zero": true,
  "verbose": true,
  "sort-order": [
    [
      "$charset",
      "$import",
      "$namespace",
      "$extend",
      "$variable",
      "$include",
      "position",
      "z-index",
      "auto",
      "top",
      "right",
      "bottom",
      "left",
      "display",
      "visibility",
      "float",
      "clear",
      "overflow",
      "overflow-x",
      "overflow-y",
      "-ms-overflow-x",
      "-ms-overflow-y",
      "-webkit-overflow-scrolling",
      "clip",
      "zoom",
      "-webkit-box-flex",
      "-webkit-flex",
      "-ms-flex",
      "flex",
      "-webkit-flex-direction",
      "-ms-flex-direction",
      "flex-direction",
      "-webkit-flex-basis",
      "flex-basis",
      "-webkit-flex-flow",
      "-webkit-box-direction",
      "-webkit-box-orient",
      "-moz-flex-flow",
      "-ms-flex-flow",
      "flex-flow",
      "-webkit-flex-grow",
      "flex-grow",
      "-webkit-flex-shrink",
      "-ms-flex-negative",
      "flex-shrink",
      "-webkit-flex-wrap",
      "-moz-flex-wrap",
      "-ms-flex-wrap",
      "flex-wrap",
      "-ms-flex-order",
      "flex-order",
      "-webkit-order",
      "-webkit-box-ordinal-group",
      "order",
      "-ms-flex-pack",
      "flex-order",
      "flex-pack",
      "align",
      "-webkit-align-self",
      "-moz-align-self",
      "-ms-align-self",
      "-ms-flex-item-align",
      "align-self",
      "justify-content",
      "-webkit-align-items",
      "-webkit-box-align",
      "-ms-flex-align",
      "align-items",
      "-webkit-align-content",
      "align-content",
      "flex-align",
      "-webkit-justify-content",
      "-webkit-box-pack",
      "justify-content",
      "justify-items",
      "justify-self",
      "-webkit-box-sizing",
      "-moz-box-sizing",
      "box-sizing",
      "width",
      "min-width",
      "max-width",
      "height",
      "min-height",
      "max-height",
      "margin",
      "margin-top",
      "margin-right",
      "margin-bottom",
      "margin-left",
      "padding",
      "padding-top",
      "padding-right",
      "padding-bottom",
      "padding-left",
      "table-layout",
      "-webkit-columns",
      "-moz-columns",
      "columns",
      "-webkit-column-span",
      "-moz-column-span",
      "column-span",
      "-webkit-column-width",
      "-moz-column-width",
      "column-width",
      "-webkit-column-count",
      "-moz-column-count",
      "column-count",
      "-webkit-column-fill",
      "-moz-column-fill",
      "column-fill",
      "-webkit-column-gap",
      "-moz-column-gap",
      "column-gap",
      "-webkit-column-rule",
      "-moz-column-rule",
      "column-rule",
      "-webkit-column-rule-width",
      "-moz-column-rule-width",
      "column-rule-width",
      "-webkit-column-rule-style",
      "-moz-column-rule-style",
      "column-rule-style",
      "-webkit-column-rule-color",
      "-moz-column-rule-color",
      "column-rule-color",
      "grid-column-start",
      "grid-column-end",
      "empty-cells",
      "caption-side",
      "border-spacing",
      "border-collapse",
      "$counter-style",
      "list-style",
      "list-style-position",
      "list-style-type",
      "list-style-image",
      "-webkit-appearance",
      "-moz-appearance",
      "appearance",
      "content",
      "quotes",
      "counter-reset",
      "counter-increment",
      "resize",
      "cursor",
      "-webkit-user-select",
      "-moz-user-select",
      "-ms-user-select",
      "user-select",
      "nav-index",
      "nav-up",
      "nav-right",
      "nav-down",
      "nav-left",
      "-webkit-transition",
      "-moz-transition",
      "-ms-transition",
      "-o-transition",
      "transition",
      "-webkit-transition-delay",
      "-moz-transition-delay",
      "-ms-transition-delay",
      "-o-transition-delay",
      "transition-delay",
      "-webkit-transition-timing-function",
      "-moz-transition-timing-function",
      "-ms-transition-timing-function",
      "-o-transition-timing-function",
      "transition-timing-function",
      "will-change",
      "-webkit-transition-duration",
      "-moz-transition-duration",
      "-ms-transition-duration",
      "-o-transition-duration",
      "transition-duration",
      "-webkit-transition-property",
      "-moz-transition-property",
      "-ms-transition-property",
      "-o-transition-property",
      "transition-property",
      "-webkit-transform",
      "-moz-transform",
      "-ms-transform",
      "-o-transform",
      "transform",
      "-webkit-transform-origin",
      "-moz-transform-origin",
      "-ms-transform-origin",
      "-o-transform-origin",
      "transform-origin",
      "$keyframes",
      "-webkit-animation",
      "-moz-animation",
      "-ms-animation",
      "-o-animation",
      "animation",
      "-webkit-animation-name",
      "-moz-animation-name",
      "-ms-animation-name",
      "-o-animation-name",
      "animation-name",
      "-webkit-animation-duration",
      "-moz-animation-duration",
      "-ms-animation-duration",
      "-o-animation-duration",
      "animation-duration",
      "-webkit-animation-play-state",
      "-moz-animation-play-state",
      "-ms-animation-play-state",
      "-o-animation-play-state",
      "animation-play-state",
      "-webkit-animation-timing-function",
      "-moz-animation-timing-function",
      "-ms-animation-timing-function",
      "-o-animation-timing-function",
      "animation-timing-function",
      "-webkit-animation-delay",
      "-moz-animation-delay",
      "-ms-animation-delay",
      "-o-animation-delay",
      "animation-delay",
      "-webkit-animation-iteration-count",
      "-moz-animation-iteration-count",
      "-ms-animation-iteration-count",
      "-o-animation-iteration-count",
      "animation-iteration-count",
      "-webkit-animation-direction",
      "-moz-animation-direction",
      "-ms-animation-direction",
      "-o-animation-direction",
      "animation-direction",
      "text-align",
      "-webkit-text-align-last",
      "-moz-text-align-last",
      "-ms-text-align-last",
      "text-align-last",
      "vertical-align",
      "white-space",
      "-webkit-text-decoration",
      "text-decoration",
      "text-emphasis",
      "text-emphasis-color",
      "text-emphasis-style",
      "text-emphasis-position",
      "text-indent",
      "-ms-text-justify",
      "text-justify",
      "text-transform",
      "letter-spacing",
      "word-spacing",
      "-ms-writing-mode",
      "text-outline",
      "text-transform",
      "text-wrap",
      "text-overflow",
      "-ms-text-overflow",
      "-o-text-overflow",
      "text-overflow-ellipsis",
      "text-overflow-mode",
      "-ms-word-wrap",
      "word-wrap",
      "word-break",
      "-ms-word-break",
      "-moz-tab-size",
      "-o-tab-size",
      "tab-size",
      "-webkit-hyphens",
      "-moz-hyphens",
      "hyphens",
      "page-break",
      "page-break-before",
      "page-break-inside",
      "page-break-after",
      "pointer-events",
      "direction",
      "unicode-bidi",
      "orphans",
      "widows",
      "opacity",
      "filter:progid:DXImageTransform.Microsoft.Alpha(Opacity",
      "-ms-filter:\\'progid:DXImageTransform.Microsoft.Alpha",
      "-webkit-filter",
      "-ms-filter",
      "filter",
      "-ms-interpolation-mode",
      "color",
      "border",
      "border-collapse",
      "border-width",
      "border-style",
      "border-color",
      "border-top",
      "border-top-width",
      "border-top-style",
      "border-top-color",
      "border-right",
      "border-right-width",
      "border-right-style",
      "border-right-color",
      "border-bottom",
      "border-bottom-width",
      "border-bottom-style",
      "border-bottom-color",
      "border-left",
      "border-left-width",
      "border-left-style",
      "border-left-color",
      "-webkit-border-radius",
      "-moz-border-radius",
      "border-radius",
      "-webkit-border-top-left-radius",
      "-moz-border-radius-topleft",
      "border-top-left-radius",
      "-webkit-border-top-right-radius",
      "-moz-border-radius-topright",
      "border-top-right-radius",
      "-webkit-border-bottom-right-radius",
      "-moz-border-radius-bottomright",
      "border-bottom-right-radius",
      "-webkit-border-bottom-left-radius",
      "-moz-border-radius-bottomleft",
      "border-bottom-left-radius",
      "-webkit-border-image",
      "-moz-border-image",
      "-o-border-image",
      "border-image",
      "-webkit-border-image-source",
      "-moz-border-image-source",
      "-o-border-image-source",
      "border-image-source",
      "-webkit-border-image-slice",
      "-moz-border-image-slice",
      "-o-border-image-slice",
      "border-image-slice",
      "-webkit-border-image-width",
      "-moz-border-image-width",
      "-o-border-image-width",
      "border-image-width",
      "-webkit-border-image-outset",
      "-moz-border-image-outset",
      "-o-border-image-outset",
      "border-image-outset",
      "-webkit-border-image-repeat",
      "-moz-border-image-repeat",
      "-o-border-image-repeat",
      "border-image-repeat",
      "outline",
      "outline-width",
      "outline-style",
      "outline-color",
      "outline-offset",
      "background",
      "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader",
      "-o-object-fit",
      "object-fit",
      "background-color",
      "background-image",
      "background-repeat",
      "background-attachment",
      "background-position",
      "background-position-x",
      "-ms-background-position-x",
      "background-position-y",
      "-ms-background-position-y",
      "-webkit-background-clip",
      "-moz-background-clip",
      "background-clip",
      "background-origin",
      "-webkit-background-size",
      "-moz-background-size",
      "-o-background-size",
      "background-size",
      "box-decoration-break",
      "-webkit-box-shadow",
      "-moz-box-shadow",
      "box-shadow",
      "filter:progid:DXImageTransform.Microsoft.gradient",
      "-ms-filter:\\'progid:DXImageTransform.Microsoft.gradient",
      "text-shadow",
      "$font-face",
      "font",
      "font-family",
      "src",
      "$font-feature-values",
      "$swash",
      "$annotation",
      "$ornaments",
      "$stylistic",
      "$styleset",
      "$character-variant",
      "font-variant-alternates",
      "font-size",
      "font-weight",
      "font-style",
      "font-variant",
      "font-size-adjust",
      "font-stretch",
      "font-effect",
      "font-emphasize",
      "font-emphasize-position",
      "font-emphasize-style",
      "font-smooth",
      "font-display",
      "line-height",
      "line-break",
      "-webkit-tap-highlight-color",
      "-webkit-text-size-adjust",
      "-webkit-text-decoration-skip-ink",
      "text-decoration-skip-ink",
      "-ms-overflow-style",
      "-ms-flex-positive",
      "-ms-flex-preferred-size",
      "-webkit-print-color-adjust",
      "-webkit-backface-visibility",
      "backface-visibility",
      "color-adjust",
      "-ms-flex-line-pack",
      "-webkit-margin-after",
      "-webkit-margin-before",
      "margin-block-end",
      "margin-block-start",
      "-webkit-margin-end",
      "-moz-margin-end",
      "margin-inline-end",
      "margin-inline-start",
      "-webkit-margin-start",
      "-moz-margin-start",
      "padding-inline-start",
      "-webkit-padding-start",
      "-moz-padding-start",
      "$media",
      "$supports",
      "$document",
      "$page",
      "$viewport"
    ]
  ]
}
 No newline at end of file

themes/claro/.eslintignore

deleted100644 → 0
+0 −3
Original line number Diff line number Diff line
**/*.min.js
**/gulpfile.js
**/node_modules

themes/claro/.eslintrc.json

deleted100644 → 0
+0 −52
Original line number Diff line number Diff line
{
  "extends": [
    "airbnb-base",
    "plugin:prettier/recommended",
    "plugin:yml/recommended"
  ],
  "root": true,
  "env": {
    "browser": true,
    "es6": true,
    "node": true
  },
  "globals": {
    "Drupal": true,
    "drupalSettings": true,
    "drupalTranslations": true,
    "jQuery": true,
    "_": true,
    "Cookies": true,
    "Backbone": true,
    "Modernizr": true,
    "loadjs": true,
    "Popper": true,
    "Shepherd": true,
    "Sortable": true,
    "once": true,
    "CKEDITOR": true,
    "CKEditor5": true,
    "tabbable": true
  },
  "rules": {
    "prettier/prettier": "error",
    "consistent-return": ["off"],
    "no-underscore-dangle": ["off"],
    "max-nested-callbacks": ["warn", 3],
    "import/no-mutable-exports": ["warn"],
    "no-plusplus": ["warn", {
      "allowForLoopAfterthoughts": true
    }],
    "no-param-reassign": ["off"],
    "no-prototype-builtins": ["off"],
    "valid-jsdoc": ["warn", {
      "prefer": {
        "returns": "return",
        "property": "prop"
      },
      "requireReturn": false
    }],
    "no-unused-vars": ["warn"],
    "operator-linebreak": ["error", "after", { "overrides": { "?": "ignore", ":": "ignore" } }]
  }
}

themes/claro/.gitignore

deleted100644 → 0
+0 −37
Original line number Diff line number Diff line
# Ignore node modules
node_modules
/*/node_modules

# Ignore Variables
/css/variables.css
/css/mixins/

# Ignore vim swp files and gedit temp files
*.swp
*.*~
.vim

# Eclipse settings files.
.project
.pydevproject
.settings
.buildpath

# netbeans settings files.
nbproject
/nbproject
/nbproject/
/nbproject/private/

# Ignore OS settings files.
.DS_Store*
Thumbs.db
ehthumbs.db

# Ignore files generated by PhpStorm.
.idea

# Ignore server stuff.
.bash_history
.bashrc
errors.log
Loading