How to check if custom entity is published in drupal 8 [SOLVED]

We all well know the functions to check if a node is published or not, but what about a custom entity?

I have a custom entity called 'group'. I had to do the following:

if ($group->status->getString() == 1) {
 // the group is published
}

 

 

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!