Loading core/modules/system/config/schema/system.schema.yml +8 −0 Original line number Diff line number Diff line Loading @@ -286,6 +286,8 @@ system.menu.*: system.action.*: type: config_entity label: 'System action' constraints: FullyValidatable: ~ mapping: id: type: machine_name Loading @@ -302,6 +304,12 @@ system.action.*: type: type: string label: 'Type' # Action can be specified without type. # @see \Drupal\action_test\Plugin\Action\NoType nullable: true constraints: NotBlank: allowNull: true plugin: type: string label: 'Plugin' Loading core/modules/system/src/ActionConfigEntityInterface.php +4 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,10 @@ public function isConfigurable(); /** * Returns the operation type. * * @return string * The operation type can be NULL if no type is specified. * * @return string|null * The operation type, or NULL if no type is specified. */ public function getType(); Loading core/modules/system/src/Entity/Action.php +2 −2 Original line number Diff line number Diff line Loading @@ -57,9 +57,9 @@ class Action extends ConfigEntityBase implements ActionConfigEntityInterface, En /** * The action type. * * @var string * @var string|null */ protected $type; protected $type = NULL; /** * The configuration of the action. Loading core/modules/system/tests/modules/action_test/config/schema/action_test.schema.yml 0 → 100644 +6 −0 Original line number Diff line number Diff line # Schema for the configuration files of the Action test module. action.configuration.action_test_no_type: type: mapping label: 'Configuration for action_test_no_type plugin' mapping: {} core/modules/system/tests/src/Kernel/Action/ActionTest.php +22 −0 Original line number Diff line number Diff line Loading @@ -101,4 +101,26 @@ public function testDependencies(): void { $this->assertSame($expected, $action->calculateDependencies()->getDependencies()); } /** * Tests no type specified action. */ public function testNoTypeAction(): void { // Create an action config entity using the action_test_no_type plugin. $action = Action::create([ 'id' => 'action_test_no_type_action', 'label' => 'Test Action with No Type', 'plugin' => 'action_test_no_type', ]); $action->save(); // Reload the action to ensure it's saved correctly. $action = Action::load('action_test_no_type_action'); // Assert that the action was saved and loaded correctly. $this->assertNotNull($action, 'The action config entity was saved and loaded correctly.'); $this->assertSame('action_test_no_type_action', $action->id(), 'The action ID is correct.'); $this->assertSame('Test Action with No Type', $action->label(), 'The action label is correct.'); $this->assertNull($action->getType(), 'The action type is correctly set to NULL.'); } } Loading
core/modules/system/config/schema/system.schema.yml +8 −0 Original line number Diff line number Diff line Loading @@ -286,6 +286,8 @@ system.menu.*: system.action.*: type: config_entity label: 'System action' constraints: FullyValidatable: ~ mapping: id: type: machine_name Loading @@ -302,6 +304,12 @@ system.action.*: type: type: string label: 'Type' # Action can be specified without type. # @see \Drupal\action_test\Plugin\Action\NoType nullable: true constraints: NotBlank: allowNull: true plugin: type: string label: 'Plugin' Loading
core/modules/system/src/ActionConfigEntityInterface.php +4 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,10 @@ public function isConfigurable(); /** * Returns the operation type. * * @return string * The operation type can be NULL if no type is specified. * * @return string|null * The operation type, or NULL if no type is specified. */ public function getType(); Loading
core/modules/system/src/Entity/Action.php +2 −2 Original line number Diff line number Diff line Loading @@ -57,9 +57,9 @@ class Action extends ConfigEntityBase implements ActionConfigEntityInterface, En /** * The action type. * * @var string * @var string|null */ protected $type; protected $type = NULL; /** * The configuration of the action. Loading
core/modules/system/tests/modules/action_test/config/schema/action_test.schema.yml 0 → 100644 +6 −0 Original line number Diff line number Diff line # Schema for the configuration files of the Action test module. action.configuration.action_test_no_type: type: mapping label: 'Configuration for action_test_no_type plugin' mapping: {}
core/modules/system/tests/src/Kernel/Action/ActionTest.php +22 −0 Original line number Diff line number Diff line Loading @@ -101,4 +101,26 @@ public function testDependencies(): void { $this->assertSame($expected, $action->calculateDependencies()->getDependencies()); } /** * Tests no type specified action. */ public function testNoTypeAction(): void { // Create an action config entity using the action_test_no_type plugin. $action = Action::create([ 'id' => 'action_test_no_type_action', 'label' => 'Test Action with No Type', 'plugin' => 'action_test_no_type', ]); $action->save(); // Reload the action to ensure it's saved correctly. $action = Action::load('action_test_no_type_action'); // Assert that the action was saved and loaded correctly. $this->assertNotNull($action, 'The action config entity was saved and loaded correctly.'); $this->assertSame('action_test_no_type_action', $action->id(), 'The action ID is correct.'); $this->assertSame('Test Action with No Type', $action->label(), 'The action label is correct.'); $this->assertNull($action->getType(), 'The action type is correctly set to NULL.'); } }