' . t('About') . ''; $output .= '

' . t('Edlp module that handle chutier and compositions entities') . '

'; return $output; default: } } /** * hook_entity_extra_field_info() * */ function edlp_studio_entity_extra_field_info(){ $extra = []; // TODO: get node content type by settings @see readme $extra['node']['enregistrement']['display']['add_to_chutier'] = [ 'label' => t('Add to chutier link'), 'description' => 'Display a link to add the content to chutier', 'weight' => 99, 'visible' => FALSE, ]; return $extra; } /** * Implements hook_ENTITY_TYPE_view(). * @see https://www.amazeelabs.com/en/render-menu-tree-custom-code-drupal-8 */ function edlp_studio_node_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) { $display_settings = $display->getComponent('add_to_chutier'); if (!empty($display_settings)) { // dpm($entity); // dpm($entity->id()); $url = Url::fromRoute('edlp_studio.chutier_controller_add_content', ['id'=>$entity->id()], array( 'attributes' => array( 'class' => ['add-to-chutier-link', 'ajax-link'], 'target_id' => $entity->id(), ) )); $build['add_to_chutier'] = array( '#title' => t("Add this content to chutier."), '#type' => 'link', '#url' => $url, '#options'=>array( 'attributes' => array( 'data-drupal-link-system-path' => $url->getInternalPath() ) ) ); } }