Skip to main content
Commonmark migration
Source Link

I want to do something when a node gets updated. To keep it simple, lets say display a drupal message.

hello_world.routing.yml

hello_world:
    path: /node/{node}
    defaults:
        _controller: Drupal\hello_world\Controller\HelloWorldController::hello_world_entity_update
    requirements:
        _permission: 'access content'

Not sure if the path should be /node/{node}/edit instead.

HelloWorldController.php

<?php
/**
 * @file
 * Contains \Drupal\hello_world\Controller\HelloController.
 */

namespace Drupal\hello_world\Controller;

use Drupal\Core\Controller\ControllerBase;

class HelloWorldController extends ControllerBase {

  public function hello_world_entity_update(Drupal\Core\Entity\EntityInterface $entity) { 
     
    drupal_set_message(t('Something @var just happened.', array('@var' => 'cool')));  
      
  }
}

Since hook_node_update() was depreciated, I assume we now have to use hook_entity_update().

I am not getting the message upon updating a node, what I'm I missing or doing wrong?


###Update

Update

Just so I don't confuse anyone. I was brainwashed into thinking I needed a routing file and a controller. All the D8 examples out there use them.

Since I was not creating any pages, turns out I did not need a routing.yml file nor a Controller.php file nor the /src folder. All I had to do is approach this like Drupal 7, all that I needed was the .info.yml file and a .module file to put the hook.

I want to do something when a node gets updated. To keep it simple, lets say display a drupal message.

hello_world.routing.yml

hello_world:
    path: /node/{node}
    defaults:
        _controller: Drupal\hello_world\Controller\HelloWorldController::hello_world_entity_update
    requirements:
        _permission: 'access content'

Not sure if the path should be /node/{node}/edit instead.

HelloWorldController.php

<?php
/**
 * @file
 * Contains \Drupal\hello_world\Controller\HelloController.
 */

namespace Drupal\hello_world\Controller;

use Drupal\Core\Controller\ControllerBase;

class HelloWorldController extends ControllerBase {

  public function hello_world_entity_update(Drupal\Core\Entity\EntityInterface $entity) { 
     
    drupal_set_message(t('Something @var just happened.', array('@var' => 'cool')));  
      
  }
}

Since hook_node_update() was depreciated, I assume we now have to use hook_entity_update().

I am not getting the message upon updating a node, what I'm I missing or doing wrong?


###Update

Just so I don't confuse anyone. I was brainwashed into thinking I needed a routing file and a controller. All the D8 examples out there use them.

Since I was not creating any pages, turns out I did not need a routing.yml file nor a Controller.php file nor the /src folder. All I had to do is approach this like Drupal 7, all that I needed was the .info.yml file and a .module file to put the hook.

I want to do something when a node gets updated. To keep it simple, lets say display a drupal message.

hello_world.routing.yml

hello_world:
    path: /node/{node}
    defaults:
        _controller: Drupal\hello_world\Controller\HelloWorldController::hello_world_entity_update
    requirements:
        _permission: 'access content'

Not sure if the path should be /node/{node}/edit instead.

HelloWorldController.php

<?php
/**
 * @file
 * Contains \Drupal\hello_world\Controller\HelloController.
 */

namespace Drupal\hello_world\Controller;

use Drupal\Core\Controller\ControllerBase;

class HelloWorldController extends ControllerBase {

  public function hello_world_entity_update(Drupal\Core\Entity\EntityInterface $entity) { 
     
    drupal_set_message(t('Something @var just happened.', array('@var' => 'cool')));  
      
  }
}

Since hook_node_update() was depreciated, I assume we now have to use hook_entity_update().

I am not getting the message upon updating a node, what I'm I missing or doing wrong?


Update

Just so I don't confuse anyone. I was brainwashed into thinking I needed a routing file and a controller. All the D8 examples out there use them.

Since I was not creating any pages, turns out I did not need a routing.yml file nor a Controller.php file nor the /src folder. All I had to do is approach this like Drupal 7, all that I needed was the .info.yml file and a .module file to put the hook.

Tweeted twitter.com/StackDrupal/status/1094385585270210561
deleted 1 character in body
Source Link
No Sssweat
  • 31.6k
  • 14
  • 55
  • 91

