I created a flag to flag the stores. I want when a user updates a store, the store is automatically flagged. The code below does not work and there is no error message.
I don't want to use the Rules module.
How do I flag the update store automatically?
use Drupal\flag\FlaggingInterface;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\user\Entity\User;
use Drupal\commerce_store\Entity\Store;
use Drupal\commerce_product\Entity\Product;
use Drupal\group\Entity\Group;
use Drupal\node\Entity\Node;
use Drupal\comment\Entity\Comment;
/**
* Flag store.
*/
function admin_task_notify_commerce_store_update(Store $commerce_store) {
$flag_id = 'report_store';
$flag_service = \Drupal::service('flag');
$flag = $flag_service->getFlagById($flag_id);
$flag_service->flag($flag, $commerce_store);
}
admin_task_notify_entity_update()
is being called?