Commit 2ebc7d39 authored by Julian Pustkuchen's avatar Julian Pustkuchen
Browse files

Issue #3261150 by Anybody: [UPGRADE] Create submodule to migrate paragraph...

Issue #3261150 by Anybody: [UPGRADE] Create submodule to migrate paragraph type container to layout (layout paragraphs) [1.x, 2.x]
parent 00763e67
Loading
Loading
Loading
Loading
+19 −9
Original line number Diff line number Diff line
@@ -322,10 +322,13 @@ class ParagraphsConverter implements ParagraphsConverterInterface {
    }

    $entityTypeStorage = $this->entityTypeManager->getStorage($entity_type);
    $query = $entityTypeStorage->getQuery();
    $query->condition('type', $entity_bundle);
    $results = $query->execute();
    $entities = $entityTypeStorage->loadMultiple($results);
    if ($entity_type == 'taxonomy_term') {
      // Taxonomy Terms use "vid" instead of "type" standard sadly due to historic reasons.
      $entities = $entityTypeStorage->loadByProperties(['vid' => $entity_bundle]);
    } else {
      $entities = $entityTypeStorage->loadByProperties(['type' => $entity_bundle]);
    }

    if (!empty($entities)) {
      /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
      foreach ($entities as $entity) {
@@ -691,9 +694,13 @@ class ParagraphsConverter implements ParagraphsConverterInterface {
  protected function handleSublevelParagraphs(Paragraph $containerParagraph, EntityReferenceRevisionsFieldItemList $masterEntityReferenceRevisions) {
    [$layoutName, $positionsArray, $columnWidths, $rows] = $this->determineLayoutAndPositions($containerParagraph);

    $subParagraphs = [];

    /** @var \Drupal\entity_reference_revisions\EntityReferenceRevisionsFieldItemList $referencedParagraphs */
    if ($containerParagraph->hasField(self::SUBPARAGRAPHS_FIELDNAME)) {
      $containerSubparagraphsReferenceRevisions = $containerParagraph->get(self::SUBPARAGRAPHS_FIELDNAME);
      $subParagraphs = $containerSubparagraphsReferenceRevisions->referencedEntities();
    }
    foreach ($subParagraphs as $delta => $subParagraph) {
      if (!empty($subParagraph->getAllBehaviorSettings()['layout_paragraphs'])) {
        // Skip this paragraph if it already has layout paragraphs behavior settings.
@@ -795,9 +802,12 @@ class ParagraphsConverter implements ParagraphsConverterInterface {
    $rows = 0;
    $colPos = 0;

    $subParagraphs = [];
    if ($containerParagraph->hasField(self::SUBPARAGRAPHS_FIELDNAME)) {
      /** @var \Drupal\entity_reference_revisions\EntityReferenceRevisionsFieldItemList $referencedParagraphs */
      $containerSubparagraphsReferenceRevisions = $containerParagraph->get(self::SUBPARAGRAPHS_FIELDNAME);
      $subParagraphs = $containerSubparagraphsReferenceRevisions->referencedEntities();
    }
    $subParagraphsCount = count($subParagraphs);

    // Following is only required if we have more than one subparagraph.