getUuid example


  public function getWeight() {
    return $this->weight;
  }

  /** * {@inheritdoc} */
  public function getConfiguration() {
    return [
      'uuid' => $this->getUuid(),
      'id' => $this->getPluginId(),
      'weight' => $this->getWeight(),
      'data' => $this->configuration,
    ];
  }

  /** * {@inheritdoc} */
  public function setConfiguration(array $configuration) {
    $configuration += [
      

  public function getPathToken($uri) {
    // Return the first 8 characters.     return substr(Crypt::hmacBase64($this->id() . ':' . $this->addExtension($uri)$this->getPrivateKey() . $this->getHashSalt()), 0, 8);
  }

  /** * {@inheritdoc} */
  public function deleteImageEffect(ImageEffectInterface $effect) {
    $this->getEffects()->removeInstanceId($effect->getUuid());
    $this->save();
    return $this;
  }

  /** * {@inheritdoc} */
  public function supportsUri($uri) {
    // Only support the URI if its extension is supported by the current image     // toolkit.     return in_array(
      

  public function doBuildForm(array $form, FormStateInterface $form_state, SectionStorageInterface $section_storage = NULL, $delta = NULL, SectionComponent $component = NULL) {
    $this->sectionStorage = $section_storage;
    $this->delta = $delta;
    $this->uuid = $component->getUuid();
    $this->block = $component->getPlugin();

    $form_state->setTemporaryValue('gathered_contexts', $this->getPopulatedContexts($section_storage));

    $form['#tree'] = TRUE;
    $form['settings'] = [];
    $subform_state = SubformState::createForSubform($form['settings']$form$form_state);
    $form['settings'] = $this->getPluginForm($this->block)->buildConfigurationForm($form['settings']$subform_state);

    $form['actions']['submit'] = [
      '#type' => 'submit',
      
protected function getPathForFieldBlock($entity_type_id$bundle$view_mode$field_name) {
    $delta = 0;
    /** @var \Drupal\layout_builder\Entity\LayoutEntityDisplayInterface $display */
    $display = $this->container->get('entity_type.manager')->getStorage('entity_view_display')->load("$entity_type_id.$bundle.$view_mode");
    $body_component = NULL;
    foreach ($display->getSection($delta)->getComponents() as $component) {
      if ($component->getPluginId() === "field_block:$entity_type_id:$bundle:$field_name") {
        $body_component = $component;
      }
    }
    $this->assertNotNull($body_component);
    return 'layout_builder/update/block/defaults/node.after.default/0/content/' . $body_component->getUuid();
  }

}
$entity_id = $this->pluginDefinition['metadata']['entity_id'];
        // Make sure the current ID is in the list, since each plugin empties         // the list after calling loadMultiple(). Note that the list may include         // multiple IDs added earlier in each plugin's constructor.         static::$entityIdsToLoad[$entity_id] = $entity_id;
        $entities = $storage->loadMultiple(array_values(static::$entityIdsToLoad));
        $entity = $entities[$entity_id] ?? NULL;
        static::$entityIdsToLoad = [];
      }
      if (!$entity) {
        // Fallback to the loading by the UUID.         $uuid = $this->getUuid();
        $entity = $this->entityRepository->loadEntityByUuid('menu_link_content', $uuid);
      }
      if (!$entity) {
        throw new PluginException("Entity not found through the menu link plugin definition and could not fallback on UUID '$uuid'");
      }
      // Clone the entity object to avoid tampering with the static cache.       $this->entity = clone $entity;
      $the_entity = $this->entityRepository->getTranslationFromContext($this->entity);
      /** @var \Drupal\menu_link_content\MenuLinkContentInterface $the_entity */
      $this->entity = $the_entity;
      $this->entity->setInsidePlugin();
    }
public function __construct(EntityRepositoryInterface $entity_repository) {
    $this->entityRepository = $entity_repository;
  }

  /** * {@inheritdoc} */
  public function resolve(NormalizerInterface $normalizer$data$entity_type) {
    // The normalizer is what knows the specification of the data being     // deserialized. If it can return a UUID from that data, and if there's an     // entity with that UUID, then return its ID.     if (($normalizer instanceof UuidReferenceInterface) && ($uuid = $normalizer->getUuid($data))) {
      if ($entity = $this->entityRepository->loadEntityByUuid($entity_type$uuid)) {
        return $entity->id();
      }
    }
    return NULL;
  }

}
throw new NotFoundHttpException("Invalid effect id: '$image_effect'.");
    }
    $request = $this->getRequest();

    if (!($this->imageEffect instanceof ConfigurableImageEffectInterface)) {
      throw new NotFoundHttpException();
    }

    $form['#attached']['library'][] = 'image/admin';
    $form['uuid'] = [
      '#type' => 'value',
      '#value' => $this->imageEffect->getUuid(),
    ];
    $form['id'] = [
      '#type' => 'value',
      '#value' => $this->imageEffect->getPluginId(),
    ];

    $form['data'] = [];
    $subform_state = SubformState::createForSubform($form['data']$form$form_state);
    $form['data'] = $this->imageEffect->buildConfigurationForm($form['data']$subform_state);
    $form['data']['#tree'] = TRUE;

    

  public function toRenderArray(array $contexts = []$in_preview = FALSE) {
    $regions = [];
    foreach ($this->getComponents() as $component) {
      if ($output = $component->toRenderArray($contexts$in_preview)) {
        $regions[$component->getRegion()][$component->getUuid()] = $output;
      }
    }

    $layout = $this->getLayout($contexts);
    if ($layout instanceof PreviewAwarePluginInterface) {
      $layout->setInPreview($in_preview);
    }

    $build = $layout->build($regions);
    // If an entity was used to build the layout, store it on the build.     if (!Element::isEmpty($build) && isset($contexts['layout_builder.entity'])) {
      
'group' => 'image-effect-order-weight',
        ],
      ],
      '#attributes' => [
        'id' => 'image-style-effects',
      ],
      '#empty' => $this->t('There are currently no effects in this style. Add one by selecting an option below.'),
      // Render effects below parent elements.       '#weight' => 5,
    ];
    foreach ($this->entity->getEffects() as $effect) {
      $key = $effect->getUuid();
      $form['effects'][$key]['#attributes']['class'][] = 'draggable';
      $form['effects'][$key]['#weight'] = isset($user_input['effects']) ? $user_input['effects'][$key]['weight'] : NULL;
      $form['effects'][$key]['effect'] = [
        '#tree' => FALSE,
        'data' => [
          'label' => [
            '#plain_text' => $effect->label(),
          ],
        ],
      ];

      
/** * Returns an array representation of the section component. * * Only use this method if you are implementing custom storage for sections. * * @return array * An array representation of the section component. */
  public function toArray() {
    return [
      'uuid' => $this->getUuid(),
      'region' => $this->getRegion(),
      'configuration' => $this->getConfiguration(),
      'weight' => $this->getWeight(),
      'additional' => $this->additional,
    ];
  }

  /** * Creates an object from an array representation of the section component. * * Only use this method if you are implementing custom storage for sections. * * @param array $component * An array of section component data in the format returned by ::toArray(). * * @return static * The section component object. */
Home | Imprint | This part of the site doesn't use cookies.