uber_publisher_daily_cartoons-8.x-6.x-dev/modules/uber_publisher_monthly_caricature/uber_publisher_monthly_caricature.module
modules/uber_publisher_monthly_caricature/uber_publisher_monthly_caricature.module
<?php
/**
* @file
* Contains uber_publisher_monthly_caricature.module.
*/
use Drupal\Core\Entity\EntityInterface;
/**
* Implements hook_node_presave().
*/
function uber_publisher_monthly_caricature_node_presave(EntityInterface $entity) {
if ($entity->getType() == 'caricature') {
if (!empty($entity->get('field_date')->getValue()[0]['value'])) {
$value = date("Ym", strtotime($entity->get('field_date')->getValue()[0]['value']));
$entity->set('field_year_month', $value);
}
}
}