I want to do something when a node gets updated. To keep it simple, lets say display a drupal message.

hello_world.routing.yml

hello_world:
    path: /node/{node}
    defaults:
        _controller: Drupal\hello_world\Controller\HelloWorldController::hello_world_entity_update
    requirements:
        _permission: 'access content'

Not sure if the path should be /node/{node}/edit instead.

HelloWorldController.php

<?php
/**
 * @file
 * Contains \Drupal\hello_world\Controller\HelloController.
 */

namespace Drupal\hello_world\Controller;

use Drupal\Core\Controller\ControllerBase;

class HelloWorldController extends ControllerBase {

  public function hello_world_entity_update(Drupal\Core\Entity\EntityInterface $entity) { 
     
    drupal_set_message(t('Something @var just happened.', array('@var' => 'cool')));  
      
  }
}

Since hook_node_update() was depreciated, I assume we now have to use hook_entity_update().

I am not getting the message upon updating a node, what I'm I missing or doing wrong?


###Update

Just so I don't confuse anyone. I was brainwashed into thinking I needed a routing file and a controller. All the D8 examples out there use them.

Since I was not creating any pages, turns out I did not need a rountingrouting.yml file nor a Controller.php file nor the /src folder. All I had to do is approach this like Drupal 7, all that I needed was the .info.yml file and a .module file to put the hook.

I want to do something when a node gets updated. To keep it simple, lets say display a drupal message.

hello_world.routing.yml

hello_world:
    path: /node/{node}
    defaults:
        _controller: Drupal\hello_world\Controller\HelloWorldController::hello_world_entity_update
    requirements:
        _permission: 'access content'

Not sure if the path should be /node/{node}/edit instead.

HelloWorldController.php

<?php
/**
 * @file
 * Contains \Drupal\hello_world\Controller\HelloController.
 */

namespace Drupal\hello_world\Controller;

use Drupal\Core\Controller\ControllerBase;

class HelloWorldController extends ControllerBase {

  public function hello_world_entity_update(Drupal\Core\Entity\EntityInterface $entity) { 
     
    drupal_set_message(t('Something @var just happened.', array('@var' => 'cool')));  
      
  }
}

Since hook_node_update() was depreciated, I assume we now have to use hook_entity_update().

I am not getting the message upon updating a node, what I'm I missing or doing wrong?


###Update

Just so I don't confuse anyone. I was brainwashed into thinking I needed a routing file and a controller. All the D8 examples out there use them.

Since I was not creating any pages, turns out I did not need a rounting.yml file nor a Controller.php file nor the /src folder. All I had to do is approach this like Drupal 7, all that I needed was the .info.yml file and a .module file to put the hook.

I want to do something when a node gets updated. To keep it simple, lets say display a drupal message.

hello_world.routing.yml

hello_world:
    path: /node/{node}
    defaults:
        _controller: Drupal\hello_world\Controller\HelloWorldController::hello_world_entity_update
    requirements:
        _permission: 'access content'

Not sure if the path should be /node/{node}/edit instead.

HelloWorldController.php

<?php
/**
 * @file
 * Contains \Drupal\hello_world\Controller\HelloController.
 */

namespace Drupal\hello_world\Controller;

use Drupal\Core\Controller\ControllerBase;

class HelloWorldController extends ControllerBase {

  public function hello_world_entity_update(Drupal\Core\Entity\EntityInterface $entity) { 
     
    drupal_set_message(t('Something @var just happened.', array('@var' => 'cool')));  
      
  }
}

Since hook_node_update() was depreciated, I assume we now have to use hook_entity_update().

I am not getting the message upon updating a node, what I'm I missing or doing wrong?


###Update

Just so I don't confuse anyone. I was brainwashed into thinking I needed a routing file and a controller. All the D8 examples out there use them.

Since I was not creating any pages, turns out I did not need a routing.yml file nor a Controller.php file nor the /src folder. All I had to do is approach this like Drupal 7, all that I needed was the .info.yml file and a .module file to put the hook.

added 128 characters in body
Source Link
No Sssweat
  • 31.6k
  • 14
  • 55
  • 91

I want to do something when a node gets updated. To keep it simple, lets say display a drupal message.

hello_world.routing.yml

