Using a Service to expose better getter methods for a Node instance Currently we use a Service that takes an NodeInterface object as an argument and then gives back a value, i.e:

  public function iFullyBooked(NodeInterface $node) {
    $fully_booked_field = $node-&gt;get('field_fully_booked')-&gt;first();
    $value = $fully_booked_field-&gt;getValue();

    return $value['value'] === "1";
  }


This works, is testable, but is this a good approach to take? We don't want to put all these preprocess things in a hook, since that function would be ridiculous long and not very nice to work with.

Would this be considered bad practise, and if so, is there a better way?
Having a service for frequently used things like this makes sense.

That said, your code can be simplified a lot.

$node-&gt;get('field_fully_booked')-&gt;value == 1;


Does exactly the same. If you want to check something, then do a hasField('field_fully_booked') to avoid an error if that field doesn't exist.

This relies on magic methods, see https://wizzlern.nl/drupal/drupal-8-entity-cheat-sheet

And yes, I did not use a type safe check on purpose. There are cases where type safety makes sense, but entity field values are not type safe, it actually makes your code more error-prone, for example if you'd change the value with API and did a = 1, then your method would return FALSE.