Get entity id in hook_form_BASE_FORM_ID_alter() I am working on porting a D7 module to D8.
As in Drupal 8 all things are represented as entity, menu items are also represented as entity.
Now I added a hook_form_BASE_FORM_ID_alter() implementation to alter the menu creation and edit form. On the menu edit form, I want to get the entity ID of the menu that is currently being edited.

I tried to get the entity id ID with the following code, but I am getting an error. (See line 43.)

$entity = $form_state['controller']-&gt;getEntity();


For above snippet I followed https://www.drupal.org/node/1734556.

How can I get the entity ID?
That CR is outdated, probably there's a later CR updating it: now you should use $form_state-&gt;getFormObject()-&gt;getEntity().