Unverified Commit 89d9f113 authored by alexpott's avatar alexpott

Issue #3110972 by sanduhrs, jungle, raman.b, samiullah, alexpott, andypost,...

Issue #3110972 by sanduhrs, jungle, raman.b, samiullah, alexpott, andypost, catch, xjm: Update easyrdf library to 1.0.0
parent f0462354
......@@ -33,7 +33,7 @@
"symfony/lock": "^4.4",
"symfony/browser-kit": "^4.4",
"symfony/dom-crawler": "^4.4 !=4.4.5",
"easyrdf/easyrdf": "^0.9"
"easyrdf/easyrdf": "^0.9 || ^1.0"
},
"replace": {
"paragonie/random_compat": "9.99.99",
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "8877ebb73b0fca58e145989738ba04b4",
"content-hash": "059e8aee61edb73b1526b840eb6c624c",
"packages": [
{
"name": "asm89/stack-cors",
......@@ -4805,35 +4805,39 @@
},
{
"name": "easyrdf/easyrdf",
"version": "0.9.1",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/easyrdf/easyrdf.git",
"reference": "acd09dfe0555fbcfa254291e433c45fdd4652566"
"reference": "8735708426066b791c2a6d40329050d5cf31385c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/easyrdf/easyrdf/zipball/acd09dfe0555fbcfa254291e433c45fdd4652566",
"reference": "acd09dfe0555fbcfa254291e433c45fdd4652566",
"url": "https://api.github.com/repos/easyrdf/easyrdf/zipball/8735708426066b791c2a6d40329050d5cf31385c",
"reference": "8735708426066b791c2a6d40329050d5cf31385c",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"ext-pcre": "*",
"php": ">=5.2.8"
"php": ">=7.1.0"
},
"require-dev": {
"phpunit/phpunit": "~3.5",
"sami/sami": "~1.4",
"squizlabs/php_codesniffer": "~1.4.3"
"ml/json-ld": "~1.0",
"phpunit/phpunit": "^7",
"sami/sami": "^4",
"semsol/arc2": "~2.2",
"squizlabs/php_codesniffer": "3.*",
"zendframework/zend-http": "~2.3"
},
"suggest": {
"ml/json-ld": "~1.0"
"ml/json-ld": "~1.0",
"semsol/arc2": "~2.2"
},
"type": "library",
"autoload": {
"psr-0": {
"EasyRdf_": "lib/"
"psr-4": {
"EasyRdf\\": "lib"
}
},
"notification-url": "https://packagist.org/downloads/",
......@@ -4850,6 +4854,7 @@
{
"name": "Alexey Zakhlestin",
"email": "indeyets@gmail.com",
"homepage": "http://indeyets.ru/",
"role": "Developer"
}
],
......@@ -4863,7 +4868,12 @@
"rdfa",
"sparql"
],
"time": "2015-02-27T09:45:49+00:00"
"support": {
"forum": "http://groups.google.com/group/easyrdf/",
"issues": "http://github.com/easyrdf/easyrdf/issues",
"source": "https://github.com/easyrdf/easyrdf/tree/master"
},
"time": "2020-07-14T23:45:20+00:00"
},
{
"name": "fabpot/goutte",
......
......@@ -12,7 +12,7 @@
"behat/mink-selenium2-driver": "^1.4",
"composer/composer": "^1.9.1",
"drupal/coder": "^8.3.7",
"easyrdf/easyrdf": "^0.9",
"easyrdf/easyrdf": "^0.9 || ^1.0",
"justinrainbow/json-schema": "^5.2",
"mikey179/vfsstream": "^1.6.8",
"phpspec/prophecy": "^1.7",
......
......@@ -18,7 +18,7 @@
"composer/xdebug-handler": "1.4.3",
"doctrine/instantiator": "1.3.1",
"drupal/coder": "8.3.9",
"easyrdf/easyrdf": "0.9.1",
"easyrdf/easyrdf": "1.0.0",
"fabpot/goutte": "v3.3.0",
"instaclick/php-webdriver": "1.4.7",
"justinrainbow/json-schema": "5.2.10",
......
......@@ -3,14 +3,8 @@
namespace Drupal\Tests\rdf\Traits;
use Drupal\Core\Url;
/**
* Override \EasyRdf_ParsedUri for PHP 7.4 compatibility.
*
* @todo https://www.drupal.org/project/drupal/issues/3110972 Remove this work
* around.
*/
class_alias('\Drupal\Tests\rdf\Traits\EasyRdf_ParsedUri', '\EasyRdf_ParsedUri');
use EasyRdf\Graph;
use EasyRdf\Parser\Rdfa;
/**
* Defines a trait for parsing RDF properties from HTML.
......@@ -39,10 +33,12 @@ trait RdfParsingTrait {
*
* @return bool
* TRUE if the property exists with the given value.
*
* @throws \EasyRdf\Exception
*/
protected function hasRdfProperty($html, $base_uri, $resource, $property, array $value) {
$parser = new \EasyRdf_Parser_Rdfa();
$graph = new \EasyRdf_Graph();
$parser = $this->getInstanceParser();
$graph = $this->getInstanceGraph();
$parser->parse($graph, $html, 'rdfa', $base_uri);
return $graph->hasProperty($resource, $property, $value);
......@@ -72,10 +68,12 @@ protected function hasRdfProperty($html, $base_uri, $resource, $property, array
*
* @return bool
* TRUE if the property exists with the given value.
*
* @throws \EasyRdf\Exception
*/
protected function hasRdfChildProperty($html, $base_uri, $resource, $parent_property, string $child_property, array $value) {
$parser = new \EasyRdf_Parser_Rdfa();
$graph = new \EasyRdf_Graph();
$parser = $this->getInstanceParser();
$graph = $this->getInstanceGraph();
$parser->parse($graph, $html, 'rdfa', $base_uri);
$node = $graph->get($resource, $parent_property);
return $graph->hasProperty($node, $child_property, $value);
......@@ -93,10 +91,12 @@ protected function hasRdfChildProperty($html, $base_uri, $resource, $parent_prop
*
* @return int
* The number of resources of the provided type.
*
* @throws \EasyRdf\Exception
*/
protected function getElementByRdfTypeCount(Url $url, $base_uri, $type) {
$parser = new \EasyRdf_Parser_Rdfa();
$graph = new \EasyRdf_Graph();
$parser = $this->getInstanceParser();
$graph = $this->getInstanceGraph();
$parser->parse($graph, $this->drupalGet($url), 'rdfa', $base_uri);
return count($graph->allOfType($type));
}
......@@ -113,10 +113,12 @@ protected function getElementByRdfTypeCount(Url $url, $base_uri, $type) {
*
* @return string|null
* The type of resource or NULL if the resource has no type.
*
* @throws \EasyRdf\Exception
*/
protected function getElementRdfType(Url $url, $base_uri, $resource_uri) {
$parser = new \EasyRdf_Parser_Rdfa();
$graph = new \EasyRdf_Graph();
$parser = $this->getInstanceParser();
$graph = $this->getInstanceGraph();
$parser->parse($graph, $this->drupalGet($url), 'rdfa', $base_uri);
return $graph->type($resource_uri);
}
......@@ -135,12 +137,46 @@ protected function getElementRdfType(Url $url, $base_uri, $resource_uri) {
*
* @return bool
* TRUE if the given property is blank.
*
* @throws \EasyRdf\Exception
*/
protected function rdfElementIsBlankNode($html, $base_uri, $resource_uri, $property) {
$parser = new \EasyRdf_Parser_Rdfa();
$graph = new \EasyRdf_Graph();
$parser = $this->getInstanceParser();
$graph = $this->getInstanceGraph();
$parser->parse($graph, $html, 'rdfa', $base_uri);
return $graph->get($resource_uri, $property)->isBnode();
}
/**
* Gets a new instance of EasyRdf\Parser\Rdfa or EasyRdf_Parser_Rdfa.
*
* @return \EasyRdf\Parser\Rdfa|\EasyRdf_Parser_Rdfa
* The instance.
*
* @todo Clean this up in drupal:10.0.0.
* @see https://www.drupal.org/node/3176468
*/
private function getInstanceParser() {
if (class_exists('EasyRdf\Parser\Rdfa')) {
return new Rdfa();
}
return new \EasyRdf_Parser_Rdfa();
}
/**
* Gets a new instance of EasyRdf\Graph or EasyRdf_Graph.
*
* @return \EasyRdf\Graph|\EasyRdf_Graph
* The instance.
*
* @todo Clean this up in drupal:10.0.0.
* @see https://www.drupal.org/node/3176468
*/
private function getInstanceGraph() {
if (class_exists('EasyRdf\Graph')) {
return new Graph();
}
return new \EasyRdf_Graph();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment