gestisce nodi senza tag

This commit is contained in:
root 2019-08-04 18:00:06 +02:00
parent e4ffb99b54
commit b2fc8092bb

View file

@ -117,6 +117,10 @@ class RelatedRorController extends ControllerBase {
}
private function getSimilarity(array $orig, array $other): int {
if(!in_array('field_tags', $orig) || count($orig['field_tags']) == 0 ||
!in_array('field_tags', $other) || count($other['field_tags']) == 0) {
return 0;
}
$orig_tags = array_map(function($t) { return $t['target_id']; }, $orig['field_tags']);
$other_tags = array_map(function($t) { return $t['target_id']; }, $other['field_tags']);
$both = array_intersect($orig_tags, $other_tags);