Questions tagged [plugins]

Use it for Drupal 8 plugins; for plugins implemented from the Views module use views, ctools for Chaos tool suite plugins.

Filter by
Sorted by
Tagged with
8 votes
1 answer
3k views

How set a time type field programmatically?

I create a custom content entity type. I want one field for the event time. Since there is no time field, but a dataTime_type, I create a plugin for a custom field : FieldType : TimeItem.php /** ...
Kevin's user avatar
  • 2,556
7 votes
2 answers
454 views

What's the difference between using $this->t('text') and t('text') in a block plugin

I've noticed in many tutorials for constructing block plugins, $this->t('text') is used to create translatable text, especially in the block form function. However using t('text') doesn't ...
Amy's user avatar
  • 5,680
7 votes
2 answers
8k views

Need to override single Drupal 8 plugin function

What I want to do is edit what is displayed in the autocomplete/drop selects for an entity reference. Basically instead of just [title] I want to show [title] - [other_distinguishing_field]. I know ...
Lee Cocklin's user avatar
6 votes
1 answer
4k views

Loading a particular plugin definition by ID

I want to load a plugin definition by its string id within a controller extending ControllerBase. What is the relevant service or class I am looking for?
Kevin's user avatar
  • 27.8k
6 votes
1 answer
3k views

How do I replace a plugin?

Let's say that I want to replace the block_content_type plugin of the core block_content module to ad some features while not having to rewrite a whole module to achieve this. It is very easy to ...
Eric MORAND's user avatar
6 votes
4 answers
3k views

How do I get the current node from a Block module?

I'm looking to create a block that renders differently, depending on the content (metadata, really) of the node in which it is embedded. The “Title” block is a good example of what I'm trying to do, ...
alficles's user avatar
  • 161
6 votes
1 answer
8k views

Twig Template for a Custom Block Plugin

I'd like to have a custom twig template for custom block plugins from my custom module. My custom block HeaderText contains public function build() { return array( '#title' => 'Test', ...
Amy's user avatar
  • 5,680
6 votes
1 answer
2k views

Plugin versus Module

Drupal has many specific terms that can have different meanings depending on usage (e.g. view vs. a Drupal View). It looks like another in Drupal 8 is plugin & module. Generically, both seem to ...
Shawn Conn's user avatar
  • 26.9k
6 votes
2 answers
3k views

Restful permission is required

I've created a @RestResource plugin to provide a REST endpoint to get some data, but when I try a GET from Postman it shows this error: { "message": "The 'restful get ...
Ivan Chavarro's user avatar
5 votes
2 answers
480 views

How can I let a plugin depend on another module?

Is it possible to let a plugin depend on a module (other than the declaring one)? Use case: I want to create a field widget plugin that should depend on the 'date_all_day' contrib module, but I don't ...
donquixote's user avatar
  • 3,642
5 votes
1 answer
6k views

How to create my own custom simple action in D8?

I'm creating a view that is used to review migrated content that was flagged for review during the migration process. I want to provide a bulk action on this view that allows the user to select a ...
Brian's user avatar
  • 1,082
5 votes
2 answers
1k views

Debug plugin discovery

A plugin that I have written is not being discovered. For eg : https://www.drupal.org/node/2847639 Is there a general suggestion for debugging failing plugin discovery?
Gokul N K's user avatar
  • 6,713
5 votes
1 answer
813 views

Block Plugin Derivatives Discovery

I need some help with my code. I am creating blocks dynamically using the plugin derivatives. I store some form data in a database table, then I display it in each block separately, depending on it's ...
Postovan Dumitru's user avatar
5 votes
3 answers
11k views

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "<whatever>" plugin does not exist [closed]

After updading a Drupal site from 8.6.16 to 8.7.1 (PostgreSQL 9.6.13 , Nginx) I get this error in almost every operation (creating a view , installing a module, creating a content type, creating a ...
Pin's user avatar
  • 171
5 votes
1 answer
5k views

How do I add extra/custom plugins in CKEditor?

I am copying the templates plugin http://ckeditor.com/addon/templates I put it in my D8 folder /core/asstes/vendor/ckeditor/plugins I do a 'drush cr' I do not see the templates plugin under ...
user551799's user avatar
4 votes
2 answers
2k views

How to override existing plugin?

Considering Drupal\search_api\Plugin\views\query\SearchApiQuery class, I want to override shouldAbort() method there. I have tried to create a new plugin class in my custom mod: namespace Drupal\...
Codium's user avatar
  • 4,955
4 votes
2 answers
3k views

How do I inject a dependency into a @FieldType plugin?

I am implementing custom fields in Drupal 8 (types, widgets, formatters). @FieldType plugins are instantiated by their respective plugin manager (\Drupal\Core\Field\FieldTypePluginManager) which does ...
Stefanos Petrakis's user avatar
4 votes
0 answers
2k views

Difference between service and plugin?

After have read some link i'm still confused about the difference between service and plugin. I am not speaking about plugin like block or Field formater etc... i would like to take an example : I ...
Kevin's user avatar
  • 2,556
3 votes
1 answer
2k views

Adding fields to entity (menu_link_content) form (menu_link_edit)

I have been diving into Drupal 8, it's plugin system and all the new stuff for some days now. I hope that I understood the basics and now I would like to start out with a new module. The module ...
philipp's user avatar
  • 211
3 votes
1 answer
486 views

Removing phantom plugin from database

On several sites I've worked on, for whatever reason before I put my hands on it, the database seems to register a plugin that is no longer in config or code. This usually goes as follows: [error] ...
TripodC's user avatar
  • 41
3 votes
2 answers
1k views

How to correctly modify Taxonomy Term selection Plugin

I want some slight modifications of Drupal\taxonomy\Plugin\EntityReferenceSelection\TermSelection::getReferenceableEntities(), for example to not use - to indicate term hierarchy. How can that be ...
LarS's user avatar
  • 665
3 votes
1 answer
1k views

Basefield 'string' shown as select list widget in entity form

I've got a custom entity ('content_sharing') and defined one of the fields as $fields['entity_definition'] = BaseFieldDefinition::create('string').... The create-form I'm showing the user is loaded ...
theuni's user avatar
  • 855
3 votes
1 answer
58 views

Field modification using PHP

I have a content type which contains field_state. The nodes of this content type store the two letter abbreviation for the state in each node using field_state. OH is Ohio, CA is California and so ...
Greg Sims's user avatar
  • 573
3 votes
1 answer
210 views

Is possible to have OR logic on block visibility?

I am on D10. I need to place several blocks on Block Layout having different visibility conditions: for example one of them should visible BOTH in the home page and in every article of the site. I'd ...
Giuseppe's user avatar
  • 939
3 votes
1 answer
743 views

Execute actions (actions module not rules module) programatically

How can an action from the actions module be executed programatically? In D7 there was actions_do() but in D8 actions are plugins or configuration entities according to https://www.drupal.org/node/...
Sebastian's user avatar
3 votes
1 answer
650 views

Entities and Plugins. What's the relationship?

As a fairly experienced Drupal 7 developer, I'm thrilled by all the new goodies in Drupal 8, but haven't quite figured out the relationship between entities and the new plugin system. I've followed a ...
Beau's user avatar
  • 968
3 votes
1 answer
110 views

Custom field formatter fails in create()

PHPStorm, PHP 7.4 IDE highlights $container->get('date.formatter'), with "Expected parameter of type '\Drupal\Core\Datetime\DateFormatterInterface', 'object' provided" This function is ...
Scott's user avatar
  • 41
3 votes
1 answer
884 views

custom action plugin with ConfigurationForm

I am trying to create a custom action with Configuration Form Field . I am able to create Action and it is being displayed on content page ( /admin/content ) , but I am not able to find the path to ...
miststudent2011's user avatar
3 votes
1 answer
4k views

How to fix “Cannot read property 'icons' of null” error?

First of all, I'd like to mention this answer is not related, I'm using Drupal 8.6.1. I'm trying to create a CKEditor plugin with a new button. In the /admin/config/content page I get the error but ...
Kwadz's user avatar
  • 489
3 votes
1 answer
103 views

How can I determine which module is associated with a field plugin?

I'd like to implement an entity hook, and act on all fields defined by Computed Field FieldType plugins. So I either need a list of all FieldType plugins provided by the module or need to know which ...
colan's user avatar
  • 2,169
3 votes
1 answer
2k views

How to get an instance of a plugin

I am attempting to use a pre-configured instance of a plugin. The plugin is of type @CommercePaymentGateway. I am currently trying to use something like: /** @var PaymentGatewayManager $manager */...
Chris Rockwell's user avatar
3 votes
2 answers
3k views

