Пример #1
0
 /**
  * Render form label.
  */
 protected function renderName($form_id, $values) {
   if ($form_id !== NULL && $form_id !== '') {
     $type = $this->formStorage->load($form_id);
     return $type ? $this->sanitizeValue($type->label()) : '';
   }
   return $this->sanitizeValue($form_id);
 }
Пример #2
0
  /**
   * {@inheritdoc}
   */
  public function applyEffect(ImageInterface $image) {
    if (empty($this->configuration['crop_type']) || !$this->typeStorage->load($this->configuration['crop_type'])) {
      $this->logger->error('Manual image crop failed due to misconfigured crop type on %path.', ['%path' => $image->getSource()]);
      return FALSE;
    }

    if ($crop = $this->getCrop($image)) {
      $anchor = $crop->anchor();
      $size = $crop->size();

      if (!$image->crop($anchor['x'], $anchor['y'], $size['width'], $size['height'])) {
        $this->logger->error('Manual image crop failed using the %toolkit toolkit on %path (%mimetype, %width x %height)', [
            '%toolkit' => $image->getToolkitId(),
            '%path' => $image->getSource(),
            '%mimetype' => $image->getMimeType(),
            '%width' => $image->getWidth(),
            '%height' => $image->getHeight(),
          ]
        );
        return FALSE;
      }
    }

    return TRUE;
  }
 /**
  * {@inheritdoc}
  */
 public function get($countryCode, $locale = NULL)
 {
     if ($locale) {
         $original_language = $this->languageManager->getConfigOverrideLanguage();
         $this->languageManager->setConfigOverrideLanguage(new Language(['id' => $locale]));
         $address_format = $this->formatStorage->load($countryCode);
         $this->languageManager->setConfigOverrideLanguage($original_language);
     } else {
         $address_format = $this->formatStorage->load($countryCode);
     }
     if (!$address_format) {
         // No format found for the given country code, fallback to ZZ.
         $address_format = $this->formatStorage->load('ZZ');
     }
     return $address_format;
 }
 /**
  * Sets allow_existing IEF setting.
  *
  * @param bool $flag
  *   "allow_existing" flag to be set.
  */
 protected function setAllowExisting($flag) {
   /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $display */
   $display = $this->entityFormDisplayStorage->load('node.ief_test_complex.default');
   $component = $display->getComponent('multi');
   $component['settings']['allow_existing'] = $flag;
   $display->setComponent('multi', $component)->save();
 }
  /**
   * Set up the ief_test_nested1 node add form.
   *
   * Sets the nested fields' required settings.
   * Gets the form.
   * Opens the inline entity forms if they are not required.
   *
   * @param boolean $required
   *  Whether the fields are required.
   */
  protected function setupNestedComplexForm($required) {
    /** @var \Drupal\Core\Field\FieldConfigInterface $ief_test_nested1 */
    $ief_test_nested1 = $this->fieldConfigStorage->load('node.ief_test_nested1.test_ref_nested1');
    $ief_test_nested1->setRequired($required);
    $ief_test_nested1->save();
    /** @var \Drupal\Core\Field\FieldConfigInterface $ief_test_nested2 */
    $ief_test_nested2 = $this->fieldConfigStorage->load('node.ief_test_nested2.test_ref_nested2');
    $ief_test_nested2->setRequired($required);
    $ief_test_nested2->save();

    $this->drupalGet('node/add/ief_test_nested1');

    if (!$required) {
      // Open inline forms if not required.
      $this->drupalPostAjaxForm(NULL, [], $this->getButtonName('//input[@type="submit" and @value="Add new node 2"]'));
      $this->drupalPostAjaxForm(NULL, [], $this->getButtonName('//input[@type="submit" and @value="Add new node 3"]'));
    }
  }
Пример #6
0
 /**
  * @covers ::filter
  */
 public function testFilterRequestAttributes()
 {
     $route_collection = new RouteCollection();
     $request = new Request([], [], ['foo' => 'bar', 'slug' => 2]);
     $route = new Route('/path/with/{slug}', ['page_manager_page_variant' => 'a_variant']);
     $route_collection->add('a_route', $route);
     $page_variant = $this->prophesize(PageVariantInterface::class);
     $page_variant->access('view')->willReturn(TRUE);
     $this->currentPath->getPath($request)->willReturn('/path/with/1');
     $this->pageVariantStorage->load('a_variant')->willReturn($page_variant->reveal());
     $route_enhancer = $this->prophesize(RouteEnhancerInterface::class);
     $this->routeFilter->addRouteEnhancer($route_enhancer->reveal());
     $result_enhance_attributes = $expected_enhance_attributes = ['foo' => 'bar', 'slug' => '1', 'page_manager_page_variant' => 'a_variant', '_route_object' => $route, '_route' => 'a_route'];
     $result_enhance_attributes['slug'] = 'slug 1';
     $route_enhancer->enhance($expected_enhance_attributes, $request)->willReturn($result_enhance_attributes);
     $result = $this->routeFilter->filter($route_collection, $request);
     $expected = ['a_route' => $route];
     $this->assertSame($expected, $result->all());
     $expected_attributes = ['foo' => 'bar', 'slug' => 'slug 1', 'page_manager_page_variant' => 'a_variant', '_route_object' => $route, '_route' => 'a_route'];
     $this->assertSame($expected_attributes, $request->attributes->all());
 }
Пример #7
0
 /**
  * Returns the vocabulary configured for forums.
  *
  * @return \Drupal\taxonomy\VocabularyInterface
  *   The vocabulary entity for forums.
  */
 protected function getForumVocabulary()
 {
     $vid = $this->configFactory->get('forum.settings')->get('vocabulary');
     return $this->vocabularyStorage->load($vid);
 }
Пример #8
0
 /**
  * {@inheritdoc}
  */
 public function get($id)
 {
     return $this->zoneStorage->load($id);
 }
 /**
  * Tests whether deleting an index works correctly.
  *
  * @param \Drupal\search_api\IndexInterface $index
  *   The index used for the test.
  */
 public function indexDelete(IndexInterface $index)
 {
     $this->storage->delete(array($index));
     $loaded_index = $this->storage->load($index->id());
     $this->assertNull($loaded_index);
 }
Пример #10
0
 /**
  * Tests whether deleting a server works correctly.
  *
  * @param \Drupal\search_api\ServerInterface $server
  *   The server used for this test.
  */
 public function serverDelete(ServerInterface $server)
 {
     $this->storage->delete(array($server));
     $loaded_server = $this->storage->load($server->id());
     $this->assertNull($loaded_server);
 }