Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_access.twig
vendored
Normal file
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_access.twig
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_access().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account) {
|
||||
// No opinion.
|
||||
return AccessResult::neutral();
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_build_defaults_alter().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_build_defaults_alter(array &$build, \Drupal\Core\Entity\EntityInterface $entity, $view_mode) {
|
||||
|
||||
}
|
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_create.twig
vendored
Normal file
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_create.twig
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_create().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_create(\Drupal\Core\Entity\EntityInterface $entity) {
|
||||
\Drupal::logger('example')->info('ENTITY_TYPE created: @label', ['@label' => $entity->label()]);
|
||||
}
|
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_create_access.twig
vendored
Normal file
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_create_access.twig
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_create_access().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_create_access(\Drupal\Core\Session\AccountInterface $account, array $context, $entity_bundle) {
|
||||
// No opinion.
|
||||
return AccessResult::neutral();
|
||||
}
|
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_delete.twig
vendored
Normal file
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_delete.twig
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_delete().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_delete(Drupal\Core\Entity\EntityInterface $entity) {
|
||||
// Delete the entity's entry from a fictional table of all entities.
|
||||
\Drupal::database()->delete('example_entity')
|
||||
->condition('type', $entity->getEntityTypeId())
|
||||
->condition('id', $entity->id())
|
||||
->execute();
|
||||
}
|
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_field_values_init.twig
vendored
Normal file
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_field_values_init.twig
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_field_values_init().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_field_values_init(\Drupal\Core\Entity\FieldableEntityInterface $entity) {
|
||||
if (!$entity->foo->value) {
|
||||
$entity->foo->value = 'some_initial_value';
|
||||
}
|
||||
}
|
13
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_insert.twig
vendored
Normal file
13
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_insert.twig
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_insert().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_insert(Drupal\Core\Entity\EntityInterface $entity) {
|
||||
// Insert the new entity into a fictional table of this type of entity.
|
||||
\Drupal::database()->insert('example_entity')
|
||||
->fields([
|
||||
'id' => $entity->id(),
|
||||
'created' => REQUEST_TIME,
|
||||
'updated' => REQUEST_TIME,
|
||||
])
|
||||
->execute();
|
||||
}
|
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_load.twig
vendored
Normal file
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_load.twig
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_load().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_load($entities) {
|
||||
foreach ($entities as $entity) {
|
||||
$entity->foo = mymodule_add_something($entity);
|
||||
}
|
||||
}
|
22
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_predelete.twig
vendored
Normal file
22
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_predelete.twig
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_predelete().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_predelete(Drupal\Core\Entity\EntityInterface $entity) {
|
||||
$connection = \Drupal::database();
|
||||
// Count references to this entity in a custom table before they are removed
|
||||
// upon entity deletion.
|
||||
$id = $entity->id();
|
||||
$type = $entity->getEntityTypeId();
|
||||
$count = \Drupal::database()->select('example_entity_data')
|
||||
->condition('type', $type)
|
||||
->condition('id', $id)
|
||||
->countQuery()
|
||||
->execute()
|
||||
->fetchField();
|
||||
|
||||
// Log the count in a table that records this statistic for deleted entities.
|
||||
$connection->merge('example_deleted_entity_statistics')
|
||||
->key(['type' => $type, 'id' => $id])
|
||||
->fields(['count' => $count])
|
||||
->execute();
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_prepare_form.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_prepare_form.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_prepare_form().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_prepare_form(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Form\FormStateInterface $form_state) {
|
||||
if ($operation == 'edit') {
|
||||
$entity->label->value = 'Altered label';
|
||||
$form_state->set('label_altered', TRUE);
|
||||
}
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_presave.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_presave.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_presave().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_presave(Drupal\Core\Entity\EntityInterface $entity) {
|
||||
if ($entity->isTranslatable()) {
|
||||
$route_match = \Drupal::routeMatch();
|
||||
\Drupal::service('content_translation.synchronizer')->synchronizeFields($entity, $entity->language()->getId(), $route_match->getParameter('source_langcode'));
|
||||
}
|
||||
}
|
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_revision_create.twig
vendored
Normal file
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_revision_create.twig
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_revision_create().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_revision_create(Drupal\Core\Entity\EntityInterface $new_revision, Drupal\Core\Entity\EntityInterface $entity, $keep_untranslatable_fields) {
|
||||
// Retain the value from an untranslatable field, which are by default
|
||||
// synchronized from the default revision.
|
||||
$new_revision->set('untranslatable_field', $entity->get('untranslatable_field'));
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_revision_delete.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_revision_delete.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_revision_delete().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_revision_delete(Drupal\Core\Entity\EntityInterface $entity) {
|
||||
$referenced_files_by_field = _editor_get_file_uuids_by_field($entity);
|
||||
foreach ($referenced_files_by_field as $field => $uuids) {
|
||||
_editor_delete_file_usage($uuids, $entity, 1);
|
||||
}
|
||||
}
|
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_storage_load.twig
vendored
Normal file
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_storage_load.twig
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_storage_load().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_storage_load(array $entities) {
|
||||
foreach ($entities as $entity) {
|
||||
$entity->foo = mymodule_add_something_uncached($entity);
|
||||
}
|
||||
}
|
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_translation_create.twig
vendored
Normal file
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_translation_create.twig
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_translation_create().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_translation_create(\Drupal\Core\Entity\EntityInterface $translation) {
|
||||
\Drupal::logger('example')->info('ENTITY_TYPE translation created: @label', ['@label' => $translation->label()]);
|
||||
}
|
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_translation_delete.twig
vendored
Normal file
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_translation_delete.twig
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_translation_delete().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_translation_delete(\Drupal\Core\Entity\EntityInterface $translation) {
|
||||
$variables = [
|
||||
'@language' => $translation->language()->getName(),
|
||||
'@label' => $translation->label(),
|
||||
];
|
||||
\Drupal::logger('example')->notice('The @language translation of @label has just been deleted.', $variables);
|
||||
}
|
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_translation_insert.twig
vendored
Normal file
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_translation_insert.twig
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_translation_insert().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_translation_insert(\Drupal\Core\Entity\EntityInterface $translation) {
|
||||
$variables = [
|
||||
'@language' => $translation->language()->getName(),
|
||||
'@label' => $translation->getUntranslated()->label(),
|
||||
];
|
||||
\Drupal::logger('example')->notice('The @language translation of @label has just been stored.', $variables);
|
||||
}
|
12
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_update.twig
vendored
Normal file
12
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_update.twig
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_update().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_update(Drupal\Core\Entity\EntityInterface $entity) {
|
||||
// Update the entity's entry in a fictional table of this type of entity.
|
||||
\Drupal::database()->update('example_entity')
|
||||
->fields([
|
||||
'updated' => REQUEST_TIME,
|
||||
])
|
||||
->condition('id', $entity->id())
|
||||
->execute();
|
||||
}
|
14
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_view.twig
vendored
Normal file
14
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_view.twig
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_view().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {
|
||||
// Only do the extra work if the component is configured to be displayed.
|
||||
// This assumes a 'mymodule_addition' extra field has been defined for the
|
||||
// entity bundle in hook_entity_extra_field_info().
|
||||
if ($display->getComponent('mymodule_addition')) {
|
||||
$build['mymodule_addition'] = [
|
||||
'#markup' => mymodule_addition($entity),
|
||||
'#theme' => 'mymodule_my_additional_field',
|
||||
];
|
||||
}
|
||||
}
|
12
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_view_alter.twig
vendored
Normal file
12
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_view_alter.twig
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* Implements hook_ENTITY_TYPE_view_alter().
|
||||
*/
|
||||
function {{ machine_name }}_ENTITY_TYPE_view_alter(array &$build, Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display) {
|
||||
if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
|
||||
// Change its weight.
|
||||
$build['an_additional_field']['#weight'] = -10;
|
||||
|
||||
// Add a #post_render callback to act on the rendered HTML of the entity.
|
||||
$build['#post_render'][] = 'my_module_node_post_render';
|
||||
}
|
||||
}
|
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/aggregator_fetcher_info_alter.twig
vendored
Normal file
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/aggregator_fetcher_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Implements hook_aggregator_fetcher_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_aggregator_fetcher_info_alter(array &$info) {
|
||||
if (empty($info['foo_fetcher'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$info['foo_fetcher']['class'] = Drupal\foo\Plugin\aggregator\fetcher\FooDefaultFetcher::class;
|
||||
}
|
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/aggregator_parser_info_alter.twig
vendored
Normal file
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/aggregator_parser_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Implements hook_aggregator_parser_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_aggregator_parser_info_alter(array &$info) {
|
||||
if (empty($info['foo_parser'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$info['foo_parser']['class'] = Drupal\foo\Plugin\aggregator\parser\FooDefaultParser::class;
|
||||
}
|
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/aggregator_processor_info_alter.twig
vendored
Normal file
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/aggregator_processor_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Implements hook_aggregator_processor_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_aggregator_processor_info_alter(array &$info) {
|
||||
if (empty($info['foo_processor'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$info['foo_processor']['class'] = Drupal\foo\Plugin\aggregator\processor\FooDefaultProcessor::class;
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ajax_render_alter.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ajax_render_alter.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_ajax_render_alter().
|
||||
*/
|
||||
function {{ machine_name }}_ajax_render_alter(array &$data) {
|
||||
// Inject any new status messages into the content area.
|
||||
$status_messages = ['#type' => 'status_messages'];
|
||||
$command = new \Drupal\Core\Ajax\PrependCommand('#block-system-main .content', \Drupal::service('renderer')->renderRoot($status_messages));
|
||||
$data[] = $command->render();
|
||||
}
|
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/archiver_info_alter.twig
vendored
Normal file
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/archiver_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* Implements hook_archiver_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_archiver_info_alter(&$info) {
|
||||
$info['tar']['extensions'][] = 'tgz';
|
||||
}
|
5
vendor/chi-teck/drupal-code-generator/templates/d8/hook/batch_alter.twig
vendored
Normal file
5
vendor/chi-teck/drupal-code-generator/templates/d8/hook/batch_alter.twig
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
/**
|
||||
* Implements hook_batch_alter().
|
||||
*/
|
||||
function {{ machine_name }}_batch_alter(&$batch) {
|
||||
}
|
13
vendor/chi-teck/drupal-code-generator/templates/d8/hook/block_access.twig
vendored
Normal file
13
vendor/chi-teck/drupal-code-generator/templates/d8/hook/block_access.twig
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* Implements hook_block_access().
|
||||
*/
|
||||
function {{ machine_name }}_block_access(\Drupal\block\Entity\Block $block, $operation, \Drupal\Core\Session\AccountInterface $account) {
|
||||
// Example code that would prevent displaying the 'Powered by Drupal' block in
|
||||
// a region different than the footer.
|
||||
if ($operation == 'view' && $block->getPluginId() == 'system_powered_by_block') {
|
||||
return AccessResult::forbiddenIf($block->getRegion() != 'footer')->addCacheableDependency($block);
|
||||
}
|
||||
|
||||
// No opinion.
|
||||
return AccessResult::neutral();
|
||||
}
|
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/block_build_BASE_BLOCK_ID_alter.twig
vendored
Normal file
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/block_build_BASE_BLOCK_ID_alter.twig
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* Implements hook_block_build_BASE_BLOCK_ID_alter().
|
||||
*/
|
||||
function {{ machine_name }}_block_build_BASE_BLOCK_ID_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) {
|
||||
// Explicitly enable placeholdering of the specific block.
|
||||
$build['#create_placeholder'] = TRUE;
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/block_build_alter.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/block_build_alter.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_block_build_alter().
|
||||
*/
|
||||
function {{ machine_name }}_block_build_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) {
|
||||
// Add the 'user' cache context to some blocks.
|
||||
if ($block->label() === 'some condition') {
|
||||
$build['#cache']['contexts'][] = 'user';
|
||||
}
|
||||
}
|
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/block_view_BASE_BLOCK_ID_alter.twig
vendored
Normal file
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/block_view_BASE_BLOCK_ID_alter.twig
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* Implements hook_block_view_BASE_BLOCK_ID_alter().
|
||||
*/
|
||||
function {{ machine_name }}_block_view_BASE_BLOCK_ID_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) {
|
||||
// Change the title of the specific block.
|
||||
$build['#title'] = t('New title of the block');
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/block_view_alter.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/block_view_alter.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_block_view_alter().
|
||||
*/
|
||||
function {{ machine_name }}_block_view_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) {
|
||||
// Remove the contextual links on all blocks that provide them.
|
||||
if (isset($build['#contextual_links'])) {
|
||||
unset($build['#contextual_links']);
|
||||
}
|
||||
}
|
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/cache_flush.twig
vendored
Normal file
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/cache_flush.twig
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Implements hook_cache_flush().
|
||||
*/
|
||||
function {{ machine_name }}_cache_flush() {
|
||||
if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update') {
|
||||
_update_cache_clear();
|
||||
}
|
||||
}
|
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ckeditor_css_alter.twig
vendored
Normal file
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ckeditor_css_alter.twig
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* Implements hook_ckeditor_css_alter().
|
||||
*/
|
||||
function {{ machine_name }}_ckeditor_css_alter(array &$css, Editor $editor) {
|
||||
$css[] = drupal_get_path('module', 'mymodule') . '/css/mymodule-ckeditor.css';
|
||||
}
|
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ckeditor_plugin_info_alter.twig
vendored
Normal file
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/ckeditor_plugin_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* Implements hook_ckeditor_plugin_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_ckeditor_plugin_info_alter(array &$plugins) {
|
||||
$plugins['someplugin']['label'] = t('Better name');
|
||||
}
|
15
vendor/chi-teck/drupal-code-generator/templates/d8/hook/comment_links_alter.twig
vendored
Normal file
15
vendor/chi-teck/drupal-code-generator/templates/d8/hook/comment_links_alter.twig
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* Implements hook_comment_links_alter().
|
||||
*/
|
||||
function {{ machine_name }}_comment_links_alter(array &$links, CommentInterface $entity, array &$context) {
|
||||
$links['mymodule'] = [
|
||||
'#theme' => 'links__comment__mymodule',
|
||||
'#attributes' => ['class' => ['links', 'inline']],
|
||||
'#links' => [
|
||||
'comment-report' => [
|
||||
'title' => t('Report'),
|
||||
'url' => Url::fromRoute('comment_test.report', ['comment' => $entity->id()], ['query' => ['token' => \Drupal::getContainer()->get('csrf_token')->get("comment/{$entity->id()}/report")]]),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/config_import_steps_alter.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/config_import_steps_alter.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_config_import_steps_alter().
|
||||
*/
|
||||
function {{ machine_name }}_config_import_steps_alter(&$sync_steps, \Drupal\Core\Config\ConfigImporter $config_importer) {
|
||||
$deletes = $config_importer->getUnprocessedConfiguration('delete');
|
||||
if (isset($deletes['field.storage.node.body'])) {
|
||||
$sync_steps[] = '_additional_configuration_step';
|
||||
}
|
||||
}
|
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/config_schema_info_alter.twig
vendored
Normal file
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/config_schema_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Implements hook_config_schema_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_config_schema_info_alter(&$definitions) {
|
||||
// Enhance the text and date type definitions with classes to generate proper
|
||||
// form elements in ConfigTranslationFormBase. Other translatable types will
|
||||
// appear as a one line textfield.
|
||||
$definitions['text']['form_element_class'] = '\Drupal\config_translation\FormElement\Textarea';
|
||||
$definitions['date_format']['form_element_class'] = '\Drupal\config_translation\FormElement\DateFormat';
|
||||
}
|
34
vendor/chi-teck/drupal-code-generator/templates/d8/hook/config_translation_info.twig
vendored
Normal file
34
vendor/chi-teck/drupal-code-generator/templates/d8/hook/config_translation_info.twig
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* Implements hook_config_translation_info().
|
||||
*/
|
||||
function {{ machine_name }}_config_translation_info(&$info) {
|
||||
$entity_manager = \Drupal::entityManager();
|
||||
$route_provider = \Drupal::service('router.route_provider');
|
||||
|
||||
// If field UI is not enabled, the base routes of the type
|
||||
// "entity.field_config.{$entity_type}_field_edit_form" are not defined.
|
||||
if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
|
||||
// Add fields entity mappers to all fieldable entity types defined.
|
||||
foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
|
||||
$base_route = NULL;
|
||||
try {
|
||||
$base_route = $route_provider->getRouteByName('entity.field_config.' . $entity_type_id . '_field_edit_form');
|
||||
}
|
||||
catch (RouteNotFoundException $e) {
|
||||
// Ignore non-existent routes.
|
||||
}
|
||||
|
||||
// Make sure entity type has field UI enabled and has a base route.
|
||||
if ($entity_type->get('field_ui_base_route') && !empty($base_route)) {
|
||||
$info[$entity_type_id . '_fields'] = [
|
||||
'base_route_name' => 'entity.field_config.' . $entity_type_id . '_field_edit_form',
|
||||
'entity_type' => 'field_config',
|
||||
'title' => t('Title'),
|
||||
'class' => '\Drupal\config_translation\ConfigFieldMapper',
|
||||
'base_entity_type' => $entity_type_id,
|
||||
'weight' => 10,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/config_translation_info_alter.twig
vendored
Normal file
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/config_translation_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Implements hook_config_translation_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_config_translation_info_alter(&$info) {
|
||||
// Add additional site settings to the site information screen, so it shows
|
||||
// up on the translation screen. (Form alter in the elements whose values are
|
||||
// stored in this config file using regular form altering on the original
|
||||
// configuration form.)
|
||||
$info['system.site_information_settings']['names'][] = 'example.site.setting';
|
||||
}
|
11
vendor/chi-teck/drupal-code-generator/templates/d8/hook/contextual_links_alter.twig
vendored
Normal file
11
vendor/chi-teck/drupal-code-generator/templates/d8/hook/contextual_links_alter.twig
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* Implements hook_contextual_links_alter().
|
||||
*/
|
||||
function {{ machine_name }}_contextual_links_alter(array &$links, $group, array $route_parameters) {
|
||||
if ($group == 'menu') {
|
||||
// Dynamically use the menu name for the title of the menu_edit contextual
|
||||
// link.
|
||||
$menu = \Drupal::entityManager()->getStorage('menu')->load($route_parameters['menu']);
|
||||
$links['menu_edit']['title'] = t('Edit menu: @label', ['@label' => $menu->label()]);
|
||||
}
|
||||
}
|
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/contextual_links_plugins_alter.twig
vendored
Normal file
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/contextual_links_plugins_alter.twig
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* Implements hook_contextual_links_plugins_alter().
|
||||
*/
|
||||
function {{ machine_name }}_contextual_links_plugins_alter(array &$contextual_links) {
|
||||
$contextual_links['menu_edit']['title'] = 'Edit the menu';
|
||||
}
|
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/contextual_links_view_alter.twig
vendored
Normal file
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/contextual_links_view_alter.twig
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Implements hook_contextual_links_view_alter().
|
||||
*/
|
||||
function {{ machine_name }}_contextual_links_view_alter(&$element, $items) {
|
||||
// Add another class to all contextual link lists to facilitate custom
|
||||
// styling.
|
||||
$element['#attributes']['class'][] = 'custom-class';
|
||||
}
|
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/countries_alter.twig
vendored
Normal file
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/countries_alter.twig
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* Implements hook_countries_alter().
|
||||
*/
|
||||
function {{ machine_name }}_countries_alter(&$countries) {
|
||||
// Elbonia is now independent, so add it to the country list.
|
||||
$countries['EB'] = 'Elbonia';
|
||||
}
|
34
vendor/chi-teck/drupal-code-generator/templates/d8/hook/cron.twig
vendored
Normal file
34
vendor/chi-teck/drupal-code-generator/templates/d8/hook/cron.twig
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* Implements hook_cron().
|
||||
*/
|
||||
function {{ machine_name }}_cron() {
|
||||
// Short-running operation example, not using a queue:
|
||||
// Delete all expired records since the last cron run.
|
||||
$expires = \Drupal::state()->get('mymodule.last_check', 0);
|
||||
\Drupal::database()->delete('mymodule_table')
|
||||
->condition('expires', $expires, '>=')
|
||||
->execute();
|
||||
\Drupal::state()->set('mymodule.last_check', REQUEST_TIME);
|
||||
|
||||
// Long-running operation example, leveraging a queue:
|
||||
// Queue news feeds for updates once their refresh interval has elapsed.
|
||||
$queue = \Drupal::queue('aggregator_feeds');
|
||||
$ids = \Drupal::entityManager()->getStorage('aggregator_feed')->getFeedIdsToRefresh();
|
||||
foreach (Feed::loadMultiple($ids) as $feed) {
|
||||
if ($queue->createItem($feed)) {
|
||||
// Add timestamp to avoid queueing item more than once.
|
||||
$feed->setQueuedTime(REQUEST_TIME);
|
||||
$feed->save();
|
||||
}
|
||||
}
|
||||
$ids = \Drupal::entityQuery('aggregator_feed')
|
||||
->condition('queued', REQUEST_TIME - (3600 * 6), '<')
|
||||
->execute();
|
||||
if ($ids) {
|
||||
$feeds = Feed::loadMultiple($ids);
|
||||
foreach ($feeds as $feed) {
|
||||
$feed->setQueuedTime(0);
|
||||
$feed->save();
|
||||
}
|
||||
}
|
||||
}
|
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/css_alter.twig
vendored
Normal file
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/css_alter.twig
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* Implements hook_css_alter().
|
||||
*/
|
||||
function {{ machine_name }}_css_alter(&$css, \Drupal\Core\Asset\AttachedAssetsInterface $assets) {
|
||||
// Remove defaults.css file.
|
||||
unset($css[drupal_get_path('module', 'system') . '/defaults.css']);
|
||||
}
|
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/data_type_info_alter.twig
vendored
Normal file
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/data_type_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* Implements hook_data_type_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_data_type_info_alter(&$data_types) {
|
||||
$data_types['email']['class'] = '\Drupal\mymodule\Type\Email';
|
||||
}
|
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/display_variant_plugin_alter.twig
vendored
Normal file
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/display_variant_plugin_alter.twig
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* Implements hook_display_variant_plugin_alter().
|
||||
*/
|
||||
function {{ machine_name }}_display_variant_plugin_alter(array &$definitions) {
|
||||
$definitions['full_page']['admin_label'] = t('Block layout');
|
||||
}
|
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/editor_info_alter.twig
vendored
Normal file
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/editor_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* Implements hook_editor_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_editor_info_alter(array &$editors) {
|
||||
$editors['some_other_editor']['label'] = t('A different name');
|
||||
$editors['some_other_editor']['library']['module'] = 'myeditoroverride';
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/editor_js_settings_alter.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/editor_js_settings_alter.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_editor_js_settings_alter().
|
||||
*/
|
||||
function {{ machine_name }}_editor_js_settings_alter(array &$settings) {
|
||||
if (isset($settings['editor']['formats']['basic_html'])) {
|
||||
$settings['editor']['formats']['basic_html']['editor'] = 'MyDifferentEditor';
|
||||
$settings['editor']['formats']['basic_html']['editorSettings']['buttons'] = ['strong', 'italic', 'underline'];
|
||||
}
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/editor_xss_filter_alter.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/editor_xss_filter_alter.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_editor_xss_filter_alter().
|
||||
*/
|
||||
function {{ machine_name }}_editor_xss_filter_alter(&$editor_xss_filter_class, FilterFormatInterface $format, FilterFormatInterface $original_format = NULL) {
|
||||
$filters = $format->filters()->getAll();
|
||||
if (isset($filters['filter_wysiwyg']) && $filters['filter_wysiwyg']->status) {
|
||||
$editor_xss_filter_class = '\Drupal\filter_wysiwyg\EditorXssFilter\WysiwygFilter';
|
||||
}
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/element_info_alter.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/element_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_element_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_element_info_alter(array &$info) {
|
||||
// Decrease the default size of textfields.
|
||||
if (isset($info['textfield']['#size'])) {
|
||||
$info['textfield']['#size'] = 40;
|
||||
}
|
||||
}
|
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_access.twig
vendored
Normal file
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_access.twig
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* Implements hook_entity_access().
|
||||
*/
|
||||
function {{ machine_name }}_entity_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account) {
|
||||
// No opinion.
|
||||
return AccessResult::neutral();
|
||||
}
|
15
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_base_field_info.twig
vendored
Normal file
15
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_base_field_info.twig
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* Implements hook_entity_base_field_info().
|
||||
*/
|
||||
function {{ machine_name }}_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
|
||||
if ($entity_type->id() == 'node') {
|
||||
$fields = [];
|
||||
$fields['mymodule_text'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('The text'))
|
||||
->setDescription(t('A text property added by mymodule.'))
|
||||
->setComputed(TRUE)
|
||||
->setClass('\Drupal\mymodule\EntityComputedText');
|
||||
|
||||
return $fields;
|
||||
}
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_base_field_info_alter.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_base_field_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_entity_base_field_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_entity_base_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type) {
|
||||
// Alter the mymodule_text field to use a custom class.
|
||||
if ($entity_type->id() == 'node' && !empty($fields['mymodule_text'])) {
|
||||
$fields['mymodule_text']->setClass('\Drupal\anothermodule\EntityComputedText');
|
||||
}
|
||||
}
|
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_build_defaults_alter.twig
vendored
Normal file
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_build_defaults_alter.twig
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* Implements hook_entity_build_defaults_alter().
|
||||
*/
|
||||
function {{ machine_name }}_entity_build_defaults_alter(array &$build, \Drupal\Core\Entity\EntityInterface $entity, $view_mode) {
|
||||
|
||||
}
|
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_bundle_create.twig
vendored
Normal file
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_bundle_create.twig
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Implements hook_entity_bundle_create().
|
||||
*/
|
||||
function {{ machine_name }}_entity_bundle_create($entity_type_id, $bundle) {
|
||||
// When a new bundle is created, the menu needs to be rebuilt to add the
|
||||
// Field UI menu item tabs.
|
||||
\Drupal::service('router.builder')->setRebuildNeeded();
|
||||
}
|
12
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_bundle_delete.twig
vendored
Normal file
12
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_bundle_delete.twig
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* Implements hook_entity_bundle_delete().
|
||||
*/
|
||||
function {{ machine_name }}_entity_bundle_delete($entity_type_id, $bundle) {
|
||||
// Remove the settings associated with the bundle in my_module.settings.
|
||||
$config = \Drupal::config('my_module.settings');
|
||||
$bundle_settings = $config->get('bundle_settings');
|
||||
if (isset($bundle_settings[$entity_type_id][$bundle])) {
|
||||
unset($bundle_settings[$entity_type_id][$bundle]);
|
||||
$config->set('bundle_settings', $bundle_settings);
|
||||
}
|
||||
}
|
14
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_bundle_field_info.twig
vendored
Normal file
14
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_bundle_field_info.twig
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Implements hook_entity_bundle_field_info().
|
||||
*/
|
||||
function {{ machine_name }}_entity_bundle_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
|
||||
// Add a property only to nodes of the 'article' bundle.
|
||||
if ($entity_type->id() == 'node' && $bundle == 'article') {
|
||||
$fields = [];
|
||||
$fields['mymodule_text_more'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('More text'))
|
||||
->setComputed(TRUE)
|
||||
->setClass('\Drupal\mymodule\EntityComputedMoreText');
|
||||
return $fields;
|
||||
}
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_bundle_field_info_alter.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_bundle_field_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_entity_bundle_field_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle) {
|
||||
if ($entity_type->id() == 'node' && $bundle == 'article' && !empty($fields['mymodule_text'])) {
|
||||
// Alter the mymodule_text field to use a custom class.
|
||||
$fields['mymodule_text']->setClass('\Drupal\anothermodule\EntityComputedText');
|
||||
}
|
||||
}
|
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_bundle_info.twig
vendored
Normal file
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_bundle_info.twig
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* Implements hook_entity_bundle_info().
|
||||
*/
|
||||
function {{ machine_name }}_entity_bundle_info() {
|
||||
$bundles['user']['user']['label'] = t('User');
|
||||
return $bundles;
|
||||
}
|
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_bundle_info_alter.twig
vendored
Normal file
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_bundle_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* Implements hook_entity_bundle_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_entity_bundle_info_alter(&$bundles) {
|
||||
$bundles['user']['user']['label'] = t('Full account');
|
||||
}
|
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_create.twig
vendored
Normal file
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_create.twig
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* Implements hook_entity_create().
|
||||
*/
|
||||
function {{ machine_name }}_entity_create(\Drupal\Core\Entity\EntityInterface $entity) {
|
||||
\Drupal::logger('example')->info('Entity created: @label', ['@label' => $entity->label()]);
|
||||
}
|
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_create_access.twig
vendored
Normal file
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_create_access.twig
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* Implements hook_entity_create_access().
|
||||
*/
|
||||
function {{ machine_name }}_entity_create_access(\Drupal\Core\Session\AccountInterface $account, array $context, $entity_bundle) {
|
||||
// No opinion.
|
||||
return AccessResult::neutral();
|
||||
}
|
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_delete.twig
vendored
Normal file
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_delete.twig
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Implements hook_entity_delete().
|
||||
*/
|
||||
function {{ machine_name }}_entity_delete(Drupal\Core\Entity\EntityInterface $entity) {
|
||||
// Delete the entity's entry from a fictional table of all entities.
|
||||
\Drupal::database()->delete('example_entity')
|
||||
->condition('type', $entity->getEntityTypeId())
|
||||
->condition('id', $entity->id())
|
||||
->execute();
|
||||
}
|
20
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_display_build_alter.twig
vendored
Normal file
20
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_display_build_alter.twig
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* Implements hook_entity_display_build_alter().
|
||||
*/
|
||||
function {{ machine_name }}_entity_display_build_alter(&$build, $context) {
|
||||
// Append RDF term mappings on displayed taxonomy links.
|
||||
foreach (Element::children($build) as $field_name) {
|
||||
$element = &$build[$field_name];
|
||||
if ($element['#field_type'] == 'entity_reference' && $element['#formatter'] == 'entity_reference_label') {
|
||||
foreach ($element['#items'] as $delta => $item) {
|
||||
$term = $item->entity;
|
||||
if (!empty($term->rdf_mapping['rdftype'])) {
|
||||
$element[$delta]['#options']['attributes']['typeof'] = $term->rdf_mapping['rdftype'];
|
||||
}
|
||||
if (!empty($term->rdf_mapping['name']['predicates'])) {
|
||||
$element[$delta]['#options']['attributes']['property'] = $term->rdf_mapping['name']['predicates'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
34
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_extra_field_info.twig
vendored
Normal file
34
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_extra_field_info.twig
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* Implements hook_entity_extra_field_info().
|
||||
*/
|
||||
function {{ machine_name }}_entity_extra_field_info() {
|
||||
$extra = [];
|
||||
$module_language_enabled = \Drupal::moduleHandler()->moduleExists('language');
|
||||
$description = t('Node module element');
|
||||
|
||||
foreach (NodeType::loadMultiple() as $bundle) {
|
||||
|
||||
// Add also the 'language' select if Language module is enabled and the
|
||||
// bundle has multilingual support.
|
||||
// Visibility of the ordering of the language selector is the same as on the
|
||||
// node/add form.
|
||||
if ($module_language_enabled) {
|
||||
$configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', $bundle->id());
|
||||
if ($configuration->isLanguageAlterable()) {
|
||||
$extra['node'][$bundle->id()]['form']['language'] = [
|
||||
'label' => t('Language'),
|
||||
'description' => $description,
|
||||
'weight' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
$extra['node'][$bundle->id()]['display']['language'] = [
|
||||
'label' => t('Language'),
|
||||
'description' => $description,
|
||||
'weight' => 0,
|
||||
'visible' => FALSE,
|
||||
];
|
||||
}
|
||||
|
||||
return $extra;
|
||||
}
|
11
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_extra_field_info_alter.twig
vendored
Normal file
11
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_extra_field_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* Implements hook_entity_extra_field_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_entity_extra_field_info_alter(&$info) {
|
||||
// Force node title to always be at the top of the list by default.
|
||||
foreach (NodeType::loadMultiple() as $bundle) {
|
||||
if (isset($info['node'][$bundle->id()]['form']['title'])) {
|
||||
$info['node'][$bundle->id()]['form']['title']['weight'] = -20;
|
||||
}
|
||||
}
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_field_access.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_field_access.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_entity_field_access().
|
||||
*/
|
||||
function {{ machine_name }}_entity_field_access($operation, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, \Drupal\Core\Session\AccountInterface $account, \Drupal\Core\Field\FieldItemListInterface $items = NULL) {
|
||||
if ($field_definition->getName() == 'field_of_interest' && $operation == 'edit') {
|
||||
return AccessResult::allowedIfHasPermission($account, 'update field of interest');
|
||||
}
|
||||
return AccessResult::neutral();
|
||||
}
|
16
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_field_access_alter.twig
vendored
Normal file
16
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_field_access_alter.twig
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Implements hook_entity_field_access_alter().
|
||||
*/
|
||||
function {{ machine_name }}_entity_field_access_alter(array &$grants, array $context) {
|
||||
/** @var \Drupal\Core\Field\FieldDefinitionInterface $field_definition */
|
||||
$field_definition = $context['field_definition'];
|
||||
if ($field_definition->getName() == 'field_of_interest' && $grants['node']->isForbidden()) {
|
||||
// Override node module's restriction to no opinion (neither allowed nor
|
||||
// forbidden). We don't want to provide our own access hook, we only want to
|
||||
// take out node module's part in the access handling of this field. We also
|
||||
// don't want to switch node module's grant to
|
||||
// AccessResultInterface::isAllowed() , because the grants of other modules
|
||||
// should still decide on their own if this field is accessible or not
|
||||
$grants['node'] = AccessResult::neutral()->inheritCacheability($grants['node']);
|
||||
}
|
||||
}
|
20
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_field_storage_info.twig
vendored
Normal file
20
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_field_storage_info.twig
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* Implements hook_entity_field_storage_info().
|
||||
*/
|
||||
function {{ machine_name }}_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
|
||||
if (\Drupal::entityManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) {
|
||||
// Query by filtering on the ID as this is more efficient than filtering
|
||||
// on the entity_type property directly.
|
||||
$ids = \Drupal::entityQuery('field_storage_config')
|
||||
->condition('id', $entity_type->id() . '.', 'STARTS_WITH')
|
||||
->execute();
|
||||
// Fetch all fields and key them by field name.
|
||||
$field_storages = FieldStorageConfig::loadMultiple($ids);
|
||||
$result = [];
|
||||
foreach ($field_storages as $field_storage) {
|
||||
$result[$field_storage->getName()] = $field_storage;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_field_storage_info_alter.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_field_storage_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_entity_field_storage_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_entity_field_storage_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type) {
|
||||
// Alter the max_length setting.
|
||||
if ($entity_type->id() == 'node' && !empty($fields['mymodule_text'])) {
|
||||
$fields['mymodule_text']->setSetting('max_length', 128);
|
||||
}
|
||||
}
|
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_field_values_init.twig
vendored
Normal file
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_field_values_init.twig
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Implements hook_entity_field_values_init().
|
||||
*/
|
||||
function {{ machine_name }}_entity_field_values_init(\Drupal\Core\Entity\FieldableEntityInterface $entity) {
|
||||
if ($entity instanceof \Drupal\Core\Entity\ContentEntityInterface && !$entity->foo->value) {
|
||||
$entity->foo->value = 'some_initial_value';
|
||||
}
|
||||
}
|
11
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_form_display_alter.twig
vendored
Normal file
11
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_form_display_alter.twig
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* Implements hook_entity_form_display_alter().
|
||||
*/
|
||||
function {{ machine_name }}_entity_form_display_alter(\Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display, array $context) {
|
||||
// Hide the 'user_picture' field from the register form.
|
||||
if ($context['entity_type'] == 'user' && $context['form_mode'] == 'register') {
|
||||
$form_display->setComponent('user_picture', [
|
||||
'region' => 'hidden',
|
||||
]);
|
||||
}
|
||||
}
|
14
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_insert.twig
vendored
Normal file
14
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_insert.twig
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Implements hook_entity_insert().
|
||||
*/
|
||||
function {{ machine_name }}_entity_insert(Drupal\Core\Entity\EntityInterface $entity) {
|
||||
// Insert the new entity into a fictional table of all entities.
|
||||
\Drupal::database()->insert('example_entity')
|
||||
->fields([
|
||||
'type' => $entity->getEntityTypeId(),
|
||||
'id' => $entity->id(),
|
||||
'created' => REQUEST_TIME,
|
||||
'updated' => REQUEST_TIME,
|
||||
])
|
||||
->execute();
|
||||
}
|
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_load.twig
vendored
Normal file
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_load.twig
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Implements hook_entity_load().
|
||||
*/
|
||||
function {{ machine_name }}_entity_load(array $entities, $entity_type_id) {
|
||||
foreach ($entities as $entity) {
|
||||
$entity->foo = mymodule_add_something($entity);
|
||||
}
|
||||
}
|
13
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_operation.twig
vendored
Normal file
13
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_operation.twig
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* Implements hook_entity_operation().
|
||||
*/
|
||||
function {{ machine_name }}_entity_operation(\Drupal\Core\Entity\EntityInterface $entity) {
|
||||
$operations = [];
|
||||
$operations['translate'] = [
|
||||
'title' => t('Translate'),
|
||||
'url' => \Drupal\Core\Url::fromRoute('foo_module.entity.translate'),
|
||||
'weight' => 50,
|
||||
];
|
||||
|
||||
return $operations;
|
||||
}
|
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_operation_alter.twig
vendored
Normal file
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_operation_alter.twig
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Implements hook_entity_operation_alter().
|
||||
*/
|
||||
function {{ machine_name }}_entity_operation_alter(array &$operations, \Drupal\Core\Entity\EntityInterface $entity) {
|
||||
// Alter the title and weight.
|
||||
$operations['translate']['title'] = t('Translate @entity_type', [
|
||||
'@entity_type' => $entity->getEntityTypeId(),
|
||||
]);
|
||||
$operations['translate']['weight'] = 99;
|
||||
}
|
22
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_predelete.twig
vendored
Normal file
22
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_predelete.twig
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Implements hook_entity_predelete().
|
||||
*/
|
||||
function {{ machine_name }}_entity_predelete(Drupal\Core\Entity\EntityInterface $entity) {
|
||||
$connection = \Drupal::database();
|
||||
// Count references to this entity in a custom table before they are removed
|
||||
// upon entity deletion.
|
||||
$id = $entity->id();
|
||||
$type = $entity->getEntityTypeId();
|
||||
$count = \Drupal::database()->select('example_entity_data')
|
||||
->condition('type', $type)
|
||||
->condition('id', $id)
|
||||
->countQuery()
|
||||
->execute()
|
||||
->fetchField();
|
||||
|
||||
// Log the count in a table that records this statistic for deleted entities.
|
||||
$connection->merge('example_deleted_entity_statistics')
|
||||
->key(['type' => $type, 'id' => $id])
|
||||
->fields(['count' => $count])
|
||||
->execute();
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_prepare_form.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_prepare_form.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_entity_prepare_form().
|
||||
*/
|
||||
function {{ machine_name }}_entity_prepare_form(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Form\FormStateInterface $form_state) {
|
||||
if ($operation == 'edit') {
|
||||
$entity->label->value = 'Altered label';
|
||||
$form_state->set('label_altered', TRUE);
|
||||
}
|
||||
}
|
23
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_prepare_view.twig
vendored
Normal file
23
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_prepare_view.twig
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* Implements hook_entity_prepare_view().
|
||||
*/
|
||||
function {{ machine_name }}_entity_prepare_view($entity_type_id, array $entities, array $displays, $view_mode) {
|
||||
// Load a specific node into the user object for later theming.
|
||||
if (!empty($entities) && $entity_type_id == 'user') {
|
||||
// Only do the extra work if the component is configured to be
|
||||
// displayed. This assumes a 'mymodule_addition' extra field has been
|
||||
// defined for the entity bundle in hook_entity_extra_field_info().
|
||||
$ids = [];
|
||||
foreach ($entities as $id => $entity) {
|
||||
if ($displays[$entity->bundle()]->getComponent('mymodule_addition')) {
|
||||
$ids[] = $id;
|
||||
}
|
||||
}
|
||||
if ($ids) {
|
||||
$nodes = mymodule_get_user_nodes($ids);
|
||||
foreach ($ids as $id) {
|
||||
$entities[$id]->user_node = $nodes[$id];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_presave.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_presave.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_entity_presave().
|
||||
*/
|
||||
function {{ machine_name }}_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
|
||||
if ($entity instanceof ContentEntityInterface && $entity->isTranslatable()) {
|
||||
$route_match = \Drupal::routeMatch();
|
||||
\Drupal::service('content_translation.synchronizer')->synchronizeFields($entity, $entity->language()->getId(), $route_match->getParameter('source_langcode'));
|
||||
}
|
||||
}
|
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_revision_create.twig
vendored
Normal file
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_revision_create.twig
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Implements hook_entity_revision_create().
|
||||
*/
|
||||
function {{ machine_name }}_entity_revision_create(Drupal\Core\Entity\EntityInterface $new_revision, Drupal\Core\Entity\EntityInterface $entity, $keep_untranslatable_fields) {
|
||||
// Retain the value from an untranslatable field, which are by default
|
||||
// synchronized from the default revision.
|
||||
$new_revision->set('untranslatable_field', $entity->get('untranslatable_field'));
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_revision_delete.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_revision_delete.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_entity_revision_delete().
|
||||
*/
|
||||
function {{ machine_name }}_entity_revision_delete(Drupal\Core\Entity\EntityInterface $entity) {
|
||||
$referenced_files_by_field = _editor_get_file_uuids_by_field($entity);
|
||||
foreach ($referenced_files_by_field as $field => $uuids) {
|
||||
_editor_delete_file_usage($uuids, $entity, 1);
|
||||
}
|
||||
}
|
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_storage_load.twig
vendored
Normal file
8
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_storage_load.twig
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Implements hook_entity_storage_load().
|
||||
*/
|
||||
function {{ machine_name }}_entity_storage_load(array $entities, $entity_type) {
|
||||
foreach ($entities as $entity) {
|
||||
$entity->foo = mymodule_add_something_uncached($entity);
|
||||
}
|
||||
}
|
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_translation_create.twig
vendored
Normal file
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_translation_create.twig
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* Implements hook_entity_translation_create().
|
||||
*/
|
||||
function {{ machine_name }}_entity_translation_create(\Drupal\Core\Entity\EntityInterface $translation) {
|
||||
\Drupal::logger('example')->info('Entity translation created: @label', ['@label' => $translation->label()]);
|
||||
}
|
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_translation_delete.twig
vendored
Normal file
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_translation_delete.twig
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Implements hook_entity_translation_delete().
|
||||
*/
|
||||
function {{ machine_name }}_entity_translation_delete(\Drupal\Core\Entity\EntityInterface $translation) {
|
||||
$variables = [
|
||||
'@language' => $translation->language()->getName(),
|
||||
'@label' => $translation->label(),
|
||||
];
|
||||
\Drupal::logger('example')->notice('The @language translation of @label has just been deleted.', $variables);
|
||||
}
|
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_translation_insert.twig
vendored
Normal file
10
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_translation_insert.twig
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Implements hook_entity_translation_insert().
|
||||
*/
|
||||
function {{ machine_name }}_entity_translation_insert(\Drupal\Core\Entity\EntityInterface $translation) {
|
||||
$variables = [
|
||||
'@language' => $translation->language()->getName(),
|
||||
'@label' => $translation->getUntranslated()->label(),
|
||||
];
|
||||
\Drupal::logger('example')->notice('The @language translation of @label has just been stored.', $variables);
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_type_alter.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_type_alter.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_entity_type_alter().
|
||||
*/
|
||||
function {{ machine_name }}_entity_type_alter(array &$entity_types) {
|
||||
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
|
||||
// Set the controller class for nodes to an alternate implementation of the
|
||||
// Drupal\Core\Entity\EntityStorageInterface interface.
|
||||
$entity_types['node']->setStorageClass('Drupal\mymodule\MyCustomNodeStorage');
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_type_build.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_type_build.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_entity_type_build().
|
||||
*/
|
||||
function {{ machine_name }}_entity_type_build(array &$entity_types) {
|
||||
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
|
||||
// Add a form for a custom node form without overriding the default
|
||||
// node form. To override the default node form, use hook_entity_type_alter().
|
||||
$entity_types['node']->setFormClass('mymodule_foo', 'Drupal\mymodule\NodeFooForm');
|
||||
}
|
13
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_update.twig
vendored
Normal file
13
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_update.twig
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* Implements hook_entity_update().
|
||||
*/
|
||||
function {{ machine_name }}_entity_update(Drupal\Core\Entity\EntityInterface $entity) {
|
||||
// Update the entity's entry in a fictional table of all entities.
|
||||
\Drupal::database()->update('example_entity')
|
||||
->fields([
|
||||
'updated' => REQUEST_TIME,
|
||||
])
|
||||
->condition('type', $entity->getEntityTypeId())
|
||||
->condition('id', $entity->id())
|
||||
->execute();
|
||||
}
|
14
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_view.twig
vendored
Normal file
14
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_view.twig
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Implements hook_entity_view().
|
||||
*/
|
||||
function {{ machine_name }}_entity_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {
|
||||
// Only do the extra work if the component is configured to be displayed.
|
||||
// This assumes a 'mymodule_addition' extra field has been defined for the
|
||||
// entity bundle in hook_entity_extra_field_info().
|
||||
if ($display->getComponent('mymodule_addition')) {
|
||||
$build['mymodule_addition'] = [
|
||||
'#markup' => mymodule_addition($entity),
|
||||
'#theme' => 'mymodule_my_additional_field',
|
||||
];
|
||||
}
|
||||
}
|
12
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_view_alter.twig
vendored
Normal file
12
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_view_alter.twig
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* Implements hook_entity_view_alter().
|
||||
*/
|
||||
function {{ machine_name }}_entity_view_alter(array &$build, Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display) {
|
||||
if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
|
||||
// Change its weight.
|
||||
$build['an_additional_field']['#weight'] = -10;
|
||||
|
||||
// Add a #post_render callback to act on the rendered HTML of the entity.
|
||||
$build['#post_render'][] = 'my_module_node_post_render';
|
||||
}
|
||||
}
|
14
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_view_display_alter.twig
vendored
Normal file
14
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_view_display_alter.twig
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Implements hook_entity_view_display_alter().
|
||||
*/
|
||||
function {{ machine_name }}_entity_view_display_alter(\Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, array $context) {
|
||||
// Leave field labels out of the search index.
|
||||
if ($context['entity_type'] == 'node' && $context['view_mode'] == 'search_index') {
|
||||
foreach ($display->getComponents() as $name => $options) {
|
||||
if (isset($options['label'])) {
|
||||
$options['label'] = 'hidden';
|
||||
$display->setComponent($name, $options);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_view_mode_alter.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_view_mode_alter.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_entity_view_mode_alter().
|
||||
*/
|
||||
function {{ machine_name }}_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInterface $entity, $context) {
|
||||
// For nodes, change the view mode when it is teaser.
|
||||
if ($entity->getEntityTypeId() == 'node' && $view_mode == 'teaser') {
|
||||
$view_mode = 'my_custom_view_mode';
|
||||
}
|
||||
}
|
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_view_mode_info_alter.twig
vendored
Normal file
6
vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_view_mode_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* Implements hook_entity_view_mode_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_entity_view_mode_info_alter(&$view_modes) {
|
||||
$view_modes['user']['full']['status'] = TRUE;
|
||||
}
|
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/extension.twig
vendored
Normal file
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/extension.twig
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* Implements hook_extension().
|
||||
*/
|
||||
function {{ machine_name }}_extension() {
|
||||
// Extension for template base names in Twig.
|
||||
return '.html.twig';
|
||||
}
|
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/field_formatter_info_alter.twig
vendored
Normal file
7
vendor/chi-teck/drupal-code-generator/templates/d8/hook/field_formatter_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* Implements hook_field_formatter_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_field_formatter_info_alter(array &$info) {
|
||||
// Let a new field type re-use an existing formatter.
|
||||
$info['text_default']['field_types'][] = 'my_field_type';
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* Implements hook_field_formatter_settings_summary_alter().
|
||||
*/
|
||||
function {{ machine_name }}_field_formatter_settings_summary_alter(&$summary, $context) {
|
||||
// Append a message to the summary when an instance of foo_formatter has
|
||||
// mysetting set to TRUE for the current view mode.
|
||||
if ($context['formatter']->getPluginId() == 'foo_formatter') {
|
||||
if ($context['formatter']->getThirdPartySetting('my_module', 'my_setting')) {
|
||||
$summary[] = t('My setting enabled.');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Implements hook_field_formatter_third_party_settings_form().
|
||||
*/
|
||||
function {{ machine_name }}_field_formatter_third_party_settings_form(\Drupal\Core\Field\FormatterInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $view_mode, $form, \Drupal\Core\Form\FormStateInterface $form_state) {
|
||||
$element = [];
|
||||
// Add a 'my_setting' checkbox to the settings form for 'foo_formatter' field
|
||||
// formatters.
|
||||
if ($plugin->getPluginId() == 'foo_formatter') {
|
||||
$element['my_setting'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('My setting'),
|
||||
'#default_value' => $plugin->getThirdPartySetting('my_module', 'my_setting'),
|
||||
];
|
||||
}
|
||||
return $element;
|
||||
}
|
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/field_info_alter.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/d8/hook/field_info_alter.twig
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Implements hook_field_info_alter().
|
||||
*/
|
||||
function {{ machine_name }}_field_info_alter(&$info) {
|
||||
// Change the default widget for fields of type 'foo'.
|
||||
if (isset($info['foo'])) {
|
||||
$info['foo']['default widget'] = 'mymodule_widget';
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue