Accessing term's tid I am trying to loop through a taxonomy term's tid, but somehow all the array elements are protected. It was very easy peasy in Drupal 7 with:

 $term_id_1 = $node-&gt;field_term['und'][0]['tid'];


I am not sure how I could access tid(here is the kint() screenshot):



and here I how I get this and my broken foreach():

public function setCollection($collection) {
$collection_array = [];
$collection_ids =  \Drupal\taxonomy\Entity\Term::load($collection);
kint($collection_ids);
foreach ($collection_ids as $collection_id) {
  $keys = $collection_id-&gt;values;
  foreach ($keys as $key){
    $collection_array[] = $key-&gt;tid;
  }
}

$this-&gt;collection = $collection_array;


}

Question 1-> Is taxonomy terms are node?

Question 2-> Is this line correct to get the fields?

  $collection_ids =  \Drupal\taxonomy\Entity\Term::load($collection);


Question 3-> Can anyone lead me to get access 'tid' from this protected 'values' array? 

Warm regards.
Yes you can do $term-&gt;id() which should return the term id if $term is a Term object. See id().