How to load my Entity in Entity form i have:

/**
 * @ContentEntityType(
 *   id = "my_entity",
 *   label = @Translation("drwywr werwer label"),
 *   bundle_label = @Translation("My entity type"),
 *   handlers = {
 *     bla...
 *     "form" = {
 *       "default" = "Drupal\my_entity\Form\MyEntityForm",
 *       "edit" = "Drupal\my_entity\Form\MyEntityForm",
 *       "delete" = "Drupal\Core\Entity\ContentEntityDeleteForm"
 *     },
 *     bla...
 *   },
 *   translatable = FALSE,
 *   entity_keys = { bla... },
 *   bundle_entity_type = "my_entity_type",
 *   links = {
 *     "collection" = "/admin/test/entity/collection",
 *     "canonical" = "/admin/test/entity/{my_entity}",
 *     "edit-form" = "/admin/test/entity/{my_entity}/edit",
 *     "delete-form" = "/admin/test/entity/{my_entity}/delete"
 *   }
 * )
 */


based on above, how do i load my entity in form below:

&lt;?php

namespace Drupal\my_entity\Form;

use bla...

/**
 * Form controller for the node edit forms.
 */
class MyEntityForm extends ContentEntityForm {
 //how to load my entity type here?
}


i tried a couple way but i keep receiving: 


  Error: Call to a member function getEntityTypeId() on null


mainly because the entity is not loaded (null value)

this is how i create the route:

in my_entity.routing.yml:

route_callbacks:
  - 'entity.my_entity.routes::routes'


in routes:

public function routes() {
// Build Entity Create Route - CREATE
  $route = new Route(
      (substr($type-&gt;getRoute()['path'], -1) == '/' ? $type-&gt;getRoute()['path'] . $type-&gt;id() : $type-&gt;getRoute()['path'] . '/' . $type-&gt;id()) . '/create',
      [
        '_form' =&gt; '\Drupal\my_entity\Form\MyEntityForm', //TODO : not finish
        'entity_type' =&gt; 'my_entity',
        'bundle' =&gt; $type-&gt;id(),
        '_title' =&gt; 'Create ' . $type-&gt;getRoute()['label'],
      ],
      ['_permission' =&gt; 'entity admin settings']
    );
  $route_collection-&gt;add('entity.my_entity.' . $type-&gt;id() . '_create', $route);
}


if you see in my content entity type config above, i have:

 *   links = {
 *     "collection" = "/admin/test/entity/collection",
 *     "canonical" = "/admin/test/entity/{my_entity}",
 *     "edit-form" = "/admin/test/entity/{my_entity}/edit",
 *     "delete-form" = "/admin/test/entity/{my_entity}/delete"
 *   }


which i want those: edit, delete to be able to 'link' with my form as well - how to do this?

what i'm trying to achieve is: to generate forms based on field define in my entity type
Your code currently loads the form with the _form routing definition. For classes extending ContentEntityForm, you have to use the _entity_form notation instead. Here is an example of an 'module_name.routing.yml' file:

kollektivhampel.pdf_erstellen_form:
  path: '/intranet/{my_entity}/something'
  defaults:
    _entity_form: 'my_entity.default'
    _title: 'Your page title'
  options:
    parameters:
      my_entity:
        type: my_entity
  requirements:
    _permission: 'some permission defined in your module_name.permissions.yml file'


The     _entity_form is composed of two parts: before the dot, you have the entity type id, in this example my_entity. Behind the dot, you have the name of the form, defined in the handlers section of the @ContentEntityType annotation. In this case, the second part is default, According to your question's code, this refers to \Drupal\my_entity\Form\MyEntityForm. You might not need the route_callbacks code, as a static routing directly in the yml file is probably enough.

For more details, see https://www.drupal.org/docs/8/api/routing-system/structure-of-routes.