diff --git a/src/DisplayBase.php b/src/DisplayBase.php index e86eae8..1a87c8c 100644 --- a/src/DisplayBase.php +++ b/src/DisplayBase.php @@ -7,6 +7,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\Core\Site\Settings; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -157,7 +158,7 @@ abstract class DisplayBase extends PluginBase implements DisplayInterface, Conta // If the existing selection was passed in save it to expirable state for // the entity browser to be able to load them from there. if (!empty($entities)) { - $this->selectionStorage->set($this->getUuid(), $entities); + $this->selectionStorage->setWithExpire($this->getUuid(), $entities, Settings::get('entity_browser_expire', 21600)); } } diff --git a/src/DisplayInterface.php b/src/DisplayInterface.php index d142f68..7513852 100644 --- a/src/DisplayInterface.php +++ b/src/DisplayInterface.php @@ -37,7 +37,7 @@ interface DisplayInterface extends PluginInspectionInterface, ConfigurablePlugin * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state object. * @param \Drupal\Core\Entity\EntityInterface[] $entities - * Existing selection that should be passed to the entity browser. + * (optional) Existing selection that should be passed to the entity browser. * * @return array * An array suitable for drupal_render(). diff --git a/src/Form/EntityBrowserForm.php b/src/Form/EntityBrowserForm.php index cf5f4db..ae3a12a 100644 --- a/src/Form/EntityBrowserForm.php +++ b/src/Form/EntityBrowserForm.php @@ -9,7 +9,6 @@ use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; use Drupal\entity_browser\DisplayAjaxInterface; use Drupal\entity_browser\EntityBrowserFormInterface; use Drupal\entity_browser\EntityBrowserInterface; -use Drupal\entity_browser\EntityCollection; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -47,7 +46,6 @@ class EntityBrowserForm extends FormBase implements EntityBrowserFormInterface { public function __construct(UuidInterface $uuid_generator, KeyValueStoreExpirableInterface $selection_storage) { $this->uuidGenerator = $uuid_generator; $this->selectionStorage = $selection_storage; - } /** diff --git a/tests/src/Kernel/Extension/EntityBrowserTest.php b/tests/src/Kernel/Extension/EntityBrowserTest.php index b91ca45..4fef471 100644 --- a/tests/src/Kernel/Extension/EntityBrowserTest.php +++ b/tests/src/Kernel/Extension/EntityBrowserTest.php @@ -357,7 +357,7 @@ class EntityBrowserTest extends KernelTestBase { ->getCurrentRequest() ->query ->set('uuid', $uuid); - $this->container->get('entity_browser.selection_storage')->set($uuid, [$user]); + $this->container->get('entity_browser.selection_storage')->setWithExpire($uuid, [$user], 21600); /** @var \Drupal\entity_browser\EntityBrowserFormInterface $form_object */ $form_object = $entity->getFormObject();