You are here

class WebformShareThemeNegotiator in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_share/src/Theme/WebformShareThemeNegotiator.php \Drupal\webform_share\Theme\WebformShareThemeNegotiator

Sets the theme for the webform share page.

Hierarchy

Expanded class hierarchy of WebformShareThemeNegotiator

See also

\Drupal\webform_share\Controller\WebformShareController::page

page--webform-share.html.twig

1 string reference to 'WebformShareThemeNegotiator'
webform_share.services.yml in modules/webform_share/webform_share.services.yml
modules/webform_share/webform_share.services.yml
1 service uses WebformShareThemeNegotiator
webform_share.theme_negotiator in modules/webform_share/webform_share.services.yml
Drupal\webform_share\Theme\WebformShareThemeNegotiator

File

modules/webform_share/src/Theme/WebformShareThemeNegotiator.php, line 16

Namespace

Drupal\webform_share\Theme
View source
class WebformShareThemeNegotiator implements ThemeNegotiatorInterface {

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

  /**
   * Constructs a WebformShareThemeNegotiator object.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory.
   */
  public function __construct(ConfigFactoryInterface $config_factory) {
    $this->configFactory = $config_factory;
  }

  /**
   * {@inheritdoc}
   */
  public function applies(RouteMatchInterface $route_match) {
    return WebformShareHelper::isPage($route_match);
  }

  /**
   * {@inheritdoc}
   */
  public function determineActiveTheme(RouteMatchInterface $route_match) {

    /** @var \Drupal\webform\WebformInterface $webform */
    $webform = $route_match
      ->getParameter('webform');
    return $webform
      ->getSetting('share_theme_name', TRUE) ?: $this->configFactory
      ->get('system.theme')
      ->get('default');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
WebformShareThemeNegotiator::$configFactory protected property The system theme config object.
WebformShareThemeNegotiator::applies public function Whether this theme negotiator should be used to set the theme. Overrides ThemeNegotiatorInterface::applies
WebformShareThemeNegotiator::determineActiveTheme public function Determine the active theme for the request. Overrides ThemeNegotiatorInterface::determineActiveTheme
WebformShareThemeNegotiator::__construct public function Constructs a WebformShareThemeNegotiator object.