You are here

public function CreateActivityAction::create in Open Social 10.3.x

Same name and namespace in other branches
  1. 8.9 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php \Drupal\activity_basics\Plugin\ActivityAction\CreateActivityAction::create()
  2. 8 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php \Drupal\activity_basics\Plugin\ActivityAction\CreateActivityAction::create()
  3. 8.2 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php \Drupal\activity_basics\Plugin\ActivityAction\CreateActivityAction::create()
  4. 8.3 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php \Drupal\activity_basics\Plugin\ActivityAction\CreateActivityAction::create()
  5. 8.4 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php \Drupal\activity_basics\Plugin\ActivityAction\CreateActivityAction::create()
  6. 8.5 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php \Drupal\activity_basics\Plugin\ActivityAction\CreateActivityAction::create()
  7. 8.6 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php \Drupal\activity_basics\Plugin\ActivityAction\CreateActivityAction::create()
  8. 8.7 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php \Drupal\activity_basics\Plugin\ActivityAction\CreateActivityAction::create()
  9. 8.8 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php \Drupal\activity_basics\Plugin\ActivityAction\CreateActivityAction::create()
  10. 10.0.x modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php \Drupal\activity_basics\Plugin\ActivityAction\CreateActivityAction::create()
  11. 10.1.x modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php \Drupal\activity_basics\Plugin\ActivityAction\CreateActivityAction::create()
  12. 10.2.x modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php \Drupal\activity_basics\Plugin\ActivityAction\CreateActivityAction::create()

Creates a new message on the action with some logic behind it.

Overrides ActivityActionBase::create

File

modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php, line 21

Class

CreateActivityAction
Provides a 'CreateActivityAction' activity action.

Namespace

Drupal\activity_basics\Plugin\ActivityAction

Code

public function create($entity) {
  if ($this
    ->isValidEntity($entity)) {

    // For nodes we make an exception, since they are potentially placed in
    // groups, which we cannot know here yet.
    if ($entity instanceof NodeInterface) {
      $data['entity_id'] = $entity
        ->id();
      $queue = \Drupal::queue('activity_logger_message');
      $queue
        ->createItem($data);
    }
    else {
      $this
        ->createMessage($entity);
    }
  }
}