Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ...
- class ContentTitle extends RulesActionBase {
- protected function doExecute(EntityInterface $entity) {
- $entity_id = $entity->id(); // Getting dynamic entity ID
- $controller = Drupal::entityManager()->getStorage('node');
- $node = $controller->load($entity_id);
- $title = $entity->label();
- $item = $node->get('field_xyz')->value;
- $new_title = "Title is " . $title . $item;
- Drupal::logger('custom_rules')->notice('new_title: ' . $new_title);
- $data = array(
- 'type' => 'custom_content',
- 'title' => [
- 'value' => $new_title,
- ]
- );
- $node = Drupal::entityManager()
- ->getStorage('node')
- ->create($data);
- $node->save();
- }
- }
- use DrupalnodeEntityNode;
- class ContentTitle extends RulesActionBase {
- protected function doExecute(EntityInterface $entity) {
- $entity_id = $entity->id(); // Getting dynamic entity ID
- $controller = Drupal::entityManager()->getStorage('node');
- $node = $controller->load($entity_id);
- $title = $entity->label();
- $item = $node->get('field_xyz')->value;
- $new_title = "Title is " . $title . $item;
- Drupal::logger('custom_rules')->notice('new_title: ' . $new_title);
- $node = Node::create([
- 'type' => 'content_type',
- 'title' => $new_title,
- ]);
- $node->save();
- }
- }
- $node->set('title', $new_title);
- $node->save();
Add Comment
Please, Sign In to add comment