hello_world:
    path: /node/{node}
    defaults:
        _controller: Drupal\hello_world\Controller\HelloWorldController::hello_world_entity_update
    requirements:
        _permission: 'access content'

Not sure if the path should be /node/{node}/edit instead.

HelloWorldController.php

<?php
/**
 * @file
 * Contains \Drupal\hello_world\Controller\HelloController.
 */

namespace Drupal\hello_world\Controller;

use Drupal\Core\Controller\ControllerBase;

class HelloWorldController extends ControllerBase {

  public function hello_world_entity_update(Drupal\Core\Entity\EntityInterface $entity) { 
     
    drupal_set_message(t('Something @var just happened.', array('@var' => 'cool')));  
      
  }
}

Since hook_node_update() was depreciated, I assume we now have to use hook_entity_update().

I am not getting the message upon updating a node, what I'm I missing or doing wrong?


###Update

Just so I don't confuse anyone. Since I I was not creating any pagesbrainwashed into thinking I needed a routing file and a controller. All the D8 examples out there use them.

Since I was not creating any pages, turns out I did not need a rounting.yml file nor a Controller.php file nor the /src folder. All I had to do is approach this like Drupal 7, all that I needed was the .info.yml file and a .module file to put the hook.

I want to do something when a node gets updated. To keep it simple, lets say display a drupal message.

hello_world.routing.yml

hello_world:
    path: /node/{node}
    defaults:
        _controller: Drupal\hello_world\Controller\HelloWorldController::hello_world_entity_update
    requirements:
        _permission: 'access content'

Not sure if the path should be /node/{node}/edit instead.

HelloWorldController.php

<?php
/**
 * @file
 * Contains \Drupal\hello_world\Controller\HelloController.
 */

namespace Drupal\hello_world\Controller;

use Drupal\Core\Controller\ControllerBase;

class HelloWorldController extends ControllerBase {

  public function hello_world_entity_update(Drupal\Core\Entity\EntityInterface $entity) { 
     
    drupal_set_message(t('Something @var just happened.', array('@var' => 'cool')));  
      
  }
}

Since hook_node_update() was depreciated, I assume we now have to use hook_entity_update().

I am not getting the message upon updating a node, what I'm I missing or doing wrong?


###Update

Just so I don't confuse anyone. Since I was not creating any pages, turns out I did not need a rounting.yml file nor a Controller.php file nor the /src folder. All I had to do is approach this like Drupal 7, all that I needed was the .info.yml file and a .module file to put the hook.

I want to do something when a node gets updated. To keep it simple, lets say display a drupal message.

hello_world.routing.yml

hello_world:
    path: /node/{node}
    defaults:
        _controller: Drupal\hello_world\Controller\HelloWorldController::hello_world_entity_update
    requirements:
        _permission: 'access content'

Not sure if the path should be /node/{node}/edit instead.

HelloWorldController.php

<?php
/**
 * @file
 * Contains \Drupal\hello_world\Controller\HelloController.
 */

namespace Drupal\hello_world\Controller;

use Drupal\Core\Controller\ControllerBase;

class HelloWorldController extends ControllerBase {

  public function hello_world_entity_update(Drupal\Core\Entity\EntityInterface $entity) { 
     
    drupal_set_message(t('Something @var just happened.', array('@var' => 'cool')));  
      
  }
}

Since hook_node_update() was depreciated, I assume we now have to use hook_entity_update().

I am not getting the message upon updating a node, what I'm I missing or doing wrong?


###Update

Just so I don't confuse anyone. I was brainwashed into thinking I needed a routing file and a controller. All the D8 examples out there use them.

Since I was not creating any pages, turns out I did not need a rounting.yml file nor a Controller.php file nor the /src folder. All I had to do is approach this like Drupal 7, all that I needed was the .info.yml file and a .module file to put the hook.

added 319 characters in body
Source Link
No Sssweat
  • 31.6k
  • 14
  • 55
  • 91
Loading
added 2 characters in body
Source Link
No Sssweat
  • 31.6k
  • 14
  • 55
  • 91
Loading
added 9 characters in body
Source Link
No Sssweat
  • 31.6k
  • 14
  • 55
  • 91
Loading
Source Link
No Sssweat
  • 31.6k
  • 14
  • 55
  • 91
Loading