Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Drupal 8 - How to add Automatic Entity Label support to ECK (Entity Construction Kit) created bundles
<?php
/**
* Implements hook_entity_type_alter().
*/
function example_entity_type_alter(array &$entity_types)
{
foreach ($entity_types as $entity_type) {
if ($entity_type->getProvider() == 'eck' && !is_null($entity_type->getBundleOf())){
$entity_type->setLinkTemplate('auto-label', $entity_type->getLinkTemplate('edit-form') . "/auto-label");
}
}
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function example_form_auto_entitylabel_settings_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
$path = \Drupal::request()->getpathInfo();
$arg = explode('/',$path);
if ($arg[2] == 'eck') {
$form['auto_entitylabel']['token_help']['#token_types'][] = $arg[5];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment