Skip to content
Snippets Groups Projects
Commit 1b8fe608 authored by Bram Driesen's avatar Bram Driesen
Browse files

Issue #3500374 by keiserjb, bramdriesen: Settings page in Drupal 11

parent deaf6344
No related branches found
No related tags found
1 merge request!7Issue #3500374 by keiserjb: Settings page in Drupal 11
Pipeline #461792 passed with warnings
Showing
with 63 additions and 32 deletions
...@@ -2,6 +2,6 @@ name: Konami Code ...@@ -2,6 +2,6 @@ name: Konami Code
type: module type: module
description: Performs special actions when the user enters the Konami Code. description: Performs special actions when the user enters the Konami Code.
package: Other package: Other
core_version_requirement: ^8.8 || ^9 || ^10 || ^11 core_version_requirement: ^10.2 || ^11
configure: konamicode.configuration configure: konamicode.configuration
...@@ -20,9 +20,9 @@ function konamicode_help($route_name, RouteMatchInterface $route_match) { ...@@ -20,9 +20,9 @@ function konamicode_help($route_name, RouteMatchInterface $route_match) {
<h3>Instructions</h3> <h3>Instructions</h3>
<p>Install the module like any other module in the <em>modules/contrib</em> folder and enable in <strong>/admin/modules</strong>.</p> <p>Install the module like any other module in the <em>modules/contrib</em> folder and enable in <strong>/admin/modules</strong>.</p>
<p>Then, visit <strong>/admin/config/user-interface/konamicode</strong> to configure the different <em>actions</em> and options for each of the actions.</p> <p>Then, visit <strong>/admin/config/user-interface/konamicode</strong> to configure the different <em>actions</em> and options for each of the actions.</p>
<p>Last, visit any page and enter the configured Konami code.</p> <p>Last, visit any page and enter the configured Konami code.</p>
<h3>Documentation</h3> <h3>Documentation</h3>
<p>The complete documentation guide can be found at the dedicated <a href="https://www.drupal.org/docs/8/modules/konami-code">documentation</a> page.</p> <p>The complete documentation guide can be found at the dedicated <a href="https://www.drupal.org/docs/8/modules/konami-code">documentation</a> page.</p>
'); ');
} }
} }
...@@ -64,7 +64,7 @@ function konamicode_page_attachments(array &$page) { ...@@ -64,7 +64,7 @@ function konamicode_page_attachments(array &$page) {
$raw_configuration = $config->getRawData(); $raw_configuration = $config->getRawData();
// Fetch the Konami Code settings. // Fetch the Konami Code settings.
$main_configuration_class = new KonamicodeMainConfiguration(\Drupal::configFactory()); $main_configuration_class = \Drupal::service('konamicode.main_configuration');
$actions = $main_configuration_class->getAllActions(); $actions = $main_configuration_class->getAllActions();
// Loop over all the actions. // Loop over all the actions.
......
services:
konamicode.main_configuration:
class: Drupal\konamicode\Form\KonamicodeMainConfiguration
arguments: [ '@config.factory', '@config.typed' ]
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\konamicode\Form; namespace Drupal\konamicode\Form;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
/** /**
...@@ -16,8 +17,8 @@ class KonamicodeActionAlertConfiguration extends KonamicodeActionBaseConfigurati ...@@ -16,8 +17,8 @@ class KonamicodeActionAlertConfiguration extends KonamicodeActionBaseConfigurati
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(ConfigFactoryInterface $config_factory) { public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config_manager) {
parent::__construct($config_factory, self::$name, self::$machineName); parent::__construct($config_factory, $typed_config_manager, self::$name, self::$machineName);
} }
/** /**
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\konamicode\Form; namespace Drupal\konamicode\Form;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
/** /**
...@@ -17,8 +18,8 @@ class KonamicodeActionAsteroidsConfiguration extends KonamicodeActionBaseConfigu ...@@ -17,8 +18,8 @@ class KonamicodeActionAsteroidsConfiguration extends KonamicodeActionBaseConfigu
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(ConfigFactoryInterface $config_factory) { public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config_manager) {
parent::__construct($config_factory, self::$name, self::$machineName, self::$dependencies); parent::__construct($config_factory, $typed_config_manager, self::$name, self::$machineName, self::$dependencies);
} }
/** /**
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\konamicode\Form; namespace Drupal\konamicode\Form;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
/** /**
...@@ -51,6 +52,8 @@ class KonamicodeActionBaseConfiguration extends KonamicodeMainConfiguration { ...@@ -51,6 +52,8 @@ class KonamicodeActionBaseConfiguration extends KonamicodeMainConfiguration {
* *
* @param Drupal\Core\Config\ConfigFactoryInterface $config_factory * @param Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The ConfigFactoryInterface. * The ConfigFactoryInterface.
* @param \Drupal\Core\Config\TypedConfigManagerInterface $typedConfigManager
* The typed config manager.
* @param string $name * @param string $name
* Action name. * Action name.
* @param string $machine_name * @param string $machine_name
...@@ -59,11 +62,11 @@ class KonamicodeActionBaseConfiguration extends KonamicodeMainConfiguration { ...@@ -59,11 +62,11 @@ class KonamicodeActionBaseConfiguration extends KonamicodeMainConfiguration {
* Optional: An array of dependencies. The dependency name must match the * Optional: An array of dependencies. The dependency name must match the
* name set in the konamicode.libraries.yml file. * name set in the konamicode.libraries.yml file.
*/ */
public function __construct(ConfigFactoryInterface $config_factory, $name, $machine_name, array $dependencies = []) { public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config_manager, $name, $machine_name, array $dependencies = []) {
$this->setName($name); $this->setName($name);
$this->setMachineName($machine_name); $this->setMachineName($machine_name);
$this->setDependencies($dependencies); $this->setDependencies($dependencies);
parent::__construct($config_factory); parent::__construct($config_factory, $typed_config_manager);
} }
/** /**
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\konamicode\Form; namespace Drupal\konamicode\Form;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
/** /**
...@@ -17,8 +18,8 @@ class KonamicodeActionFlipTextConfiguration extends KonamicodeActionBaseConfigur ...@@ -17,8 +18,8 @@ class KonamicodeActionFlipTextConfiguration extends KonamicodeActionBaseConfigur
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(ConfigFactoryInterface $config_factory) { public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config_manager) {
parent::__construct($config_factory, self::$name, self::$machineName, self::$dependencies); parent::__construct($config_factory, $typed_config_manager, self::$name, self::$machineName, self::$dependencies);
} }
/** /**
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\konamicode\Form; namespace Drupal\konamicode\Form;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
/** /**
...@@ -17,8 +18,8 @@ class KonamicodeActionImageSpawnConfiguration extends KonamicodeActionBaseConfig ...@@ -17,8 +18,8 @@ class KonamicodeActionImageSpawnConfiguration extends KonamicodeActionBaseConfig
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(ConfigFactoryInterface $config_factory) { public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config_manager) {
parent::__construct($config_factory, self::$name, self::$machineName, self::$dependencies); parent::__construct($config_factory, $typed_config_manager, self::$name, self::$machineName, self::$dependencies);
} }
/** /**
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\konamicode\Form; namespace Drupal\konamicode\Form;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
/** /**
...@@ -17,8 +18,8 @@ class KonamicodeActionRaptorizeConfiguration extends KonamicodeActionBaseConfigu ...@@ -17,8 +18,8 @@ class KonamicodeActionRaptorizeConfiguration extends KonamicodeActionBaseConfigu
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(ConfigFactoryInterface $config_factory) { public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config_manager) {
parent::__construct($config_factory, self::$name, self::$machineName, self::$dependencies); parent::__construct($config_factory, $typed_config_manager, self::$name, self::$machineName, self::$dependencies);
} }
/** /**
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\konamicode\Form; namespace Drupal\konamicode\Form;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
/** /**
...@@ -16,8 +17,8 @@ class KonamicodeActionRedirectConfiguration extends KonamicodeActionBaseConfigur ...@@ -16,8 +17,8 @@ class KonamicodeActionRedirectConfiguration extends KonamicodeActionBaseConfigur
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(ConfigFactoryInterface $config_factory) { public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config_manager) {
parent::__construct($config_factory, self::$name, self::$machineName); parent::__construct($config_factory, $typed_config_manager, self::$name, self::$machineName);
} }
/** /**
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\konamicode\Form; namespace Drupal\konamicode\Form;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
/** /**
...@@ -16,8 +17,8 @@ class KonamicodeActionReplaceImagesConfiguration extends KonamicodeActionBaseCon ...@@ -16,8 +17,8 @@ class KonamicodeActionReplaceImagesConfiguration extends KonamicodeActionBaseCon
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(ConfigFactoryInterface $config_factory) { public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config_manager) {
parent::__construct($config_factory, self::$name, self::$machineName); parent::__construct($config_factory, $typed_config_manager, self::$name, self::$machineName);
} }
/** /**
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\konamicode\Form; namespace Drupal\konamicode\Form;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link; use Drupal\Core\Link;
use Drupal\Core\Url; use Drupal\Core\Url;
...@@ -19,8 +20,8 @@ class KonamicodeActionSnowfallConfiguration extends KonamicodeActionBaseConfigur ...@@ -19,8 +20,8 @@ class KonamicodeActionSnowfallConfiguration extends KonamicodeActionBaseConfigur
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(ConfigFactoryInterface $config_factory) { public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config_manager) {
parent::__construct($config_factory, self::$name, self::$machineName, self::$dependencies); parent::__construct($config_factory, $typed_config_manager, self::$name, self::$machineName, self::$dependencies);
} }
/** /**
......
...@@ -109,14 +109,14 @@ class KonamicodeMainConfiguration extends ConfigFormBase { ...@@ -109,14 +109,14 @@ class KonamicodeMainConfiguration extends ConfigFormBase {
*/ */
public function getAllActions() { public function getAllActions() {
return [ return [
new KonamicodeActionRedirectConfiguration($this->configFactory), new KonamicodeActionRedirectConfiguration($this->configFactory, $this->typedConfigManager),
new KonamicodeActionAlertConfiguration($this->configFactory), new KonamicodeActionAlertConfiguration($this->configFactory, $this->typedConfigManager),
new KonamicodeActionRaptorizeConfiguration($this->configFactory), new KonamicodeActionRaptorizeConfiguration($this->configFactory, $this->typedConfigManager),
new KonamicodeActionFlipTextConfiguration($this->configFactory), new KonamicodeActionFlipTextConfiguration($this->configFactory, $this->typedConfigManager),
new KonamicodeActionImageSpawnConfiguration($this->configFactory), new KonamicodeActionImageSpawnConfiguration($this->configFactory, $this->typedConfigManager),
new KonamicodeActionReplaceImagesConfiguration($this->configFactory), new KonamicodeActionReplaceImagesConfiguration($this->configFactory, $this->typedConfigManager),
new KonamicodeActionSnowfallConfiguration($this->configFactory), new KonamicodeActionSnowfallConfiguration($this->configFactory, $this->typedConfigManager),
new KonamicodeActionAsteroidsConfiguration($this->configFactory), new KonamicodeActionAsteroidsConfiguration($this->configFactory, $this->typedConfigManager),
]; ];
} }
......
...@@ -19,6 +19,13 @@ class KonamicodeHexColorTest extends UnitTestCase { ...@@ -19,6 +19,13 @@ class KonamicodeHexColorTest extends UnitTestCase {
*/ */
protected $configFactory; protected $configFactory;
/**
* The typed config manager.
*
* @var \Drupal\Core\Config\TypedConfigManager
*/
protected $typedConfigManager;
/** /**
* The action class used to trigger the functions. * The action class used to trigger the functions.
* *
...@@ -32,9 +39,10 @@ class KonamicodeHexColorTest extends UnitTestCase { ...@@ -32,9 +39,10 @@ class KonamicodeHexColorTest extends UnitTestCase {
public function setUp(): void { public function setUp(): void {
parent::setUp(); parent::setUp();
$this->configFactory = $this->createMock('Drupal\Core\Config\ConfigFactory'); $this->configFactory = $this->createMock('Drupal\Core\Config\ConfigFactory');
$this->typedConfigManager = $this->createMock('Drupal\Core\Config\TypedConfigManager');
// Mock that we are the snowfall class. // Mock that we are the snowfall class.
$this->actionClass = new KonamicodeActionSnowfallConfiguration($this->configFactory); $this->actionClass = new KonamicodeActionSnowfallConfiguration($this->configFactory, $this->typedConfigManager);
} }
/** /**
......
...@@ -18,6 +18,13 @@ class KonamicodeKeyCodeSequenceTest extends UnitTestCase { ...@@ -18,6 +18,13 @@ class KonamicodeKeyCodeSequenceTest extends UnitTestCase {
* @var \Drupal\Core\Config\ConfigFactory * @var \Drupal\Core\Config\ConfigFactory
*/ */
protected $configFactory; protected $configFactory;
/**
* The typed config manager.
*
* @var \Drupal\Core\Config\TypedConfigManager
*/
protected $typedConfigManager;
/** /**
* The action class used to trigger the functions. * The action class used to trigger the functions.
...@@ -32,10 +39,11 @@ class KonamicodeKeyCodeSequenceTest extends UnitTestCase { ...@@ -32,10 +39,11 @@ class KonamicodeKeyCodeSequenceTest extends UnitTestCase {
public function setUp(): void { public function setUp(): void {
parent::setUp(); parent::setUp();
$this->configFactory = $this->createMock('Drupal\Core\Config\ConfigFactory'); $this->configFactory = $this->createMock('Drupal\Core\Config\ConfigFactory');
$this->typedConfigManager = $this->createMock('Drupal\Core\Config\TypedConfigManager');
// Just mock that we are one of the action classes in order to be able to // Just mock that we are one of the action classes in order to be able to
// call the validation function of the base class. // call the validation function of the base class.
$this->actionClass = new KonamicodeActionAlertConfiguration($this->configFactory); $this->actionClass = new KonamicodeActionAlertConfiguration($this->configFactory, $this->typedConfigManager);
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment