Skip to content
Snippets Groups Projects
Commit a10a712f authored by Jess's avatar Jess
Browse files

Issue #3043825 by tim.plunkett, johndevman, phenaproxima: Create an interface...

Issue #3043825 by tim.plunkett, johndevman, phenaproxima: Create an interface for LayoutBuilderSampleEntityGenerator
parent f4f60261
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -8,13 +8,8 @@
/**
* Generates a sample entity for use by the Layout Builder.
*
* @internal
* Layout Builder is currently experimental and should only be leveraged by
* experimental modules and development releases of contributed modules.
* See https://www.drupal.org/core/experimental for more information.
*/
class LayoutBuilderSampleEntityGenerator {
class LayoutBuilderSampleEntityGenerator implements SampleEntityGeneratorInterface {
/**
* The shared tempstore factory.
......@@ -44,15 +39,7 @@ public function __construct(SharedTempStoreFactory $temp_store_factory, EntityTy
}
/**
* Gets a sample entity for a given entity type and bundle.
*
* @param string $entity_type_id
* The entity type ID.
* @param string $bundle_id
* The bundle ID.
*
* @return \Drupal\Core\Entity\EntityInterface
* An entity.
* {@inheritdoc}
*/
public function get($entity_type_id, $bundle_id) {
$tempstore = $this->tempStoreFactory->get('layout_builder.sample_entity');
......@@ -73,14 +60,7 @@ public function get($entity_type_id, $bundle_id) {
}
/**
* Deletes a sample entity for a given entity type and bundle.
*
* @param string $entity_type_id
* The entity type ID.
* @param string $bundle_id
* The bundle ID.
*
* @return $this
* {@inheritdoc}
*/
public function delete($entity_type_id, $bundle_id) {
$tempstore = $this->tempStoreFactory->get('layout_builder.sample_entity');
......
<?php
namespace Drupal\layout_builder\Entity;
/**
* Generates a sample entity.
*/
interface SampleEntityGeneratorInterface {
/**
* Gets a sample entity for a given entity type and bundle.
*
* @param string $entity_type_id
* The entity type ID.
* @param string $bundle_id
* The bundle ID.
*
* @return \Drupal\Core\Entity\EntityInterface
* An entity.
*/
public function get($entity_type_id, $bundle_id);
/**
* Deletes a sample entity for a given entity type and bundle.
*
* @param string $entity_type_id
* The entity type ID.
* @param string $bundle_id
* The bundle ID.
*
* @return $this
*/
public function delete($entity_type_id, $bundle_id);
}
......@@ -15,7 +15,7 @@
use Drupal\Core\Url;
use Drupal\field_ui\FieldUI;
use Drupal\layout_builder\DefaultsSectionStorageInterface;
use Drupal\layout_builder\Entity\LayoutBuilderSampleEntityGenerator;
use Drupal\layout_builder\Entity\SampleEntityGeneratorInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\RouteCollection;
......@@ -60,14 +60,14 @@ class DefaultsSectionStorage extends SectionStorageBase implements ContainerFact
/**
* The sample entity generator.
*
* @var \Drupal\layout_builder\Entity\LayoutBuilderSampleEntityGenerator
* @var \Drupal\layout_builder\Entity\SampleEntityGeneratorInterface
*/
protected $sampleEntityGenerator;
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, LayoutBuilderSampleEntityGenerator $sample_entity_generator) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, SampleEntityGeneratorInterface $sample_entity_generator) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityTypeManager = $entity_type_manager;
......
......@@ -9,8 +9,8 @@
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Plugin\Context\ContextInterface;
use Drupal\layout_builder\Entity\LayoutBuilderSampleEntityGenerator;
use Drupal\layout_builder\Entity\LayoutEntityDisplayInterface;
use Drupal\layout_builder\Entity\SampleEntityGeneratorInterface;
use Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage;
use Drupal\layout_builder\SectionStorage\SectionStorageDefinition;
use Drupal\Tests\UnitTestCase;
......@@ -41,7 +41,7 @@ class DefaultsSectionStorageTest extends UnitTestCase {
/**
* The sample entity generator.
*
* @var \Drupal\layout_builder\Entity\LayoutBuilderSampleEntityGenerator
* @var \Drupal\layout_builder\Entity\SampleEntityGeneratorInterface
*/
protected $sampleEntityGenerator;
......@@ -53,7 +53,7 @@ protected function setUp() {
$this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class);
$entity_type_bundle_info = $this->prophesize(EntityTypeBundleInfoInterface::class);
$this->sampleEntityGenerator = $this->prophesize(LayoutBuilderSampleEntityGenerator::class);
$this->sampleEntityGenerator = $this->prophesize(SampleEntityGeneratorInterface::class);
$definition = new SectionStorageDefinition([
'id' => 'defaults',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment