PHP code example of chi-teck / field_definition_dumper

1. Go to this page and download the library: Download chi-teck/field_definition_dumper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

chi-teck / field_definition_dumper example snippets


$fields['uid'] = BaseFieldDefinition::create('entity_reference')
  ->setLabel(t('Authored by'))
  ->setSetting('target_type', 'user')
  ->setDisplayOptions('form', [
    'type' => 'entity_reference_autocomplete',
    'settings' => [
      'match_operator' => 'CONTAINS',
      'size' => '30',
      'placeholder' => '',
    ],
  ])
  ->setDisplayOptions('view', [
    'label' => 'hidden',
    'type' => 'author',
  ]);

$display_options = [
  'type' => 'entity_reference_label',
  'settings' => ['link' => FALSE],
];
$build = $node->uid->view($display_options);

$settings['config_exclude_modules'] = ['field_definition_dumper'];