Skip to main content
Appic Softwares Logo - Custom Software and App Development Company
  • AI/ML
  • Services
  • Industries
  • Platform
  • Hire Talent
  • Our Company
  • Blog
Contact Us
HomeBlogDrupal

What Are Action Plugins In Drupal? Know Everthing Here 2025

Nitesh Jain
Jan 2, 2024
Back to Blog

Table of Contents

  • Action Plugin Overview
  • Advantages Of Action Plugin In Drupal
  • Custom Actions Plugin
  • Archive Node Action
  • Custom Actions Existing Enable Module
  • Conclusion

Share this

What Are Action Plugins In Drupal? Know Everthing Here 2025

Explore the versatile landscape of Drupal’s Action Plugins in 2024, uncovering their role in extending functionality and promoting code reuse. From seamless integration to scalability, our guide delves into the intricacies of Action Plugins, providing a comprehensive understanding of how they enhance the development process within the dynamic Drupal framework. Let’s delve deeper into the world of Action Plugins and harness their power for an optimized web development experience.

Action Plugin Overview

Drupal’s Actions module is a core module that lets developers and site builders define actions and triggers to build automated workflows. A set of operations or tasks that can be carried out on a site are referred to as actions in Drupal. Sending an email, posting content, or updating a database record are a few examples of actions.

Advantages Of Action Plugin In Drupal

Action plugins in Drupal offer several advantages, enhancing the functionality and flexibility of the platform:

  • Extensibility: Action plugins provide a modular and extensible way to add custom actions to Drupal. Developers can create their own plugins to extend the functionality of the system without altering core code.
  • Reusability: Action plugins follow a reusable design pattern, allowing developers to use the same action in multiple contexts. This promotes code reuse and simplifies the development process.
  • Configurability: Action plugins are highly configurable, enabling site administrators to customize and configure actions through the Drupal administration interface. This flexibility simplifies the management of various actions without re
    quiring extensive coding.
  • Consistency: Action plugins contribute to maintaining consistency in code and user interfaces. By adhering to Drupal’s plugin system, developers can ensure that their custom actions align with Drupal’s coding standards and best practices.
  • Integration with Rules: Action plugins seamlessly integrate with the Rules module in Drupal. This integration allows developers and site builders to create complex workflows and trigger actions based on specific conditions, enhancing the overall functionality of the website.
  • Scalability: As part of Drupal’s plugin system, action plugins contribute to the scalability of the platform. Developers can efficiently scale their applications by creating and utilizing plugins tailored to their specific needs.
  • Community Support: Action plugins benefit from the Drupal community’s collective expertise. The community actively contributes to the development and improvement of plugins, ensuring that they stay current, secure, and aligned with the latest Drupal updates.

Custom Actions Plugin

Activities If the action is configurable, extend Drupal\Core\Action\ActionBase or Drupal\Core\Action\ConfigurableActionBase and use the annotation class Drupal\Core\Annotation\Action.

Plugin Annotation contains the definition of the Action Plugin. There are three necessary keys for it:

/**

* Provides an Archive Node Action.

*

* @Action(

*   id = “ttn_archive_node”,

*   label = @Translation(“Archive Node”),

*   type = “node”,

*   category = @Translation(“Custom”)

* )

*/

id: The Action Plugin’s ID; label: The Action Plugin’s name; type: The Entity type that the Action Plugin falls under; – (Optional) Action Plugin Category

Archive Node Action

This is an easy action that doesn’t need to be configured. When it runs, the node’s alias is changed to /archive//. Additionally, it puts the word “Archive” in front of the title. Lastly, it turns off the promoted and sticky flags.

<?php

namespace Drupal\ttn\Plugin\Action;

use Drupal\Core\Action\ActionBase;

use Drupal\Core\Session\AccountInterface;

use Drupal\Core\Plugin\ContainerFactoryPluginInterface;

use Symfony\Component\DependencyInjection\ContainerInterface;

use Drupal\pathauto\PathautoState;

/
**

 * Provides an Archive Node Action.

 *

 * @Action(

 *   id = “ttn_archive_node”,

 *   label = @Translation(“Archive Node”),

 *   type = “node”,

 *   category = @Translation(“Custom”)

 * )

 */

class ArchiveNode extends ActionBase implements ContainerFactoryPluginInterface {

  /**

   * The Messenger service.

   *

   * @var \Drupal\Core\Messenger\MessengerInterface

   */

  protected $messenger;

  /**

   * Logger service.

   *

   * @var \Drupal\Core\Logger\LoggerChannelFactoryInterface

   */

  protected $logger;

 

  /**

   * The path alias manager.

   *

 
  * @var \Drupal\path_alias\AliasManagerInterface

   */

  protected $aliasManager;

 

  /**

   * Language manager for retrieving the default Langcode.

   *

   * @var \Drupal\Core\Language\LanguageManagerInterface

   */

  protected $languageManager;

 

  /**

   * {@inheritdoc}

   */

  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {

    $instance = new static($configuration, $plugin_id, $plugin_definition);

    $instance->logger = $container->get(‘logger.factory’)->get(‘ttn’);

    $instance->messenger = $container->get(‘messenger’);

    $instance->aliasManager = $container->get(‘path_alias.manager’);

    $instance->languageManager = $container->get(‘language_manager’);

    return $instance;

  }

 

  /**

   * {@inheritdoc}

   */

  public function access($node, AccountInterface $account = NULL, $return_as_object = FALSE) {

    /** @var \Drupal\node\NodeInterface $node */

    $access = $node->access(‘update’, $account, TRUE)

      ->andIf($node->title->access(‘edit’, $account, TRUE));

    return $return_as_object ? $access : $access->isAllowed();

  }

 

