Skip to content

Instantly share code, notes, and snippets.

@daggerhart
Last active July 7, 2017 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daggerhart/07f7223accc795879c5849b0959bce4e to your computer and use it in GitHub Desktop.
Save daggerhart/07f7223accc795879c5849b0959bce4e to your computer and use it in GitHub Desktop.
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