node保存前に色々やる方法

カテゴリ コンテンツの作成 コアバージョン 8.4x 関連モジュール node

hook_node_presave()

/**
 * @param \Drupal\node\NodeInterface $node
 */
function yourmodule_node_presave(\Drupal\node\NodeInterface $node) {
  switch ($node->getType()) {
    case 'your_content_type':
      // Title.
      $file_name = $imc->getTitle();
      $node->setTitle($node->getTitle() . ' is mine');
      $node->set('field_xxxxxxx', $node->get('field_yyyyyyy')->value);
      break;
  }
}

OTHER FAQ