CKEditor custom plugin to add richcombo select list

I am building a CKEditor plugin for Drupal 8. I've done plugins that show a button in the editor toolbar, but this one should render a select list. The list is not showing up in the configuration page ...
kaldimar's user avatar
  • 309
3 votes
1 answer
244 views

How to set the correct RSS row plugin?

I need to add an image to the RSS feed. So I create a new row plugin for the RSS and it extends RssFields row plugin. /** * Renders an RSS item based on fields. * * @ViewsRow( * id = "...
ilazgo's user avatar
  • 131
3 votes
1 answer
913 views

How do I make an ajax callback in Field Plugin formElement() reload form?

I've created a custom field as a module Plugin and have the following code in the formElement() method of the field's Widget.php. The intention is to populate options in the second select element ...
Sunset Bill's user avatar
3 votes
1 answer
1k views

How does a module tell Drupal which mail plugin should be used?

How does a module tell Drupal which mail plugin should be used? The SMTP Authentication Support module uses the following code in the submission handler of its settings form. $values = $form_state-&...
apaderno's user avatar
  • 97.4k
3 votes
1 answer
852 views

Migrating into custom node type with multi value field

I'm doing a migration into D8, and I'm migrating into a custom video player field with multiple values. Here's the schema for the field as defined in its plugin: public static function schema(...
wonder95's user avatar
  • 1,201
2 votes
1 answer
195 views

How to override a contrib module's FieldType plugin?

I'm trying to override a FieldType plugin provided by the Field Encrypt module: class EncryptedFieldStorageItem extends FieldItemBase { I created my own class, MyModuleEncryptedFieldStorageItem, and ...
Patrick Kenny's user avatar
2 votes
1 answer
596 views

How do I create a block in a module that can be referenced via an entity reference field?

I'd like to be able to reference my programmed block as a field in a paragraphs. I've Generated a module with drupal console - drupal generate:module Used the template for a block from the example ...
Interlated's user avatar
  • 1,413
2 votes
1 answer
1k views

Migrating content with referenced taxonomy field is to be migrated by term name

Is it possible to migrate content with term reference fields, but instead of referencing terms by their tid they are referenced by their term name? instead of this: field_tags: plugin: ...
Che Figueroa's user avatar
2 votes
2 answers
2k views

Destination fields not filled from custom migration process plugin

I'm working on a D6 -> D8 migration, and my destination has a custom video upload field (field_video_upload) that contains three pieces of data: video, thumbnail, and poster (field_video_upload_video, ...
wonder95's user avatar
  • 1,201
2 votes
1 answer
550 views

Cannot get values in 3rd level SubFormState

I have a block that embeds another plugins into itself and this includes configuration form. I can properly handle the form structure but when it comes to validation I am not able to access the values ...
user avatar
2 votes
1 answer
2k views

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "node_type" plugin does not exist

I have upgraded drupal 9 to drupal 10 and now while creating a content page or editing the existing content page it is throwing error in error logs Drupal\Component\Plugin\Exception\...
Libbna Mathew's user avatar
2 votes
2 answers
2k views

How to use migrate process plugin concat on multiple values?

I am trying to import from a csv that has multiple files in the same column, e.g. title,gallery,tag node1,img1.jpg|img2.jpg|img3.jpg,2 node2,img4.jpg,2 node3,img5.jpg|img6.jpg,3 I need to prepend the ...
jofitz's user avatar
  • 125
2 votes
1 answer
159 views

Non-Config Menus

I have this requirement where I would need to create a menu every time a user creates a new instance of a custom entity I'm building. One can easily do this with Menu::create() on entity creation, but ...
Joseph's user avatar
  • 1,596
2 votes
1 answer
2k views

Adding Constraint to entity referenced Paragraph field

I'm attempting to follow this documentation to add a custom constraint to a field in a Paragraph but I'm having trouble in adding constraint to that field. Currently I have book content type with ...
miststudent2011's user avatar
2 votes
1 answer
233 views

CKEditor 5 - access PHP plugin configuration from JS plugin?

I have provided a CKEditor 5 plugin a PHP configuration class. I am able to set and store configuration for the text editor plugin now, but do not know how to access that configuration value(s) from ...
Kevin's user avatar
  • 27.8k
2 votes
1 answer
311 views

How to create configurable plugins under a plugin manager?

I have a custom plugin type and annotation. The purpose of it is so people can develop their own clients for an API integration, and tell the system which plugin to use to perform these actions. I am ...
Kevin's user avatar
  • 27.8k
2 votes
1 answer
1k views

How can I implement paging for a custom query plugin which displays data from an external API?

Hi I have a requirement to display the data from external api but should not be imported into any entities. What I did is I have written a custom view query plugin which displays the data from ...
Kanna's user avatar
  • 29
2 votes
1 answer
634 views

How to debug the evaluate() function of a custom Block Condition Plugin

I'm implementing a custom block visibility condition plugin and am unable to figure out my bugs in the conditional logic, because I can't get a dpm, var_dump, or debug call to work inside the evaluate(...
JamesWilson's user avatar
  • 2,148
2 votes
2 answers
931 views

Create a custom area plugin

I'm looking to add a plugin for Views to provide some custom functionality in the footer of a view. First, I created the following in my_module/src/Plugin/views/area/MyPlugin.php: namespace Drupal\...
akalata's user avatar
  • 592

1
2 3 4 5