escludi le "page" dai tag

This commit is contained in:
root 2019-08-04 18:11:36 +02:00
parent 77e80ee160
commit 3c819998ee

View file

@ -87,7 +87,10 @@ class RelatedRorController extends ControllerBase {
$nid = intval($nid);
$node = \Drupal\node\Entity\Node::load($nid);
if($node == null) {
return new Response("Node not found", 400, array('Content-Type' => 'text/plain'));
return new Response("Node not found", 404, array('Content-Type' => 'text/plain'));
}
if($this->isFilteredOut($node)) {
return new Response("Node has no similarity", 404, array('Content-Type' => 'text/plain'));
}
$time = intval($node->getCreatedTime());
$nearnodes = $this->presentNids(array_filter(
@ -138,6 +141,13 @@ class RelatedRorController extends ControllerBase {
return $resp;
}
private function isFilteredOut(\Drupal\node\Entity\Node $node) {
if($node->getType() === 'page')
return true;
return false;
}
public function relatedTopic() {
// TODO: get node time
// TODO: queryNearInTime($time)
@ -151,7 +161,10 @@ class RelatedRorController extends ControllerBase {
$nid = intval($nid);
$node = \Drupal\node\Entity\Node::load($nid);
if($node == null) {
return new Response("Node not found", 400, array('Content-Type' => 'text/plain'));
return new Response("Node not found", 404, array('Content-Type' => 'text/plain'));
}
if($this->isFilteredOut($node)) {
return new Response("Node similarity disallowed", 403, array('Content-Type' => 'text/plain'));
}
$orig_arr = $node->toArray();
$time = intval($node->getCreatedTime());