diff --git a/core/MAINTAINERS.txt b/core/MAINTAINERS.txt index 4df923d..c794c06 100644 --- a/core/MAINTAINERS.txt +++ b/core/MAINTAINERS.txt @@ -242,9 +242,6 @@ Help module Image module - Nathan Haug 'quicksketch' http://drupal.org/user/35821 -JSON-LD module -- Lin Clark 'linclark' http://drupal.org/user/396253 - Locale module - Gábor Hojtsy 'Gábor Hojtsy' http://drupal.org/user/4166 diff --git a/core/modules/jsonld/jsonld.info b/core/modules/jsonld/jsonld.info deleted file mode 100644 index 6e89779..0000000 --- a/core/modules/jsonld/jsonld.info +++ /dev/null @@ -1,7 +0,0 @@ -name = JSON-LD -description = Serializes entities using JSON-LD format. -package = Core -version = VERSION -core = 8.x -dependencies[] = rdf -dependencies[] = serialization diff --git a/core/modules/jsonld/jsonld.module b/core/modules/jsonld/jsonld.module deleted file mode 100644 index b839e88..0000000 --- a/core/modules/jsonld/jsonld.module +++ /dev/null @@ -1,20 +0,0 @@ -' . t('The JSON-LD module serializes entities to the JSON-LD data format. To request JSON-LD instead of HTML, a client should add an Accept header to the request. This module will respond with JSON-LD if the Accept header value is one of the following: application/ld+json, which returns an easy-to-use data structure which is compatible with many external schemas, and application/vnd.drupal.ld+json, which is more expressive and is appropriate for content staging.', array( - '@jsonld_org' => 'http://json-ld.org/', - )) . '

