public function AmpPrepareMetadataJson::getJson in Accelerated Mobile Pages (AMP) 8
Gets the encoded AMP metadata JSON.
Parameters
array $amp_metadata_settings: The array containing AMP metadata settings.
string $canonical_url: The canonical url for this node.
NodeInterface $node: The node object.
Return value
string A JSON encoded string on success or FALSE on failure.
Overrides AmpPrepareMetadataJsonInterface::getJson
File
- src/
Utility/ AmpPrepareMetadataJson.php, line 90
Class
- AmpPrepareMetadataJson
- Class AmpPrepareMetadataJson
Namespace
Drupal\amp\UtilityCode
public function getJson(array $amp_metadata_settings, $canonical_url, NodeInterface $node) {
if (!empty($this->ampMetadataSettings = $amp_metadata_settings) && !empty($this->canonicalUrl = $canonical_url) && !empty($this->node = $node)) {
$this
->prepareMetadataJson();
$this
->setAmpMetadataList();
$this
->checkMetadataComplete();
}
if (!empty($this->ampPreparedMetadataJson)) {
// Improve appearance of JSON output by using json_encode() options
// JSON_PRETTY_PRINT and JSON_UNESCAPED_SLASHES, which are not supported
// by Drupal's JSON serialization service ('serialization.json').
return json_encode($this->ampPreparedMetadataJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
}
else {
return FALSE;
}
}