Think this is an OOP question... so the correct answer is to switch by the type of the instance. In PHP you do this with "instanceof", like here in MappingTest.php: protected function filterNumericFields(&$fields) { foreach ($this->view->field as $id => $field) { if (!($field instanceof NumericField)) { unset($fields[$id]); } } } Note: dpm is bad with nested objects... you should set up a debugger like xdebug. Another Note: Each content entity has a getFieldDefinitions method: /** * {@inheritdoc} */ public function getFieldDefinitions() { if (!isset($this->fieldDefinitions)) { $this->fieldDefinitions = \Drupal::service('entity_field.manager')->getFieldDefinitions($this->entityTypeId, $this->bundle()); } return $this->fieldDefinitions; }