Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function render(ResultRow $values)
 {
     $value = $this->getValue($values);
     if ($value && ($country = $this->countryStorage->load($value))) {
         return $country->label();
     }
     return '';
 }
Esempio n. 2
0
 /**
  * {@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 installation of default blocks.
  */
 public function testDefaultBlocks()
 {
     $entities = $this->controller->loadMultiple();
     $this->assertTrue(empty($entities), 'There are no blocks initially.');
     // Install the block_test.module, so that its default config is installed.
     $this->installConfig(array('block_test'));
     $entities = $this->controller->loadMultiple();
     $entity = reset($entities);
     $this->assertEqual($entity->id(), 'test_block', 'The default test block was loaded.');
 }
Esempio n. 4
0
 /**
  * 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.');
 }
Esempio n. 5
0
  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();

    /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
    $entity_type_manager = $this->container->get('entity_type.manager');
    $this->cropStorage = $entity_type_manager->getStorage('crop');
    $this->cropTypeStorage = $entity_type_manager->getStorage('crop_type');
    $this->imageStyleStorage = $entity_type_manager->getStorage('image_style');
    $this->fileStorage = $entity_type_manager->getStorage('file');

    // Create DB schemas.
    /** @var \Drupal\Core\Entity\EntityTypeListenerInterface $entity_type_listener */
    $entity_type_listener = $this->container->get('entity_type.listener');
    $entity_type_listener->onEntityTypeCreate($entity_type_manager->getDefinition('user'));
    $entity_type_listener->onEntityTypeCreate($entity_type_manager->getDefinition('image_style'));
    $entity_type_listener->onEntityTypeCreate($entity_type_manager->getDefinition('crop'));
    $entity_type_listener->onEntityTypeCreate($entity_type_manager->getDefinition('file'));

    // Create test image style.
    $uuid = $this->container->get('uuid')->generate();
    $this->testStyle = $this->imageStyleStorage->create([
      'name' => 'test',
      'label' => 'Test image style',
      'effects' => [
        $uuid => [
          'id' => 'crop_crop',
          'data' => ['crop_type' => 'test_type'],
          'weight' => 0,
          'uuid' => $uuid,
        ]
      ],
    ]);
    $this->testStyle->save();

    // Create test crop type.
    $this->cropType = $this->cropTypeStorage->create([
      'id' => 'test_type',
      'label' => 'Test crop type',
      'description' => 'Some nice desc.',
    ]);
    $this->cropType->save();
  }