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

Is there a Media acces control mechanism in Drupal?

I am using hook_node_access_records() , and hook_node_grants() in a custom module for node acces control and it Works perfectly

I am wondering if there would be something similar for media entities??

Thanks in advance for your advices.

 

Struggling with dependency injection

I am still struggling to understand how to use dependecy injection correctly.

(This is all from the contributed extension Notify)

It has a a service class named "Notify".

In it, I am doing a lot of direct calls to global service containers. Example:

$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple();

This works (i.e. it gets the nodes), but I am getting warned by PHPstan:

How does a path become content in Drupal 7? (aka auditing content effectively)

Heya! I'm working on a project for a client who is using Drupal 7. Among other things, we want to perform an audit of the content currently stored in their Drupal instance. Specifically, I want to create a list of every page / link on the site and any related files / downloads that Drupal is managing for them. 

Looking at the APIs, I honestly have no idea where to start here. I am also digging around the database and, while I see the nodes and various field_ tables that seem to have the content stored in them, I see no obvious way they're connected. 

What's the correct way to set a field value in views_pre_render?

Here's my code.

I'm trying to populate a custom text field that has a default value with a new value thus:

function mytheme_views_pre_render(Drupal\views\ViewExecutable $view) {
if ($view->id() == "contacts" && $view->current_display == 'block_7') {
foreach ($view->result as $row) {
$cid = $row->_entity->id->value;
$cs = lgf_checksum_get($cid);
if ($cs) {
$row->_entity->nothing->setValue($cs);
}
}
}
}

It's throwing this error 

Dependencies version restrictions not working (.info.yml file)

Hello,

I am trying to add the exact version of AnimateCSS module for a new module in the .info.yml dependencies.

My code is as follows:

Drupal throws warning after deleting unneeded .module

Drupal 10 is supposed to work fine if there is no .module file in a project.

However, if I install an module project (named say, Example) that initially came with example.module and later found that that file was no longer needed in the project, deleting it throws this warning when the cache is rebuilt:

Pages

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