   /**

   * {@inheritdoc}

   */

  public function execute($node = NULL) {

 

    /** @var \Drupal\node\NodeInterface $node */

 

    $language = $this->languageManager->getCurrentLanguage()->getId();

 

    $old_alias = $this->aliasManager->getAliasByPath(‘/node/’ . $node->id(), $language);

 

    $title = $node->getTitle();

    $date = $node->created->value;

    $year = date(‘Y’, $date);

    $new_title = $this->t(‘[Archive] | @title’, [‘@title’ => $title]);

    $node->setTitle($new_title);

    $node->setSticky(FALSE);

    $node->setPromoted(FALSE);

 

    $new_alias = ‘/archive/’ . $year . $old_alias;

    $node->set(“path”, [

      ‘alias’ => $new_alias,

      ‘langcode’ => $language,

      ‘pathauto’ => PathautoState::SKIP,

    ]);

    $node->save();

    $message = $this->t(‘Node with NID : @id Archived.’, [‘@id’ => $node->id()]);

    $this->logger->notice($message);

    $this->messenger->addMessage($message);

  }

 

}

 

You must add system.action.<plugin_id>.yml, which is located in config/install, to obtain Action Plugin Discoverable.

The following illustrates the.yml file’s structure:

 

langcode: en

status: true

id: ttn_archive_node

label: ‘Archive Node’

type: node

plugin: ttn_archive_node

 

The /admin/content page displays the created Action Plugin.

Custom Actions Existing Enable Module

that is kept in the install/config folder. Create a hook_update_N() file and use it.

<?php 

// Install config. 

function ttn_update_9501(&$sandbox){ 

  $config_installer = \Drupal::service(‘config.installer’); 

  $config_installer->installDefaultConfig(‘module’, ‘ttn’);

}

 

Run update.php

Conclusion

Drupal Action Plugins are an effective tool that gives developers an extensible and adaptable way to improve functionality and optimize workflows. Their adaptability and smooth integration add to the Drupal ecosystem’s dynamic and effective web development experience.

We hope that this tutorial has helped you with Drupal Core with Composer. Additionally, Appic Softwares is a company you should check out if you want to hire Drupal developers on a devoted basis.

You can employ our team of knowledgeable Drupal developers to handle your software.

So, what are you waiting for?

Hire them now!

Get Free Consultation Now!

Fill out the form below to get started.

Phone

Related Articles

How AI Agents Are Transforming Financial Markets
2/18/2026

How AI Agents Are Transforming Financial Markets

Financial markets have constantly changed in response to advancements. Electronic trading systems, mobile banking, and other technologies continue to revolutionize how money changes hands. The biggest driver of this change is AI agents in finance. These intelligent systems are no longer just experimental tools being tested by tech companies. They are now the backbone of […]

Read More
7 Use Cases of Predictive Analytics In Finance
2/17/2026

7 Use Cases of Predictive Analytics In Finance

Today, the financial service industry is no longer reliant on simply looking back at previous years of data. Institutions expect that they will be able to not only predict and mitigate risks, but also forecast potential market fluctuations, and provide personalized customer experiences in real time through predictive analytics. Predictive analytics is an important area […]

Read More
OpenAI vs Claude for Enterprise AI Applications
2/16/2026

OpenAI vs Claude for Enterprise AI Applications

The use of Enterprise AI Applications is no longer considered just an experiment or “proof of concept”, but instead they are now vital components of a business as it relates to top line revenue generation and the customer experience, as well as the overall operational effectiveness and the long-term strategy of the company. Companies across […]

Read More

Our Drupal Services

Mobile App Development →AI Development Services →Web Development →E-Commerce Development →

Share Your Ideas Here!

We are all ears!

Get in touch with us

  • Contact info type iconsales@appicsoftwares.com
  • Contact info type icon
    +91 - 8233801424,+91 - 9887354080
  • Contact info type iconlive:appicsoftwares
  • Contact info type icon41/11 Varun Path, New Sanganer Road, Jaipur, Rajasthan
  • Follow Us

Your Partner Everywhere!

Appic Softwares Jaipur office illustration

India

41/11 Varun Path, New Sanganer Road, Jaipur, Rajasthan

Appic Softwares USA office illustration

USA

5 Cowboys Way, Suite 300, Frisco, TX 75034, USA

Appic Softwares Germany office illustration

Germany

Magdalenenstraße 34, 80638 München, Germany

About

  • Our company
  • Blog
  • Portfolio
  • Case Studies
  • Let's connect
  • Career

Services

  • iOS App Development
  • Android App Development
  • Software Development
  • Flutter App Development
  • Mobile App Development
  • Ionic development
  • Maintenance & Support

Portfolio

  • Bridl
  • Obdoor
  • Laiqa
  • Rocca Box
  • Plantify
  • City of Cars
  • No-limit-Qr
  • Sync Remote

Platform

  • Artificial Intelligence
  • Blockchain
  • IOT
  • MVP
  • Angular
  • PWA
  • Devops
  • Drupal

Industries

  • Restaurant
  • Healthcare
  • Real estate
  • On-demand
  • Travel
  • Education
  • Fitness
  • Pet Care

Recognized For Excellence

GoodFirms Award
TopDevelopers.co Award
Clutch Leader Award
DesignRush Award
SelectedFirms Award

© 2026 Appic Softwares. All Rights Reserved. |Privacy Policy