CreateActivityAction.php in Open Social 8.9
Same filename and directory in other branches
- 8 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php
- 8.2 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php
- 8.3 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php
- 8.4 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php
- 8.5 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php
- 8.6 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php
- 8.7 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php
- 8.8 modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php
- 10.3.x modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php
- 10.0.x modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php
- 10.1.x modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php
- 10.2.x modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.php
File
modules/custom/activity_basics/src/Plugin/ActivityAction/CreateActivityAction.phpView source
<?php
namespace Drupal\activity_basics\Plugin\ActivityAction;
use Drupal\activity_creator\Plugin\ActivityActionBase;
use Drupal\node\NodeInterface;
/**
* Provides a 'CreateActivityAction' activity action.
*
* @ActivityAction(
* id = "create_entitiy_action",
* label = @Translation("Action that is triggered when a entity is created"),
* )
*/
class CreateActivityAction extends ActivityActionBase {
/**
* {@inheritdoc}
*/
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);
}
}
}
}
Classes
Name | Description |
---|---|
CreateActivityAction | Provides a 'CreateActivityAction' activity action. |