Last active
July 7, 2017 19:21
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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