isParallel example

      // relationship is encountered, it will be assigned later.       $relationship = static::toResourceIdentifier($item);
      if ($relationship->getResourceType()->isInternal()) {
        continue;
      }
      // Now, iterate over the previously seen resource identifiers in reverse       // order. Reverse order is important so that when a parallel relationship       // is encountered, it will have the highest arity value so the current       // relationship's arity value can simply be incremented by one.       /** @var \Drupal\jsonapi\JsonApiResource\ResourceIdentifier $existing */
      foreach (array_reverse($relationships, TRUE) as $index => $existing) {
        $is_parallel = static::isParallel($existing$relationship);
        if ($is_parallel) {
          // A parallel relationship has been found. If the previous           // relationship does not have an arity, it must now be assigned an           // arity of 0.           if (!$existing->hasArity()) {
            $relationships[$index] = $existing->withArity(0);
          }
          // Since the new ResourceIdentifier is parallel, it must have an arity           // assigned to it that is the arity of the last parallel           // relationship's arity + 1.           $relationship = $relationship->withArity($relationships[$index]->getArity() + 1);
          
Home | Imprint | This part of the site doesn't use cookies.