This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Error, I can't spot it.

I am having an error, but I can't figure out why it occurs.

This is my event subscriber:

<?php

namespace Drupal\module_hero\EventSubscriber;

use Symfony\Component\EventSubscriber\EventSubscriberInterface;

use Symfony\Component\HttpKernel\KernelEvents;

/**
 * Our events subscriber.
 */
class HeroInitSubscriber implements EventSubscriberInterface {

    public function __construct() {}

    public function onRequest($event) {    

    var_dump("Hello from our event"); die();
    } 

Export/Import Fields, Content Types, Views, Blocks, Menus, and Roles

I've developed a Drupal 9 site in our "development" environment. I'd like to copy it to a "testing", "staging", and eventually a "production" environment. How do I do this without exporting/importing the entire database? I have many views, custom fields, content types, blocks, menus, and roles to export/import.

I use to be able to do this in Drupal 6/7. There were easy to use UIs to export/import views, blocks, and content types but not menus. Where are they now?

Update a field of all node with get or entity Query

use Drupal\node\Entity\Node;
$node = Node::load($nid);
$node->setTitle('MY NEW TITLE'); // This is a special meta field
$node->set('FIELD_NAME', 'THIS IS DATA'); // This is a Field added in to the content type
$node->save();

This code allows you to update the item (s) of a content type.
I need to update a boolean field of all nodes of a content type.
Is it possible to do this with getQuery or entityQuery to make it faster?
Or if there is another sql command to be able to do it

Installed module is not recognized as a service

I am currently in the process of updating a pre-existing drupal site from 8 to 9. This is being done on my local first using XAMMP, later we will update on the server.

I have managed to update all the modules, and then finished by updating drupal core. Everything was going smoothly however once running the site and trying to open it, It says that "The website encountered an unexpected error. Please try again later."

The logs say.... The service "samlauth.saml" has a dependency on a non-existent service "externalauth.externalauth"

How can I update an entity with a .yml file?

I see that EntityDefinitionUpdateManager::applyUpdates() has been removed.

Every time I add a new field to a .yml file or I add a new node.type.yml to the configuration directory in a module I am developing, I reinstall the module to see newly added fields.

How to attach a library to a multiple value field ?

Context:
I am building a "field formatter" custom module.
The field has multiple values. These values  are hidden in the node.
They appear in an animated overlay table when you click on a link "show the values" (a JS script is attached to the field)
It works.
But I have a question.

What is the proper way for attaching a library to a field ?

I did it this way in the formatter class:

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions