Programmatically get the list of fields of a custom content
You're mixing up entity types/node (content) types/bundles. Common mistake :)

Especially since the UI naming is... very unfortunate.

What is called Content in the UI is actually the entity type node. And Content types are node types (you figured out that much), which are bundles of the node entity type.

getFieldDefinitions() expects an entity_type ID and a bundle. In your case, that is:

$definitions = \Drupal::service('entity_field.manager')-&gt;getFieldDefinitions('node', 'my_custom_content');


Note that this will also return base field definitions like nid, vid, title, status and so on.

Tipp: Once you have a node object, you can get the same definition from that object and other useful information too:

$node = Node::create(['type' =&gt; 'my_custom_content']);
$node-&gt;getFieldDefinitions();
$node-&gt;getFieldDefinition('body');
$node-&gt;hasField('body');


So if you want to dynamically do something like this, it can simplify your code a lot if you first create the node with the information that's always enable and then work with the methods on your entity object.

Default recommendation when working with entities in 8.x: http://wizzlern.nl/drupal/drupal-8-entity-cheat-sheet