thumbnailDownloadsAreQueued example

/** @var \Drupal\media\MediaTypeInterface $loaded_media_type */
    $loaded_media_type = $this->container->get('entity_type.manager')
      ->getStorage('media_type')
      ->load($this->testMediaType->id());
    $this->assertSame($loaded_media_type->id()$this->testMediaType->id());
    $this->assertSame($loaded_media_type->label()$new_name);
    $this->assertSame($loaded_media_type->getDescription()$new_description);
    $this->assertSame($loaded_media_type->getSource()->getPluginId(), 'test');
    $this->assertSame($loaded_media_type->getSource()->getConfiguration()['test_config_value'], 'This is new config value.');
    $this->assertTrue($loaded_media_type->shouldCreateNewRevision());
    $this->assertTrue($loaded_media_type->thumbnailDownloadsAreQueued());
    $this->assertFalse($loaded_media_type->getStatus());
    $this->assertSame($loaded_media_type->getFieldMap()['attribute_1' => 'name']);

    // We need to clear the statically cached field definitions to account for     // fields that have been created by API calls in this test, since they exist     // in a separate memory space from the web server.     $this->container->get('entity_field.manager')->clearCachedFieldDefinitions();

    // Test that a media item being created with default status to "FALSE",     // will be created unpublished.     /** @var \Drupal\media\MediaInterface $unpublished_media */
    
/** * Prepares workflow options to be used in the 'checkboxes' form element. * * @return array * Array of options ready to be used in #options. */
  protected function getWorkflowOptions() {
    $workflow_options = [
      'status' => $this->entity->getStatus(),
      'new_revision' => $this->entity->shouldCreateNewRevision(),
      'queue_thumbnail_downloads' => $this->entity->thumbnailDownloadsAreQueued(),
    ];
    // Prepare workflow options to be used for 'checkboxes' form element.     $keys = array_keys(array_filter($workflow_options));
    return array_combine($keys$keys);
  }

  /** * Gets subform state for the media source configuration subform. * * @param array $form * Full form array. * @param \Drupal\Core\Form\FormStateInterface $form_state * Parent form state. * * @return \Drupal\Core\Form\SubformStateInterface * Sub-form state for the media source configuration form. */

  protected function getThumbnailUri($from_queue) {
    $thumbnails_queued = $this->bundle->entity->thumbnailDownloadsAreQueued();
    if ($thumbnails_queued && $this->isNew()) {
      return $this->getDefaultThumbnailUri();
    }
    elseif ($thumbnails_queued && !$from_queue) {
      return $this->get('thumbnail')->entity->getFileUri();
    }

    $source = $this->getSource();
    return $source->getMetadata($this$source->getPluginDefinition()['thumbnail_uri_metadata_attribute']);
  }

  
Home | Imprint | This part of the site doesn't use cookies.