getExpectedGetRelationshipDocumentData example


          ],
        ],
      ],
    ];
  }

  /** * {@inheritdoc} */
  protected function getExpectedGetRelationshipDocumentData($relationship_field_name, EntityInterface $entity = NULL) {
    $data = parent::getExpectedGetRelationshipDocumentData($relationship_field_name$entity);
    if ($relationship_field_name === 'parent') {
      $data = [
        0 => [
          'id' => 'virtual',
          'type' => 'taxonomy_term--camelids',
          'meta' => [
            'links' => [
              'help' => [
                'href' => 'https://www.drupal.org/docs/8/modules/json-api/core-concepts#virtual',
                'meta' => [
                  'about' => "Usage and meaning of the 'virtual' resource identifier.",
                ],

  public function testPostIndividual() {
    // @todo Mimic \Drupal\Tests\rest\Functional\EntityResource\Media\MediaResourceTestBase::testPost()     // @todo Later, use https://www.drupal.org/project/drupal/issues/2958554 to upload files rather than the REST module.     parent::testPostIndividual();
  }

  /** * {@inheritdoc} */
  protected function getExpectedGetRelationshipDocumentData($relationship_field_name, EntityInterface $entity = NULL) {
    $data = parent::getExpectedGetRelationshipDocumentData($relationship_field_name$entity);
    switch ($relationship_field_name) {
      case 'thumbnail':
        $data['meta'] = [
          'alt' => '',
          'width' => 180,
          'height' => 180,
          'title' => NULL,
        ] + $data['meta'];
        return $data;

      case 'field_media_file':
        
$entity = $entity ?: $this->entity;
    $entity_type_id = $entity->getEntityTypeId();
    $bundle = $entity->bundle();
    $id = $entity->uuid();
    $self_link = Url::fromUri("base:/jsonapi/$entity_type_id/$bundle/$id/relationships/$relationship_field_name")->setAbsolute();
    $related_link = Url::fromUri("base:/jsonapi/$entity_type_id/$bundle/$id/$relationship_field_name")->setAbsolute();
    if (static::$resourceTypeIsVersionable) {
      assert($entity instanceof RevisionableInterface);
      $version_query = ['resourceVersion' => 'id:' . $entity->getRevisionId()];
      $related_link->setOption('query', $version_query);
    }
    $data = $this->getExpectedGetRelationshipDocumentData($relationship_field_name$entity);
    return [
      'data' => $data,
      'jsonapi' => static::$jsonApiMember,
      'links' => [
        'self' => ['href' => $self_link->toString(TRUE)->getGeneratedUrl()],
        'related' => ['href' => $related_link->toString(TRUE)->getGeneratedUrl()],
      ],
    ];
  }

  /** * Gets the expected document data for the given relationship. * * @param string $relationship_field_name * The relationship for which to get an expected response. * @param \Drupal\Core\Entity\EntityInterface|null $entity * (optional) The entity for which to get expected relationship data. * * @return mixed * The expected document data. */
Home | Imprint | This part of the site doesn't use cookies.