related flag missing bug fix in materio_flag module
This commit is contained in:
		@@ -65,32 +65,42 @@ class MaterioFlagController extends ControllerBase {
 | 
			
		||||
 | 
			
		||||
    $data = [];
 | 
			
		||||
    foreach ($colls as $id => $collection) {
 | 
			
		||||
      $flag_id = $collection->getRelatedFlag()->id();
 | 
			
		||||
      $relatedflag = $collection->getRelatedFlag();
 | 
			
		||||
      if ($relatedflag) {
 | 
			
		||||
        $flag_id = $relatedflag->id();
 | 
			
		||||
 | 
			
		||||
        // get the items
 | 
			
		||||
        $itemsids = $this->flagListsService->getFlagListItemIds($flag_id,$id);
 | 
			
		||||
        $items = [];
 | 
			
		||||
        foreach ($this->flagListsService->getFlagListItems($itemsids) as $id => $item) {
 | 
			
		||||
          // $items[] = array(
 | 
			
		||||
          //   'id' => $id,
 | 
			
		||||
          //   'name' => $item->getName(),
 | 
			
		||||
          //   'connected_entity_id' => $item->getConnectedEntityId(),
 | 
			
		||||
          // );
 | 
			
		||||
          $items[] = (int)$item->getConnectedEntityId();
 | 
			
		||||
        }
 | 
			
		||||
        // $items_uuids = [];
 | 
			
		||||
        // foreach ($items as $nid) {
 | 
			
		||||
        //   $node = $this->entityTypeManager->getStorage('node')->load($nid);
 | 
			
		||||
        //   $items_uuids[] = $node->uuid();
 | 
			
		||||
        // }
 | 
			
		||||
 | 
			
		||||
        $data[$collection->id()] = array(
 | 
			
		||||
          "id" => $collection->id(),
 | 
			
		||||
          "name" => $collection->getName(),
 | 
			
		||||
          "flag_id" => $flag_id,
 | 
			
		||||
          "items" => $items
 | 
			
		||||
          // "items_uuids" => $items_uuids
 | 
			
		||||
        );
 | 
			
		||||
      } else {
 | 
			
		||||
        \Drupal::logger('materio_flag')->notice('%colname (%colid): Collection\'s Related flag does not exists.',
 | 
			
		||||
        [
 | 
			
		||||
          '%colid' => $collection->id(),
 | 
			
		||||
          '%colname' => $collection->getName()
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
      // get the items
 | 
			
		||||
      $itemsids = $this->flagListsService->getFlagListItemIds($flag_id,$id);
 | 
			
		||||
      $items = [];
 | 
			
		||||
      foreach ($this->flagListsService->getFlagListItems($itemsids) as $id => $item) {
 | 
			
		||||
        // $items[] = array(
 | 
			
		||||
        //   'id' => $id,
 | 
			
		||||
        //   'name' => $item->getName(),
 | 
			
		||||
        //   'connected_entity_id' => $item->getConnectedEntityId(),
 | 
			
		||||
        // );
 | 
			
		||||
        $items[] = (int)$item->getConnectedEntityId();
 | 
			
		||||
      }
 | 
			
		||||
      // $items_uuids = [];
 | 
			
		||||
      // foreach ($items as $nid) {
 | 
			
		||||
      //   $node = $this->entityTypeManager->getStorage('node')->load($nid);
 | 
			
		||||
      //   $items_uuids[] = $node->uuid();
 | 
			
		||||
      // }
 | 
			
		||||
 | 
			
		||||
      $data[$collection->id()] = array(
 | 
			
		||||
        "id" => $collection->id(),
 | 
			
		||||
        "name" => $collection->getName(),
 | 
			
		||||
        "flag_id" => $flag_id,
 | 
			
		||||
        "items" => $items
 | 
			
		||||
        // "items_uuids" => $items_uuids
 | 
			
		||||
      );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return new JsonResponse($data);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user