function RdfParsingTrait::getElementByRdfTypeCount

Same name and namespace in other branches
  1. 9 core/modules/rdf/tests/src/Traits/RdfParsingTrait.php \Drupal\Tests\rdf\Traits\RdfParsingTrait::getElementByRdfTypeCount()

Counts the number of resources of the provided type.

Parameters

\Drupal\Core\Url $url: URL of the document.

string $base_uri: The base URI for the html being parsed.

string $type: Type of resource to count.

Return value

int The number of resources of the provided type.

1 call to RdfParsingTrait::getElementByRdfTypeCount()
StandardProfileTest::doFrontPageRdfaTests in core/modules/rdf/tests/src/Functional/StandardProfileTest.php
Tests that data is exposed in the front page teasers.

File

core/modules/rdf/tests/src/Traits/RdfParsingTrait.php, line 97

Class

RdfParsingTrait
Defines a trait for parsing RDF properties from HTML.

Namespace

Drupal\Tests\rdf\Traits

Code

protected function getElementByRdfTypeCount(Url $url, $base_uri, $type) {
    $parser = new \EasyRdf_Parser_Rdfa();
    $graph = new \EasyRdf_Graph();
    $parser->parse($graph, $this->drupalGet($url), 'rdfa', $base_uri);
    return count($graph->allOfType($type));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.