Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • project/theme_switcher
  • issue/theme_switcher-3154752
  • issue/theme_switcher-3123722
  • issue/theme_switcher-3321135
  • issue/theme_switcher-3307042
  • issue/theme_switcher-3338040
  • issue/theme_switcher-3290031
  • issue/theme_switcher-3231339
  • issue/theme_switcher-3370533
  • issue/theme_switcher-3434980
10 results
Show changes
Commits on Source (6)
Showing
with 166 additions and 34 deletions
include:
- project: $_GITLAB_TEMPLATES_REPO
ref: $_GITLAB_TEMPLATES_REF
file:
- '/includes/include.drupalci.main.yml'
- '/includes/include.drupalci.variables.yml'
- '/includes/include.drupalci.workflows.yml'
variables:
SKIP_STYLELINT: '1'
SKIP_ESLINT: '1'
SKIP_CSPELL: '1'
OPT_IN_TEST_NEXT_MAJOR: '1'
composer (next major):
allow_failure: true
......@@ -12,10 +12,10 @@ CONTENTS OF THIS FILE
INTRODUCTION
------------
The Theme Switcher module allows you to create theme-switching rules which
allow automatic selection of a theme based on Drupal 8 Conditions system.
Because of this it can also be easily extended to support additional
custom conditions exposed by other modules. In Drupal 8 conditions are no
The Theme Switcher Rules module allows you to create theme-switching rules which
allow automatic selection of a theme based on Drupal 8 Conditions system.
Because of this it can also be easily extended to support additional
custom conditions exposed by other modules. In Drupal 8 conditions are no
longer defined through a hook and they are plugins now.
This modules is currently only available for Drupal 8.
......@@ -25,7 +25,7 @@ This modules is currently only available for Drupal 8.
* To submit bug reports and feature suggestions, or track changes:
https://www.drupal.org/project/issues/theme_switcher
* For Conditions further information:
https://www.drupal.org/docs/8/modules/d8-rules-essentials/for-developers/conditions
......@@ -50,45 +50,45 @@ CONFIGURATION
* Configure the user permissions in Administration >> People >> Permissions:
- Administer all Theme Switcher Rules
Allows all permissions for the module.
- View Theme Switcher Rules
Users with this permission will be allow to view all Theme Switcher
Users with this permission will be allow to view all Theme Switcher
Rules.
- Create Theme Switcher Rules
Users with this permission will be allow to create Theme Switcher
Users with this permission will be allow to create Theme Switcher
Rules.
- Edit Theme Switcher Rules
Users with this permission will be allow to edit Theme Switcher Rules.
- Delete Theme Switcher Rules
Users with this permission will be allow to delete Theme Switcher
Users with this permission will be allow to delete Theme Switcher
Rules.
* Configuring theme switcher rules:
- To create a theme switcher rule, you must provide the following
- To create a theme switcher rule, you must provide the following
information:
* A *name* to be used in lists of theme switcher rules.
* A *machine_name* that must be unique. This value will be
* A *machine_name* that must be unique. This value will be
autogenerated and cannot be edited once created.
* A *status* indicating `active` or `inactive`.
* A hidden field *weight* that can be changed using the list drag&drop
* A hidden field *weight* that can be changed using the list drag&drop
interface.
* A *theme* to apply when each conditions are evaluated and pass.
* A set of *Conditions* that indicate each one of the variables that
* A set of *Conditions* that indicate each one of the variables that
must be satisfied by the rule to apply the above selected theme.
**IMPORTANT**: All the rules will be evaluated in the order of the list.
This means that once the rule pass all its conditions in a satisfying way
**IMPORTANT**: All the rules will be evaluated in the order of the list.
This means that once the rule pass all its conditions in a satisfying way
the rest of the rules will not be evaluated.
......
File mode changed from 100755 to 100644
......@@ -15,7 +15,7 @@ class ThemeSwitcherAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
public function checkAccess(EntityInterface $entity, $operation, AccountInterface $account = NULL) {
public function checkAccess(EntityInterface $entity, $operation, ?AccountInterface $account = NULL) {
$account = $this->prepareUser($account);
// Check the global permission.
......
......@@ -7,8 +7,8 @@ use Drupal\Core\Entity\EntityStorageException;
use Drupal\Core\Logger\LoggerChannelInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\theme_switcher\ThemeSwitcherRuleInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
......
......@@ -4,13 +4,13 @@ namespace Drupal\theme_switcher\Controller;
use Drupal\Core\Config\Entity\DraggableListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Session\AccountInterface;
/**
* Provides a listing of theme_switcher_rule.
......
File mode changed from 100755 to 100644
......@@ -3,10 +3,10 @@
namespace Drupal\theme_switcher\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Logger\LoggerChannelInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Url;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......
File mode changed from 100755 to 100644
......@@ -5,13 +5,13 @@ namespace Drupal\theme_switcher\Theme;
use Drupal\Component\Plugin\Exception\ContextException;
use Drupal\Component\Plugin\Exception\MissingValueContextException;
use Drupal\Core\Condition\ConditionAccessResolverTrait;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\Context\ContextHandlerInterface;
use Drupal\Core\Plugin\Context\ContextRepositoryInterface;
use Drupal\Core\Plugin\ContextAwarePluginInterface;
use Drupal\Core\Routing\AdminContext;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Theme\ThemeNegotiatorInterface;
use Drupal\Core\Routing\AdminContext;
use Drupal\Core\Entity\EntityTypeManagerInterface;
/**
* Negotiate the current theme based on theme_switcher_rules rules.
......@@ -107,7 +107,7 @@ class ThemeSwitcherNegotiator implements ThemeNegotiatorInterface {
// access without disabling caching. For example the node type
// condition will have a missing context on any non-node route
// like the frontpage.
return FALSE;
continue 2;
}
}
$conditions[$condition_id] = $condition;
......
File mode changed from 100755 to 100644
<?php
namespace Drupal\theme_switcher\Tests\Functional\Entity;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\node\Traits\NodeCreationTrait;
use Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait;
use Drupal\Tests\user\Traits\UserCreationTrait;
/**
* Describes tests of functionality for theme_switcher_rule entities.
*
* @group theme_switcher
*/
class ThemeSwitcherRuleEntityTest extends BrowserTestBase {
use NodeCreationTrait;
use TaxonomyTestTrait;
use UserCreationTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'taxonomy',
'theme_switcher',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* A privileged administrative user.
*
* @var \Drupal\user\UserInterface
*/
protected $administrativeUser;
/**
* A test node type.
*
* @var \Drupal\node\NodeTypeInterface
*/
protected $contentType;
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
/** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
$theme_installer = $this->container->get('theme_installer');
$theme_installer->install(['claro', 'olivero', 'stable9']);
$this->administrativeUser = $this->createUser([
'access content',
'access administration pages',
'administer theme switcher rules',
'administer content types',
'administer nodes',
'administer taxonomy',
'create theme switcher rules',
]);
$this->contentType = $this->drupalCreateContentType();
}
/**
* Tests creating, updating and deleting a theme switcher rule.
*/
public function testCreateDelete(): void {
$this->drupalLogin($this->administrativeUser);
$this->drupalGet('/admin/config/system/theme_switcher');
$this->assertSession()
->pageTextContains('There are no theme switcher rule entities yet.');
// Creates the entity.
$this->drupalGet('/admin/config/system/theme_switcher/add');
$label = $this->randomString();
$id = $this->randomMachineName();
$edit = [
'label' => $label,
'id' => $id,
'status' => '1',
'theme' => 'olivero',
'admin_theme' => 'olivero',
'conjunction' => 'and',
'visibility[response_status][status_codes][200]' => '200',
'visibility[response_status][negate]' => '0',
'visibility[entity_bundle:node][bundles][' . $this->contentType->id() . ']' => $this->contentType->id(),
'visibility[entity_bundle:node][negate]' => '0',
];
$this->submitForm($edit, 'Save');
$this->assertSession()
->pageTextContainsOnce(sprintf("The Theme Switcher Rule '%s' has been created", $label));
$this->assertSession()
->pageTextContains($id);
$this->assertSession()
->pageTextContains('olivero');
// Deletes the entity.
$this->drupalGet('/admin/config/system/theme_switcher/delete/' . $id);
$this->submitForm([], 'Delete');
$this->assertSession()
->pageTextContainsOnce(sprintf("The Theme Switcher Rule '%s' has been deleted.", $label));
$this->assertSession()
->pageTextContains('There are no theme switcher rule entities yet.');
}
}
name: 'Theme Switcher Rules'
description: 'Switches active themes on specific conditions.'
package: User Interface
type: module
core_version_requirement: ^8.9 || ^9 || ^10
package: User interface
core_version_requirement: ^8.9 || ^9 || ^10 || ^11
configure: theme_switcher.admin
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644