'; - return $output; - } -} diff --git a/core/modules/jsonld/lib/Drupal/jsonld/EventSubscriber/JsonldSubscriber.php b/core/modules/jsonld/lib/Drupal/jsonld/EventSubscriber/JsonldSubscriber.php deleted file mode 100644 index 38a06ec..0000000 --- a/core/modules/jsonld/lib/Drupal/jsonld/EventSubscriber/JsonldSubscriber.php +++ /dev/null @@ -1,42 +0,0 @@ -getRequest(); - $request->setFormat('drupal_jsonld', 'application/vnd.drupal.ld+json'); - $request->setFormat('jsonld', 'application/ld+json'); - } - - /** - * Registers the methods in this class that should be listeners. - * - * @return array - * An array of event listener definitions. - */ - static function getSubscribedEvents() { - $events[KernelEvents::REQUEST][] = array('onKernelRequest', 40); - return $events; - } - -} diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldBundle.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldBundle.php deleted file mode 100644 index 3024883..0000000 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldBundle.php +++ /dev/null @@ -1,72 +0,0 @@ - array( - 'jsonld' => 'Drupal\jsonld\JsonldEntityReferenceNormalizer', - ), - 'field_item' => array( - 'jsonld' => 'Drupal\jsonld\JsonldFieldItemNormalizer', - ), - // Entity. - 'entity' => array( - 'jsonld' => 'Drupal\jsonld\JsonldEntityNormalizer', - ), - // RDF Schema. - 'rdf_schema' => array( - 'jsonld' => 'Drupal\jsonld\JsonldRdfSchemaNormalizer', - ), - ); - - // Add Normalizers to service container. - foreach ($normalizers as $supported_class => $formats) { - foreach ($formats as $format => $normalizer_class) { - $container->register("serializer.normalizer.{$supported_class}.{$format}", $normalizer_class) - ->addArgument(new Reference('rdf.site_schema_manager')) - ->addArgument(new Reference('rdf.mapping_manager')) - ->addTag('normalizer', array('priority' => $priority)); - } - } - - // Add the encoder to the service container. Encoders can only specify which - // format they support in Encoder::supportsEncoding(). - $container->register('serializer.encoder.jsonld', 'Drupal\jsonld\JsonldEncoder') - ->addTag('encoder', array( - 'priority' => $priority, - 'format' => array( - 'jsonld' => 'JSON-LD', - 'drupal_jsonld' => 'Drupal JSON-LD', - ), - )); - - $container->register('jsonld.subscriber', 'Drupal\jsonld\EventSubscriber\JsonldSubscriber') - ->addTag('event_subscriber'); - } -} diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEncoder.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEncoder.php deleted file mode 100644 index 8aa289e..0000000 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEncoder.php +++ /dev/null @@ -1,40 +0,0 @@ -serializer, $this->siteSchemaManager); - - $attributes = $entity_wrapper->getProperties(); - $attributes = array( - '@id' => $entity_wrapper->getId(), - '@type' => $entity_wrapper->getTypeUri(), - ) + $attributes; - return $attributes; - } - - /** - * Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::denormalize() - * - * @throws \Symfony\Component\Serializer\Exception\UnexpectedValueException - */ - public function denormalize($data, $class, $format = null, array $context = array()) { - if (!isset($data['@type'])) { - throw new UnexpectedValueException('JSON-LD @type parameter must be included.'); - } - - // Every bundle has a type, identified by URI. The incoming data should - // either include a type URI from this site's schema, or one of the type - // URIs in the incoming data must map to a site schema URI when passed - // through the RDF mapping manager. - $type_uris = is_array($data['@type']) ? $data['@type'] : array($data['@type']); - // If the RDF mapping manager can find a match to a site schema URI, it - // will return the corresponding Typed Data ids. Otherwise, throw an - // exception. - // @todo The @types might be CURIEs or aliases. Expand before trying to map. - try { - $typed_data_ids = $this->rdfMappingManager->getTypedDataIdsFromTypeUris($type_uris); - } - catch (RdfMappingException $e) { - throw new UnexpectedValueException($e->getMessage(), 0, $e); - } - - $values = array( - 'type' => $typed_data_ids['bundle'], - ); - // If the data specifies a default language, use it to create the entity. - if (isset($data['langcode'])) { - $values['langcode'] = $data['langcode'][LANGUAGE_NOT_SPECIFIED][0]['value']; - } - // Otherwise, if the default language is not specified but there are - // translations of field values, explicitly set the entity's default - // language to the site's default language. This is required to enable - // field translation on this entity. - else if ($this->containsTranslation($data)) { - $values['langcode'] = language(LANGUAGE_TYPE_CONTENT)->langcode; - } - $entity = entity_create($typed_data_ids['entity_type'], $values); - // Make sure all empty entity fields default to NULL, so that afterwards it - // is possible to determine which fields were part of the data (even if they - // are empty). - foreach ($entity as $name => $field) { - if ($field->isEmpty()) { - $field->setValue(NULL); - } - } - - // For each attribute in the JSON-LD, add the values as fields to the newly - // created entity. It is assumed that the JSON attribute names are the same - // as the site's field names. - // @todo Possibly switch to URI expansion of attribute names. - foreach ($data as $fieldName => $incomingFieldValues) { - // Skip the JSON-LD specific terms, which start with '@'. - if ($fieldName[0] === '@') { - continue; - } - // If the incoming value is an empty array we set the property to mark it - // for deletion. - if (empty($incomingFieldValues) && is_array($incomingFieldValues)) { - $entity->{$fieldName} = array(); - } - - // Figure out the designated class for this field type, which is used by - // the Serializer to determine which Denormalizer to use. - // @todo Is there a better way to get the field type's associated class? - $fieldItemClass = get_class($entity->get($fieldName)->offsetGet(0)); - - // Iterate through the language keyed values and add them to the entity. - // The vnd.drupal.ld+json mime type will always use language keys, per - // http://drupal.org/node/1838700. - foreach ($incomingFieldValues as $langcode => $incomingFieldItems) { - $fieldValue = $this->serializer->denormalize($incomingFieldItems, $fieldItemClass, $format); - $entity->getTranslation($langcode) - ->set($fieldName, $fieldValue); - } - } - return $entity; - } - - /** - * Determine whether incoming data contains translated content. - * - * @param array $data - * The incoming data. - * - * @return bool - * Whether or not this data contains translated content. - */ - protected function containsTranslation($data) { - // Langcodes which do not represent a translation of the entity. - $defaultLangcodes = array( - LANGUAGE_DEFAULT, - LANGUAGE_NOT_SPECIFIED, - LANGUAGE_NOT_APPLICABLE, - language(LANGUAGE_TYPE_CONTENT)->langcode, - ); - - // Combine the langcodes from the field value keys in a single array. - $fieldLangcodes = array(); - foreach ($data as $propertyName => $property) { - //@todo Once @context has been added, check whether this property - // corresponds to an annotation instead. This will allow us to support - // incoming data that doesn't use language annotations. - if ('@' !== $propertyName[0]) { - $fieldLangcodes += array_keys($property); - } - } - - $translationLangcodes = array_diff($fieldLangcodes, $defaultLangcodes); - return !empty($translationLangcodes); - } -} diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityReferenceNormalizer.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityReferenceNormalizer.php deleted file mode 100644 index 28f47ef..0000000 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityReferenceNormalizer.php +++ /dev/null @@ -1,61 +0,0 @@ -entity, $format, $this->serializer, $this->siteSchemaManager); - return array( - '@id' => $entity_wrapper->getId(), - ); - } - - /** - * Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::denormalize() - */ - public function denormalize($data, $class, $format = null, array $context = array()) { - // @todo Support denormalization for Entity Reference. - return array(); - } - - /** - * Overrides \Drupal\jsonld\JsonldNormalizerBase::supportsDenormalization() - */ - public function supportsDenormalization($data, $type, $format = NULL) { - $reflection = new ReflectionClass($type); - return in_array($format, static::$format) && ($reflection->getName() == $this->supportedInterfaceOrClass || $reflection->isSubclassOf($this->supportedInterfaceOrClass)); - } - -} diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php deleted file mode 100644 index a2e49e3..0000000 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php +++ /dev/null @@ -1,130 +0,0 @@ -entity = $entity; - $this->format = $format; - $this->serializer = $serializer; - $this->siteSchemaManager = $site_schema_manager; - } - - /** - * Get the Entity's URI for the @id attribute. - * - * @return string - * The URI of the entity. - */ - public function getId() { - $uri_info = $this->entity->uri(); - return url($uri_info['path'], array('absolute' => TRUE)); - } - - /** - * Get the type URI. - * - * @todo Once RdfMappingManager has a mapOutputTypes event, use that instead - * of simply returning the site schema URI. - */ - public function getTypeUri() { - $entity_type = $this->entity->entityType(); - $bundle = $this->entity->bundle(); - switch ($this->format) { - case 'drupal_jsonld': - $schema_path = SiteSchema::CONTENT_DEPLOYMENT; - break; - case 'jsonld': - $schema_path = SiteSchema::SYNDICATION; - } - $schema = $this->siteSchemaManager->getSchema($schema_path); - return $schema->bundle($entity_type, $bundle)->getUri(); - } - - /** - * Get properties, excluding JSON-LD specific properties. - * - * @return array - * An array of properties structured as in JSON-LD. - */ - public function getProperties() { - // Properties to skip. - $skip = array('id'); - - // Create language map property structure. - foreach ($this->entity->getTranslationLanguages() as $langcode => $language) { - foreach ($this->entity->getTranslation($langcode) as $name => $field) { - $definition = $this->entity->getPropertyDefinition($name); - $langKey = empty($definition['translatable']) ? LANGUAGE_NOT_SPECIFIED : $langcode; - if (!$field->isEmpty()) { - $properties[$name][$langKey] = $this->serializer->normalize($field, $this->format); - } - } - } - - // Only return properties which are not in the $skip array. - return array_diff_key($properties, array_fill_keys($skip, '')); - } - -} diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldFieldItemNormalizer.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldFieldItemNormalizer.php deleted file mode 100644 index 1f1a1bb..0000000 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldFieldItemNormalizer.php +++ /dev/null @@ -1,42 +0,0 @@ -getPropertyValues(); - } - - /** - * Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::denormalize() - */ - public function denormalize($data, $class, $format = null, array $context = array()) { - // For most fields, the field items array should simply be returned as is. - return $data; - } - -} diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldNormalizerBase.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldNormalizerBase.php deleted file mode 100644 index 61741ee..0000000 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldNormalizerBase.php +++ /dev/null @@ -1,80 +0,0 @@ -siteSchemaManager = $site_schema_manager; - $this->rdfMappingManager = $rdf_mapping_manager; - } - - /** - * Implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize() - */ - public function supportsNormalization($data, $format = NULL) { - return is_object($data) && in_array($format, static::$format) && ($data instanceof $this->supportedInterfaceOrClass); - } - - /** - * Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization() - * - * This class doesn't implement DenormalizerInterface, but most of its child - * classes do, so this method is implemented at this level to reduce code - * duplication. - */ - public function supportsDenormalization($data, $type, $format = NULL) { - $reflection = new ReflectionClass($type); - return in_array($format, static::$format) && $reflection->implementsInterface($this->supportedInterfaceOrClass); - } -} diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldRdfSchemaNormalizer.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldRdfSchemaNormalizer.php deleted file mode 100644 index 9315a58..0000000 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldRdfSchemaNormalizer.php +++ /dev/null @@ -1,51 +0,0 @@ -getGraph(); - - foreach ($graph as $term_uri => $properties) { - // JSON-LD uses the @type keyword as a stand-in for rdf:type. Replace any - // use of rdf:type and move the type to the front of the property array. - if (isset($properties[RdfConstants::RDF_TYPE])) { - $properties = array( - '@type' => $properties[RdfConstants::RDF_TYPE], - ) + $properties; - } - unset($properties[RdfConstants::RDF_TYPE]); - - // Add the @id keyword to the front of the array. - $normalized[] = array( - '@id' => $term_uri, - ) + $properties; - } - - return $normalized; - } - -} diff --git a/core/modules/jsonld/lib/Drupal/jsonld/Tests/JsonldTestSetupHelper.php b/core/modules/jsonld/lib/Drupal/jsonld/Tests/JsonldTestSetupHelper.php deleted file mode 100644 index d0eb0c3..0000000 --- a/core/modules/jsonld/lib/Drupal/jsonld/Tests/JsonldTestSetupHelper.php +++ /dev/null @@ -1,96 +0,0 @@ -siteSchemaManager = new SiteSchemaManager(new DatabaseBackend('cache')); - // Construct RDF mapping manager. - $dispatcher = new EventDispatcher(); - $dispatcher->addSubscriber(new MappingSubscriber()); - $this->rdfMappingManager = new RdfMappingManager($dispatcher, $this->siteSchemaManager); - // Construct normalizers. - $this->normalizers = array( - 'entityreference' => new JsonldEntityReferenceNormalizer($this->siteSchemaManager, $this->rdfMappingManager), - 'field_item' => new JsonldFieldItemNormalizer($this->siteSchemaManager, $this->rdfMappingManager), - 'entity' => new JsonldEntityNormalizer($this->siteSchemaManager, $this->rdfMappingManager), - ); - $serializer = new Serializer($this->normalizers, array(new JsonldEncoder())); - $this->normalizers['entity']->setSerializer($serializer); - } - - /** - * Get Normalizers. - * - * @return array - * An array of normalizers, keyed by supported class or interface. - */ - public function getNormalizers() { - return $this->normalizers; - } - - /** - * Get the SiteSchemaManager object. - * - * @return \Drupal\rdf\SiteSchema\SiteSchemaManager - * The SiteSchemaManager, which is also injected into the Normalizers. - */ - public function getSiteSchemaManager() { - return $this->siteSchemaManager; - } - - /** - * Get the RdfMappingManager object. - * - * @return \Drupal\rdf\RdfMappingManager - * The RdfMappingManager, which is also injected into the Normalizers. - */ - public function getRdfMappingManager() { - return $this->rdfMappingManager; - } -} diff --git a/core/modules/jsonld/lib/Drupal/jsonld/Tests/NormalizeDenormalizeTest.php b/core/modules/jsonld/lib/Drupal/jsonld/Tests/NormalizeDenormalizeTest.php deleted file mode 100644 index a9e057d..0000000 --- a/core/modules/jsonld/lib/Drupal/jsonld/Tests/NormalizeDenormalizeTest.php +++ /dev/null @@ -1,213 +0,0 @@ - 'Normalize/Denormalize Test', - 'description' => "Test that entities can be normalized/denormalized in JSON-LD.", - 'group' => 'JSON-LD', - ); - } - - /** - * Add the normalizer to be tested. - */ - function setUp() { - parent::setUp(); - - $setup_helper = new JsonldTestSetupHelper(); - $this->normalizers = $setup_helper->getNormalizers(); - - // Add German as a language. - $language = new Language(array( - 'langcode' => 'de', - 'name' => 'Deutsch', - )); - language_save($language); - } - - /** - * Tests the normalize function. - */ - public function testNormalize() { - // Create a German entity. - $values = array( - 'langcode' => 'de', - 'name' => $this->randomName(), - 'user_id' => $GLOBALS['user']->uid, - 'field_test_text' => array( - 'value' => $this->randomName(), - 'format' => 'full_html', - ), - ); - // Array of translated values. - $translationValues = array( - 'name' => $this->randomName(), - ); - - $entity = entity_create('entity_test', $values); - $entity->save(); - // Add an English value for name property. - $entity->getTranslation('en')->set('name', array(0 => array('value' => $translationValues['name']))); - - $expectedArray = array( - '@id' => $this->getEntityId($entity), - 'uuid' => array( - 'und' => array( - array( - 'value' => $entity->uuid(), - ), - ), - ), - 'user_id' => array( - 'de' => array( - array( - '@id' => url('user/' . $values['user_id'], array('absolute' => TRUE)), - ), - ), - ), - 'name' => array( - 'de' => array( - array( - 'value' => $values['name'], - ), - ), - 'en' => array( - array( - 'value' => $translationValues['name'], - ), - ), - ), - 'field_test_text' => array( - 'und' => array( - array( - 'value' => $values['field_test_text']['value'], - 'format' => $values['field_test_text']['format'], - ), - ), - ), - ); - - $normalized = $this->normalizers['entity']->normalize($entity, static::$format); - // Test ordering. The @context and @id properties should always be first. - $keys = array_keys($normalized); - $this->assertEqual($keys[0], '@id', '@id and @context attributes placed correctly.'); - // Test @id value. - $this->assertEqual($normalized['@id'], $expectedArray['@id'], '@id uses correct value.'); - // Test non-translatable field. - $this->assertEqual($normalized['uuid'], $expectedArray['uuid'], 'Non-translatable fields are nested correctly.'); - // Test single-language translatable. - $this->assertEqual($normalized['user_id'], $expectedArray['user_id'], 'Translatable field with single language value is nested correctly.'); - // Test multi-language translatable. - $this->assertEqual($normalized['name'], $expectedArray['name'], 'Translatable field with multiple language values is nested correctly.'); - // Test multi-property untranslatable field. - $this->assertEqual($normalized['field_test_text'], $expectedArray['field_test_text'], 'Field with properties is nested correctly.'); - } - - function testDenormalize() { - $schema = new SiteSchema(SiteSchema::CONTENT_DEPLOYMENT); - $bundle_uri = $schema->bundle('entity_test', 'entity_test')->getUri(); - $incoming_data = array( - '@type' => $bundle_uri, - 'name' => array( - 'en' => array( - array( - 'value' => $this->randomName(), - ), - ), - 'de' => array( - array( - 'value' => $this->randomName(), - ), - ), - ), - 'field_test_text' => array( - 'und' => array( - array( - 'value' => $this->randomName(), - 'format' => 'full_html', - ), - ), - ), - ); - - // Test valid request. - $entity = $this->normalizers['entity']->denormalize($incoming_data, 'Drupal\Core\Entity\EntityNG', static::$format); - $this->assertEqual('entity_test', $entity->bundle(), "Denormalize creates entity with correct bundle."); - $this->assertEqual($incoming_data['name']['en'], $entity->get('name')->getValue(), "Translatable field denormalized correctly in default language."); - $this->assertEqual($incoming_data['name']['de'], $entity->getTranslation('de')->get('name')->getValue(), "Translatable field denormalized correctly in translation language."); - $this->assertEqual($incoming_data['field_test_text']['und'], $entity->get('field_test_text')->getValue(), "Untranslatable field denormalized correctly."); - - // Test request without @type. - unset($incoming_data['@type']); - try { - $this->normalizers['entity']->denormalize($incoming_data, 'Drupal\Core\Entity\EntityNG', static::$format); - $this->fail('Trying to denormalize entity data without @type results in exception.'); - } - catch (UnexpectedValueException $e) { - $this->pass('Trying to denormalize entity data without @type results in exception.'); - } - - // Test request with @type that has no valid mapping. - $incoming_data['@type'] = 'http://failing-uri.com/type'; - try { - $this->normalizers['entity']->denormalize($incoming_data, 'Drupal\Core\Entity\EntityNG', static::$format); - $this->fail('Trying to denormalize entity data with unrecognized @type results in exception.'); - } - catch (UnexpectedValueException $e) { - $this->pass('Trying to denormalize entity data with unrecognized @type results in exception.'); - } - } - - /** - * Get the Entity ID. - * - * @param \Drupal\Core\Entity\EntityNG $entity - * Entity to get URI for. - * - * @return string - * Return the entity URI. - */ - protected function getEntityId($entity) { - global $base_url; - $uriInfo = $entity->uri(); - return $base_url . '/' . $uriInfo['path']; - } - -} diff --git a/core/modules/jsonld/lib/Drupal/jsonld/Tests/RdfSchemaSerializationTest.php b/core/modules/jsonld/lib/Drupal/jsonld/Tests/RdfSchemaSerializationTest.php deleted file mode 100644 index eacf9df..0000000 --- a/core/modules/jsonld/lib/Drupal/jsonld/Tests/RdfSchemaSerializationTest.php +++ /dev/null @@ -1,56 +0,0 @@ - 'Site schema JSON-LD serialization', - 'description' => 'Tests the JSON-LD serialization of the RDF site schema.', - 'group' => 'JSON-LD', - ); - } - - /** - * Tests the serialization of site schemas. - */ - function testSchemaSerialization() { - // url() requires the {url_alias} table. - $this->installSchema('system', 'url_alias'); - - $entity_type = $bundle = 'entity_test'; - - // Set up the bundle schema for the entity_test bundle. - $schema = new SiteSchema(SiteSchema::CONTENT_DEPLOYMENT); - $bundle_schema = $schema->bundle($entity_type, $bundle); - // Set up the serializer. - $setup_helper = new JsonldTestSetupHelper(); - $normalizer = new JsonldRdfSchemaNormalizer($setup_helper->getSiteSchemaManager(), $setup_helper->getRdfMappingManager()); - $serializer = new Serializer(array($normalizer), array(new JsonldEncoder())); - - $serialized = $serializer->serialize($bundle_schema, 'jsonld'); - $decoded = json_decode($serialized); - $parsed_term = $decoded[0]; - - $this->assertEqual($parsed_term->{'@id'}, $bundle_schema->getUri(), 'JSON-LD for schema term uses correct @id.'); - $this->assertEqual($parsed_term->{'@type'}, 'http://www.w3.org/2000/01/rdf-schema#class', 'JSON-LD for schema term uses correct @type.'); - // The @id and @type should be placed in the beginning of the array. - $array_keys = array_keys((array) $parsed_term); - $this->assertEqual(array('@id', '@type'), array_slice($array_keys, 0, 2), 'JSON-LD keywords are placed before other properties.'); - $this->assertTrue(isset($parsed_term->{'http://www.w3.org/2000/01/rdf-schema#isDefinedBy'}), 'Other properties of the term are included.'); - } -} diff --git a/core/modules/jsonld/lib/Drupal/jsonld/Tests/SupportsSerializationTest.php b/core/modules/jsonld/lib/Drupal/jsonld/Tests/SupportsSerializationTest.php deleted file mode 100644 index 38cee8a..0000000 --- a/core/modules/jsonld/lib/Drupal/jsonld/Tests/SupportsSerializationTest.php +++ /dev/null @@ -1,96 +0,0 @@ - 'Supports class/format serialization test', - 'description' => "Test that normalizers and encoders support expected classes and formats.", - 'group' => 'JSON-LD', - ); - } - - /** - * Add the normalizer to be tested. - */ - function setUp() { - parent::setUp(); - - $setup_helper = new JsonldTestSetupHelper(); - $this->normalizers = $setup_helper->getNormalizers(); - } - - /** - * Tests the supportsNormalization function. - */ - public function testSupportsNormalization() { - $format = static::$format; - $supportedEntity = entity_create('entity_test', array()); - $unsupportedEntity = new ConfigEntityTest(); - $field = $supportedEntity->get('uuid'); - $entityreferenceField = $supportedEntity->get('user_id'); - - // Supported entity. - $this->assertTrue($this->normalizers['entity']->supportsNormalization($supportedEntity, static::$format), "Entity normalization is supported for $format on content entities."); - // Unsupported entity. - $this->assertFalse($this->normalizers['entity']->supportsNormalization($unsupportedEntity, static::$format), "Normalization is not supported for other entity types."); - - // Field item. - $this->assertTrue($this->normalizers['field_item']->supportsNormalization($field->offsetGet(0), static::$format), "Field item normalization is supported for $format."); - // Entity reference field item. - $this->assertTrue($this->normalizers['entityreference']->supportsNormalization($entityreferenceField->offsetGet(0), static::$format), "Entity reference field item normalization is supported for $format."); - } - - /** - * Tests the supportsDenormalization function. - */ - public function testSupportsDenormalization() { - $format = static::$format; - $data = array(); - $supportedEntityClass = 'Drupal\Core\Entity\EntityNG'; - $unsupportedEntityClass = 'Drupal\config\Tests\ConfigEntityTest'; - $fieldClass = 'Drupal\Core\Entity\Field\Type\StringItem'; - $entityreferenceFieldClass = 'Drupal\Core\Entity\Field\Type\EntityReferenceItem'; - - // Supported entity. - $this->assertTrue($this->normalizers['entity']->supportsDenormalization($data, $supportedEntityClass, static::$format), "Entity denormalization is supported for $format on content entities."); - // Unsupported entity. - $this->assertFalse($this->normalizers['entity']->supportsDenormalization($data, $unsupportedEntityClass, static::$format), "Denormalization is not supported for other entity types."); - - // Field item. - $this->assertTrue($this->normalizers['field_item']->supportsDenormalization($data, $fieldClass, static::$format), "Field item denormalization is supported for $format."); - // Entity reference field item. - $this->assertTrue($this->normalizers['entityreference']->supportsDenormalization($data, $entityreferenceFieldClass, static::$format), "Entity reference field item denormalization is supported for $format."); - } - -} diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/EntityResource.php b/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/EntityResource.php index 541c80b..61d05a5 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/EntityResource.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/EntityResource.php @@ -155,6 +155,11 @@ public function patch($id, EntityInterface $entity) { } // Overwrite the received properties. foreach ($entity->getProperties() as $name => $property) { + // Requests cannot overwrite id or uuid, so skip them. + if (in_array($name, array('id', 'uuid'))) { + continue; + } + if (isset($entity->{$name})) { $original_entity->{$name} = $property; } diff --git a/core/modules/rest/lib/Drupal/rest/RequestHandler.php b/core/modules/rest/lib/Drupal/rest/RequestHandler.php index 30156de..e0d09bc 100644 --- a/core/modules/rest/lib/Drupal/rest/RequestHandler.php +++ b/core/modules/rest/lib/Drupal/rest/RequestHandler.php @@ -75,7 +75,7 @@ public function handle(Request $request, $id = NULL) { } catch (HttpException $e) { $error['error'] = $e->getMessage(); - $format = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT)->getRequirement('_format') ?: 'drupal_jsonld'; + $format = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT)->getRequirement('_format') ?: 'hal_json'; $content = $serializer->serialize($error, $format); // Add the default content type, but only if the headers from the // exception have not specified it already. @@ -88,9 +88,8 @@ public function handle(Request $request, $id = NULL) { if ($data != NULL) { // All REST routes are restricted to exactly one format, so instead of // parsing it out of the Accept headers again we can simply retrieve the - // format requirement. If there is no format associated just pick Drupal - // JSON-LD. - $format = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT)->getRequirement('_format') ?: 'drupal_jsonld'; + // format requirement. If there is no format associated just pick HAL. + $format = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT)->getRequirement('_format') ?: 'hal_json'; $output = $serializer->serialize($data, $format); $response->setContent($output); diff --git a/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php b/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php index a3a5c60..3420652 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php @@ -19,7 +19,7 @@ class CreateTest extends RESTTestBase { * * @var array */ - public static $modules = array('rest', 'entity_test'); + public static $modules = array('hal', 'rest', 'entity_test'); public static function getInfo() { return array( @@ -46,9 +46,9 @@ public function testCreate() { $entity_values = $this->entityValues($entity_type); $entity = entity_create($entity_type, $entity_values); - $serialized = $serializer->serialize($entity, 'drupal_jsonld'); + $serialized = $serializer->serialize($entity, 'hal_json'); // Create the entity over the web API. - $this->httpRequest('entity/' . $entity_type, 'POST', $serialized, 'application/vnd.drupal.ld+json'); + $this->httpRequest('entity/' . $entity_type, 'POST', $serialized, 'application/hal+json'); $this->assertResponse(201); // Get the new entity ID from the location header and try to read it from @@ -71,7 +71,7 @@ public function testCreate() { $loaded_entity->delete(); // Try to send invalid data that cannot be correctly deserialized. - $this->httpRequest('entity/' . $entity_type, 'POST', 'kaboom!', 'application/vnd.drupal.ld+json'); + $this->httpRequest('entity/' . $entity_type, 'POST', 'kaboom!', 'application/hal+json'); $this->assertResponse(400); // Try to create an entity without the CSRF token. @@ -82,21 +82,21 @@ public function testCreate() { CURLOPT_POSTFIELDS => $serialized, CURLOPT_URL => url('entity/' . $entity_type, array('absolute' => TRUE)), CURLOPT_NOBODY => FALSE, - CURLOPT_HTTPHEADER => array('Content-Type: application/vnd.drupal.ld+json'), + CURLOPT_HTTPHEADER => array('Content-Type: application/hal+json'), )); $this->assertResponse(403); $this->assertFalse(entity_load_multiple($entity_type, NULL, TRUE), 'No entity has been created in the database.'); // Try to create an entity without proper permissions. $this->drupalLogout(); - $this->httpRequest('entity/' . $entity_type, 'POST', $serialized, 'application/vnd.drupal.ld+json'); + $this->httpRequest('entity/' . $entity_type, 'POST', $serialized, 'application/hal+json'); $this->assertResponse(403); $this->assertFalse(entity_load_multiple($entity_type, NULL, TRUE), 'No entity has been created in the database.'); // Try to create a resource which is not web API enabled. $this->enableService(FALSE); $this->drupalLogin($account); - $this->httpRequest('entity/entity_test', 'POST', $serialized, 'application/vnd.drupal.ld+json'); + $this->httpRequest('entity/entity_test', 'POST', $serialized, 'application/hal+json'); $this->assertResponse(404); $this->assertFalse(entity_load_multiple($entity_type, NULL, TRUE), 'No entity has been created in the database.'); diff --git a/core/modules/rest/lib/Drupal/rest/Tests/DBLogTest.php b/core/modules/rest/lib/Drupal/rest/Tests/DBLogTest.php index d4b9cc2..f93820c 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/DBLogTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/DBLogTest.php @@ -19,7 +19,7 @@ class DBLogTest extends RESTTestBase { * * @var array */ - public static $modules = array('jsonld', 'rest', 'dblog'); + public static $modules = array('hal', 'rest', 'dblog'); public static function getInfo() { return array( @@ -50,16 +50,16 @@ public function testWatchdog() { $account = $this->drupalCreateUser(array('restful get dblog')); $this->drupalLogin($account); - $response = $this->httpRequest("dblog/$id", 'GET', NULL, 'application/vnd.drupal.ld+json'); + $response = $this->httpRequest("dblog/$id", 'GET', NULL, 'application/hal+json'); $this->assertResponse(200); - $this->assertHeader('content-type', 'application/vnd.drupal.ld+json'); + $this->assertHeader('content-type', 'application/hal+json'); $log = drupal_json_decode($response); $this->assertEqual($log['wid'], $id, 'Log ID is correct.'); $this->assertEqual($log['type'], 'rest_test', 'Type of log message is correct.'); $this->assertEqual($log['message'], 'Test message', 'Log message text is correct.'); // Request an unknown log entry. - $response = $this->httpRequest("dblog/9999", 'GET', NULL, 'application/vnd.drupal.ld+json'); + $response = $this->httpRequest("dblog/9999", 'GET', NULL, 'application/hal+json'); $this->assertResponse(404); $decoded = drupal_json_decode($response); $this->assertEqual($decoded['error'], 'Log entry with ID 9999 was not found', 'Response message is correct.'); diff --git a/core/modules/rest/lib/Drupal/rest/Tests/DeleteTest.php b/core/modules/rest/lib/Drupal/rest/Tests/DeleteTest.php index c29e7e6..8259db8 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/DeleteTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/DeleteTest.php @@ -19,7 +19,7 @@ class DeleteTest extends RESTTestBase { * * @var array */ - public static $modules = array('rest', 'entity_test'); + public static $modules = array('hal', 'rest', 'entity_test'); public static function getInfo() { return array( diff --git a/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php b/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php index c428c86..f69eb81 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php @@ -26,7 +26,7 @@ * @param string $format * The MIME type of the transmitted content. */ - protected function httpRequest($url, $method, $body = NULL, $format = 'application/ld+json') { + protected function httpRequest($url, $method, $body = NULL, $format = 'application/hal+json') { if (!in_array($method, array('GET', 'HEAD', 'OPTIONS', 'TRACE'))) { // GET the CSRF token first for writing requests. $token = $this->drupalGet('rest/session/token'); @@ -159,7 +159,7 @@ protected function entityValues($entity_type) { * @param string $method * The HTTP method to enable, e.g. GET, POST etc. * @param string $format - * (Optional) The serialization format, e.g. jsonld. + * (Optional) The serialization format, e.g. hal_json. */ protected function enableService($resource_type, $method = 'GET', $format = NULL) { // Enable web API for this entity type. diff --git a/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php b/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php index 299bdd4..87c4aaa 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php @@ -19,7 +19,7 @@ class ReadTest extends RESTTestBase { * * @var array */ - public static $modules = array('jsonld', 'rest', 'entity_test'); + public static $modules = array('hal', 'rest', 'entity_test'); public static function getInfo() { return array( @@ -48,34 +48,34 @@ public function testRead() { $entity = $this->entityCreate($entity_type); $entity->save(); // Read it over the web API. - $response = $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'GET', NULL, 'application/vnd.drupal.ld+json'); + $response = $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'GET', NULL, 'application/hal+json'); $this->assertResponse('200', 'HTTP response code is correct.'); - $this->assertHeader('content-type', 'application/vnd.drupal.ld+json'); + $this->assertHeader('content-type', 'application/hal+json'); $data = drupal_json_decode($response); // Only assert one example property here, other properties should be // checked in serialization tests. - $this->assertEqual($data['uuid'][LANGUAGE_DEFAULT][0]['value'], $entity->uuid(), 'Entity UUID is correct'); + $this->assertEqual($data['uuid'][0]['value'], $entity->uuid(), 'Entity UUID is correct'); // Try to read the entity with an unsupported mime format. $response = $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'GET', NULL, 'application/wrongformat'); $this->assertResponse(415); // Try to read an entity that does not exist. - $response = $this->httpRequest('entity/' . $entity_type . '/9999', 'GET', NULL, 'application/vnd.drupal.ld+json'); + $response = $this->httpRequest('entity/' . $entity_type . '/9999', 'GET', NULL, 'application/hal+json'); $this->assertResponse(404); $decoded = drupal_json_decode($response); $this->assertEqual($decoded['error'], 'Entity with ID 9999 not found', 'Response message is correct.'); // Try to read an entity without proper permissions. $this->drupalLogout(); - $response = $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'GET', NULL, 'application/vnd.drupal.ld+json'); + $response = $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'GET', NULL, 'application/hal+json'); $this->assertResponse(403); $this->assertNull(drupal_json_decode($response), 'No valid JSON found.'); } // Try to read a resource which is not web API enabled. $account = $this->drupalCreateUser(); $this->drupalLogin($account); - $response = $this->httpRequest('entity/user/' . $account->id(), 'GET', NULL, 'application/vnd.drupal.ld+json'); + $response = $this->httpRequest('entity/user/' . $account->id(), 'GET', NULL, 'application/hal+json'); $this->assertResponse(404); $this->assertNull(drupal_json_decode($response), 'No valid JSON found.'); } diff --git a/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php b/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php index 94be2bf..87f7e71 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php @@ -19,7 +19,7 @@ class UpdateTest extends RESTTestBase { * * @var array */ - public static $modules = array('rest', 'entity_test'); + public static $modules = array('hal', 'rest', 'entity_test'); public static function getInfo() { return array( @@ -51,12 +51,10 @@ public function testPatchUpdate() { // Create a second stub entity for overwriting a field. $patch_values['field_test_text'] = array(0 => array('value' => $this->randomString())); $patch_entity = entity_create($entity_type, $patch_values); - // We don't want to overwrite the UUID. - unset($patch_entity->uuid); - $serialized = $serializer->serialize($patch_entity, 'drupal_jsonld'); + $serialized = $serializer->serialize($patch_entity, 'hal_json'); // Update the entity over the web API. - $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PATCH', $serialized, 'application/vnd.drupal.ld+json'); + $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PATCH', $serialized, 'application/hal+json'); $this->assertResponse(204); // Re-load updated entity from the database. @@ -64,12 +62,12 @@ public function testPatchUpdate() { $this->assertEqual($entity->field_test_text->value, $patch_entity->field_test_text->value, 'Field was successfully updated.'); // Try to empty a field. - $normalized = $serializer->normalize($patch_entity, 'drupal_jsonld'); + $normalized = $serializer->normalize($patch_entity, 'hal_json'); $normalized['field_test_text'] = array(); - $serialized = $serializer->encode($normalized, 'jsonld'); + $serialized = $serializer->encode($normalized, 'hal_json'); // Update the entity over the web API. - $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PATCH', $serialized, 'application/vnd.drupal.ld+json'); + $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PATCH', $serialized, 'application/hal+json'); $this->assertResponse(204); // Re-load updated entity from the database. @@ -77,20 +75,20 @@ public function testPatchUpdate() { $this->assertNull($entity->field_test_text->value, 'Test field has been cleared.'); // Try to update a non-existing entity with ID 9999. - $this->httpRequest('entity/' . $entity_type . '/9999', 'PATCH', $serialized, 'application/vnd.drupal.ld+json'); + $this->httpRequest('entity/' . $entity_type . '/9999', 'PATCH', $serialized, 'application/hal+json'); $this->assertResponse(404); $loaded_entity = entity_load($entity_type, 9999, TRUE); $this->assertFalse($loaded_entity, 'Entity 9999 was not created.'); // Try to update an entity without proper permissions. $this->drupalLogout(); - $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PATCH', $serialized, 'application/vnd.drupal.ld+json'); + $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PATCH', $serialized, 'application/hal+json'); $this->assertResponse(403); // Try to update a resource which is not web API enabled. $this->enableService(FALSE); $this->drupalLogin($account); - $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PATCH', $serialized, 'application/vnd.drupal.ld+json'); + $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PATCH', $serialized, 'application/hal+json'); $this->assertResponse(404); } @@ -120,9 +118,9 @@ public function testPutUpdate() { $update_entity->uuid->value = $entity->uuid(); $update_entity->id->value = $entity->id(); - $serialized = $serializer->serialize($update_entity, 'drupal_jsonld'); + $serialized = $serializer->serialize($update_entity, 'hal_json'); // Update the entity over the web API. - $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PUT', $serialized, 'application/vnd.drupal.ld+json'); + $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PUT', $serialized, 'application/hal+json'); $this->assertResponse(204); // Re-load the updated entity from the database. @@ -138,8 +136,8 @@ public function testPutUpdate() { // Try to delete a property. unset($update_entity->field_test_text); - $serialized = $serializer->serialize($update_entity, 'drupal_jsonld'); - $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PUT', $serialized, 'application/vnd.drupal.ld+json'); + $serialized = $serializer->serialize($update_entity, 'hal_json'); + $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PUT', $serialized, 'application/hal+json'); $this->assertResponse(204); // Re-load the updated entity from the database. @@ -147,20 +145,20 @@ public function testPutUpdate() { $this->assertTrue($entity->field_test_text->isEmpty(), 'Property has been deleted.'); // Try to create an entity with ID 9999. - $this->httpRequest('entity/' . $entity_type . '/9999', 'PUT', $serialized, 'application/vnd.drupal.ld+json'); + $this->httpRequest('entity/' . $entity_type . '/9999', 'PUT', $serialized, 'application/hal+json'); $this->assertResponse(404); $loaded_entity = entity_load($entity_type, 9999, TRUE); $this->assertFalse($loaded_entity, 'Entity 9999 was not created.'); // Try to update an entity without proper permissions. $this->drupalLogout(); - $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PUT', $serialized, 'application/vnd.drupal.ld+json'); + $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PUT', $serialized, 'application/hal+json'); $this->assertResponse(403); // Try to update a resource which is not web API enabled. $this->enableService(FALSE); $this->drupalLogin($account); - $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PUT', $serialized, 'application/vnd.drupal.ld+json'); + $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PUT', $serialized, 'application/hal+json'); $this->assertResponse(404); } } diff --git a/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php index 4aeaaa7..c38db82 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php @@ -25,7 +25,7 @@ class StyleSerializerTest extends PluginTestBase { * * @var array */ - public static $modules = array('views_ui', 'entity_test', 'jsonld', 'rest_test_views'); + public static $modules = array('views_ui', 'entity_test', 'hal', 'rest_test_views'); /** * Views used by this test. @@ -127,13 +127,9 @@ public function testSerializerResponses() { $this->assertIdentical($actual_json, $expected, 'The expected JSON output was found.'); - $expected = $serializer->serialize($entities, 'jsonld'); - $actual_json = $this->drupalGet('test/serialize/entity', array(), array('Accept: application/ld+json')); - $this->assertIdentical($actual_json, $expected, 'The expected JSONLD output was found.'); - - $expected = $serializer->serialize($entities, 'drupal_jsonld'); - $actual_json = $this->drupalGet('test/serialize/entity', array(), array('Accept: application/vnd.drupal.ld+json')); - $this->assertIdentical($actual_json, $expected, 'The expected JSONLD output was found.'); + $expected = $serializer->serialize($entities, 'hal_json'); + $actual_json = $this->drupalGet('test/serialize/entity', array(), array('Accept: application/hal+json')); + $this->assertIdentical($actual_json, $expected, 'The expected HAL output was found.'); } /** diff --git a/core/modules/rest/rest.info b/core/modules/rest/rest.info index c450567..7b0b88d 100644 --- a/core/modules/rest/rest.info +++ b/core/modules/rest/rest.info @@ -3,7 +3,5 @@ description = Exposes entities and other resources as RESTful web API package = Core version = VERSION core = 8.x -; @todo Remove this dependency once hard coding to JSON-LD is gone. -dependencies[] = jsonld dependencies[] = serialization configure = admin/config/services/rest diff --git a/core/modules/rest/rest.module b/core/modules/rest/rest.module index 233db32..43b32f4 100644 --- a/core/modules/rest/rest.module +++ b/core/modules/rest/rest.module @@ -69,7 +69,7 @@ function rest_help($path, $arg) { $output .= '

' . t('Example uses') . '

'; $output .= '
'; $output .= '
' . t('An HTTP GET request can be used to get a node') . '
'; - $output .= '
curl -H "Accept: application/vnd.drupal.ld+json" --include --request GET --cookie ' . session_name() . '=' . session_id() . ' ' . url('entity/node/5', array('absolute' => TRUE)) . '
'; + $output .= '
curl -H "Accept: application/hal+json" --include --request GET --cookie ' . session_name() . '=' . session_id() . ' ' . url('entity/node/5', array('absolute' => TRUE)) . '
'; $output .= '
' . t('An HTTP DELETE request can be used to delete a node') . '
'; $output .= '
curl --include --request DELETE --cookie ' . session_name() . '=' . session_id() . ' ' . url('entity/node/5', array('absolute' => TRUE)) . '
'; $output .= '
';