Verified Commit c7ebe845 authored by quietone's avatar quietone
Browse files

Issue #3488823 by mstrelan, shalini_jha, smustgrave, nicxvan: Add void return...

Issue #3488823 by mstrelan, shalini_jha, smustgrave, nicxvan: Add void return to @ingroup entity_crud hook implementations
parent b57dbb43
Loading
Loading
Loading
Loading
Loading
+0 −1302

File changed.

Preview size limit exceeded, changes collapsed.

+43 −43

File changed.

Preview size limit exceeded, changes collapsed.

+3 −3
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ public function rebuild(): void {
   * Removes deleted role from blocks that use it.
   */
  #[Hook('user_role_delete')]
  public function userRoleDelete($role) {
  public function userRoleDelete($role): void {
    foreach (Block::loadMultiple() as $block) {
      /** @var \Drupal\block\BlockInterface $block */
      $visibility = $block->getVisibility();
@@ -153,7 +153,7 @@ public function userRoleDelete($role) {
   * Implements hook_ENTITY_TYPE_delete() for menu entities.
   */
  #[Hook('menu_delete')]
  public function menuDelete(Menu $menu) {
  public function menuDelete(Menu $menu): void {
    if (!$menu->isSyncing()) {
      foreach (Block::loadMultiple() as $block) {
        if ($block->getPluginId() == 'system_menu_block:' . $menu->id()) {
@@ -169,7 +169,7 @@ public function menuDelete(Menu $menu) {
   * Delete the potential block visibility settings of the deleted language.
   */
  #[Hook('configurable_language_delete')]
  public function configurableLanguageDelete(ConfigurableLanguageInterface $language) {
  public function configurableLanguageDelete(ConfigurableLanguageInterface $language): void {
    // Remove the block visibility settings for the deleted language.
    foreach (Block::loadMultiple() as $block) {
      /** @var \Drupal\block\BlockInterface $block */
+8 −8
Original line number Diff line number Diff line
@@ -13,19 +13,19 @@
class BlockContentTestHooks {

  /**
   * Implements hook_block_content_view().
   * Implements hook_ENTITY_TYPE_view().
   */
  #[Hook('block_content_view')]
  public function blockContentView(array &$build, BlockContent $block_content, $view_mode) {
  public function blockContentView(array &$build, BlockContent $block_content, $view_mode): void {
    // Add extra content.
    $build['extra_content'] = ['#markup' => '<blink>Wow</blink>'];
  }

  /**
   * Implements hook_block_content_presave().
   * Implements hook_ENTITY_TYPE_presave().
   */
  #[Hook('block_content_presave')]
  public function blockContentPresave(BlockContent $block_content) {
  public function blockContentPresave(BlockContent $block_content): void {
    if ($block_content->label() == 'testing_block_content_presave') {
      $block_content->setInfo($block_content->label() . '_presave');
    }
@@ -40,10 +40,10 @@ public function blockContentPresave(BlockContent $block_content) {
  }

  /**
   * Implements hook_block_content_update().
   * Implements hook_ENTITY_TYPE_update().
   */
  #[Hook('block_content_update')]
  public function blockContentUpdate(BlockContent $block_content) {
  public function blockContentUpdate(BlockContent $block_content): void {
    // Determine changes on update.
    if ($block_content->getOriginal() && $block_content->getOriginal()->label() == 'test_changes') {
      if ($block_content->getOriginal()->label() != $block_content->label()) {
@@ -53,14 +53,14 @@ public function blockContentUpdate(BlockContent $block_content) {
  }

  /**
   * Implements hook_block_content_insert().
   * Implements hook_ENTITY_TYPE_insert().
   *
   * This tests saving a block_content on block_content insert.
   *
   * @see \Drupal\block_content\Tests\BlockContentSaveTest::testBlockContentSaveOnInsert()
   */
  #[Hook('block_content_insert')]
  public function blockContentInsert(BlockContent $block_content) {
  public function blockContentInsert(BlockContent $block_content): void {
    // Set the block_content title to the block_content ID and save.
    if ($block_content->label() == 'new') {
      $block_content->setInfo('BlockContent ' . $block_content->id());
+9 −9
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ public function theme() : array {
   * Implements hook_ENTITY_TYPE_create() for 'field_config'.
   */
  #[Hook('field_config_create')]
  public function fieldConfigCreate(FieldConfigInterface $field) {
  public function fieldConfigCreate(FieldConfigInterface $field): void {
    if ($field->getType() == 'comment' && !$field->isSyncing()) {
      // Assign default values for the field.
      $default_value = $field->getDefaultValueLiteral();
@@ -133,7 +133,7 @@ public function fieldConfigCreate(FieldConfigInterface $field) {
   * Implements hook_ENTITY_TYPE_update() for 'field_config'.
   */
  #[Hook('field_config_update')]
  public function fieldConfigUpdate(FieldConfigInterface $field) {
  public function fieldConfigUpdate(FieldConfigInterface $field): void {
    if ($field->getType() == 'comment') {
      // Comment field settings also affects the rendering of *comment* entities,
      // not only the *commented* entities.
@@ -145,7 +145,7 @@ public function fieldConfigUpdate(FieldConfigInterface $field) {
   * Implements hook_ENTITY_TYPE_insert() for 'field_storage_config'.
   */
  #[Hook('field_storage_config_insert')]
  public function fieldStorageConfigInsert(FieldStorageConfigInterface $field_storage) {
  public function fieldStorageConfigInsert(FieldStorageConfigInterface $field_storage): void {
    if ($field_storage->getType() == 'comment') {
      // Check that the target entity type uses an integer ID.
      $entity_type_id = $field_storage->getTargetEntityTypeId();
@@ -159,7 +159,7 @@ public function fieldStorageConfigInsert(FieldStorageConfigInterface $field_stor
   * Implements hook_ENTITY_TYPE_delete() for 'field_config'.
   */
  #[Hook('field_config_delete')]
  public function fieldConfigDelete(FieldConfigInterface $field) {
  public function fieldConfigDelete(FieldConfigInterface $field): void {
    if ($field->getType() == 'comment') {
      // Delete all comments that used by the entity bundle.
      $entity_query = \Drupal::entityQuery('comment')->accessCheck(FALSE);
@@ -190,7 +190,7 @@ public function nodeLinksAlter(array &$links, NodeInterface $node, array &$conte
   * Implements hook_entity_view().
   */
  #[Hook('entity_view')]
  public function entityView(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
  public function entityView(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode): void {
    if ($entity instanceof FieldableEntityInterface && $view_mode == 'rss' && $display->getComponent('links')) {
      /** @var \Drupal\comment\CommentManagerInterface $comment_manager */
      $comment_manager = \Drupal::service('comment.manager');
@@ -298,7 +298,7 @@ public function entityStorageLoad($entities, $entity_type): void {
   * Implements hook_entity_insert().
   */
  #[Hook('entity_insert')]
  public function entityInsert(EntityInterface $entity) {
  public function entityInsert(EntityInterface $entity): void {
    // Allow bulk updates and inserts to temporarily disable the
    // maintenance of the {comment_entity_statistics} table.
    if (\Drupal::state()->get('comment.maintain_entity_statistics') && ($fields = \Drupal::service('comment.manager')->getFields($entity->getEntityTypeId()))) {
@@ -310,7 +310,7 @@ public function entityInsert(EntityInterface $entity) {
   * Implements hook_entity_predelete().
   */
  #[Hook('entity_predelete')]
  public function entityPredelete(EntityInterface $entity) {
  public function entityPredelete(EntityInterface $entity): void {
    // Entities can have non-numeric IDs, but {comment} and
    // {comment_entity_statistics} tables have integer columns for entity ID, and
    // PostgreSQL throws exceptions if you attempt query conditions with
@@ -461,7 +461,7 @@ public function userCancel($edit, UserInterface $account, $method): void {
   * Implements hook_ENTITY_TYPE_predelete() for user entities.
   */
  #[Hook('user_predelete')]
  public function userPredelete($account) {
  public function userPredelete($account): void {
    $entity_query = \Drupal::entityQuery('comment')->accessCheck(FALSE);
    $entity_query->condition('uid', $account->id());
    $cids = $entity_query->execute();
@@ -482,7 +482,7 @@ public function ranking(): array {
   * Implements hook_ENTITY_TYPE_presave() for entity_view_display entities.
   */
  #[Hook('entity_view_display_presave')]
  public function entityViewDisplayPresave(EntityViewDisplayInterface $display) {
  public function entityViewDisplayPresave(EntityViewDisplayInterface $display): void {
    // Act only on comment view displays being disabled.
    if ($display->isNew() || $display->getTargetEntityTypeId() !== 'comment' || $display->status()) {
      return;
Loading