diff --git a/src/Entity/HelpTopic.php b/src/Entity/HelpTopic.php index a6a1d23..ebc340a 100644 --- a/src/Entity/HelpTopic.php +++ b/src/Entity/HelpTopic.php @@ -55,6 +55,15 @@ use Drupal\config_help\TextSectionPluginCollection; * "id" = "id", * "label" = "label" * }, + * config_export = { + * "id", + * "label", + * "body", + * "top_level", + * "locked", + * "related", + * "list_on", + * }, * admin_permission = "administer help topics", * links = { * "canonical" = "/admin/help-topic/{help_topic}", @@ -67,7 +76,7 @@ use Drupal\config_help\TextSectionPluginCollection; * } * ) */ -class HelpTopic extends ConfigEntityBase implements HelpTopicInterface, EntityWithPluginCollectionInterface, \Serializable { +class HelpTopic extends ConfigEntityBase implements HelpTopicInterface, EntityWithPluginCollectionInterface { /** * The topic machine name. @@ -297,40 +306,4 @@ class HelpTopic extends ConfigEntityBase implements HelpTopicInterface, EntityWi return [$this->pluginCollection]; } - /** - * Implements serialization for this entity. - * - * @return string - * Serialized string, containing the configuration array. - * - * @todo Remove this if the generic serialization for config entities - * works instead. Issue: https://www.drupal.org/node/1977206 - */ - public function serialize() { - $values = $this->toArray(); - unset($values['pluginCollection']); - $data = [ - 'entity_type_id' => $this->getEntityTypeId(), - 'is_new' => $this->isNew(), - 'values' => $values, - ]; - return serialize(['_config_entity_serialize' => $data]); - } - - /** - * Implements unserialization for this entity. - * - * @param string $serialized - * Serialized data. - * - * @todo Remove this if the generic serialization for config entities - * works instead. Issue: https://www.drupal.org/node/1977206 - */ - public function unserialize($serialized) { - $unserialized = unserialize($serialized); - $data = $unserialized['_config_entity_serialize']; - $this->__construct($data['values'], $data['entity_type_id']); - $this->enforceIsNew($data['is_new']); - } - } diff --git a/tests/src/Functional/HelpTopicTest.php b/tests/src/Functional/HelpTopicTest.php index e7f1ca5..a4ef6f0 100644 --- a/tests/src/Functional/HelpTopicTest.php +++ b/tests/src/Functional/HelpTopicTest.php @@ -102,51 +102,6 @@ class HelpTopicTest extends BrowserTestBase { } /** - * Tests serialization of help topics. - * - * This has sometimes been a problem, and it causes trouble when using - * the Add new item button in the help topic editing form, which uses - * Ajax. - */ - public function testTopicSerialize() { - // Create a help topic entity. - $values = [ - 'id' => 'foo', - 'label' => 'Foo', - 'body' => [ - [ - 'type' => 'heading', - 'text' => 'Greetings', - ], - [ - 'type' => 'paragraph', - 'text' => 'Hello, world!', - ], - ], - 'top_level' => TRUE, - 'locked' => TRUE, - 'related' => ['config_help'], - 'list_on' => ['config_help_form'], - ]; - - /** @var \Drupal\config_help\HelpTopicInterface $foo */ - $foo = HelpTopic::create($values); - - // Serialize and unserialize it. - $foo_serialized = serialize($foo); - $bar = unserialize($foo_serialized); - - // Verify that everything is OK. - $this->assertTrue($bar instanceof HelpTopic, 'Unserialized object is correct class'); - $this->assertEqual($bar->id(), $values['id'], 'ID is correct after unserialize'); - $this->assertEqual($bar->getBody(), $values['body'], 'Body is correct after unserialize'); - $this->assertEqual($bar->isTopLevel(), $values['top_level'], 'Top level is correct after unserialize'); - $this->assertEqual($bar->isLocked(), $values['locked'], 'Locked is correct after unserialize'); - $this->assertEqual($bar->getRelated(), $values['related'], 'Related is correct after unserialize'); - $this->assertEqual($bar->getListOn(), $values['list_on'], 'List on is correct after unserialize'); - } - - /** * Verifies the logged in user has access to various help links and pages. * * @param int $response