paid_ads-8.x-1.x-dev/modules/paid_ads_example/paid_ads_example.module

modules/paid_ads_example/paid_ads_example.module
<?php

/**
 * @file
 * Module hook and functions.
 */

use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;

/**
 * Implements hook_entity_view().
 */
function paid_ads_example_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
  if ($entity->getEntityTypeId() == 'node'
    && $entity->bundle() == 'advert'
    && $view_mode == 'teaser'
  ) {
    $entity->set('field_advert_last_view',
      date('Y-m-d\TH:i:s', time()))
      ->save();
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc