/** * {@inheritdoc} */ public function render(ResultRow $values) { $value = $this->getValue($values); if ($value && ($country = $this->countryStorage->load($value))) { return $country->label(); } return ''; }
/** * {@inheritdoc} */ public function render(ResultRow $values) { $country_value = $this->getValue($values, 'country'); if ($country_value && ($country = $this->countryStorage->load($country_value))) { $zone_value = $this->getValue($values); if ($zone_value) { return $country->getZones()[$zone_value]; } } return ''; }
/** * Tests the deleting of blocks. */ protected function deleteTests() { $entity = $this->controller->load('test_block'); // Ensure that the storage isn't currently empty. $config_storage = $this->container->get('config.storage'); $config = $config_storage->listAll('block.block.'); $this->assertFalse(empty($config), 'There are blocks in config storage.'); // Delete the block. $entity->delete(); // Ensure that the storage is now empty. $config = $config_storage->listAll('block.block.'); $this->assertTrue(empty($config), 'There are no blocks in config storage.'); }
/** * Test selected event dispatch. */ public function testSelectedEvent() { $this->installConfig(['entity_browser_test']); /** @var $entity \Drupal\entity_browser\EntityBrowserInterface */ $entity = $this->controller->load('dummy_widget'); /** @var \Drupal\Core\Entity\EntityFormInterface $form_object */ $form_object = $this->container->get('entity.manager')->getFormObject($entity->getEntityTypeId(), 'entity_browser'); $form_object->setEntity($entity); $form_state = new FormState(); $entity->getWidgets()->get($entity->getFirstWidget())->entity = $entity; $this->container->get('form_builder')->buildForm($form_object, $form_state); $this->container->get('form_builder')->submitForm($form_object, $form_state); // Event should be dispatched from widget and added to list of selected entities. $selected_entities = $form_state->get(['entity_browser', 'selected_entities']); $this->assertEquals($selected_entities, [$entity], 'Expected selected entities detected.'); }