What to use instead of a global const in procedural code?

I have something like the following in mymodule.module:

const MYMODULE_CONST = 42;

/**
 * Implements hook_myhook().
 */
function mymodule_myhook($route_name, RouteMatchInterface $route_match) {
  return(t('The answer is @const', ['@const' => MYMODULE_CONST]));
}

This is the only place I use this constant. The reason for using a PHP global const for this is to have it defined near the top of the file for easy spotting and replacement. So having it as a value inside the function is not an option.

Ministry of the Interior of the State of North Rhine-Westphalia

New website of the Ministry of the Interior of the State of North Rhine-Westphalia based on nrwGOV

The relaunch of the website for the North Rhine-Westphalian Ministry of the Interior was the first major project to be built using nrwGOV.

Sectors: 
Government

Adding Affiliate Links and Securing API Keys with Key module & Encryption

Please pardon the fact I’m an ordinary non-expert (basic programmer but not in-depth expert) and am a friendly interface user for the most part.

Composer and Modules

I administer a Windows Server running IIS with Drupal 8. I have some web developers who are doing the actual site development. They are the ones installing and using Modules, and they do this via the web interface. Note that I installed Drupal 'recommended-project' using Composer and have been updating it with Composer.

Would it make sense to keep the Modules out of the composer.json file and just continue to let the devs manage them manually themselves, and only use Composer to update Core?

Routing issue

Hello there! I am trying to get used to the new way drupal 8/9 does things (I am an avid d7 developer), but having trouble finding proper documentation. 

So I am building an invoicing system for a client, and I have two routes setup in my invoicing.routing.yml file, as shown below

Media in Views, Content Types Storing Media for Views

One thing Drupal doesn't do is allow you to filter media in Views. I'm currently setting up "asset" content types for documents. Assigning taxonomy to these document content type assets. Then using views to pre-populate them on necessary pages. Reasoning for this... A large number of staff will be on the site. These document assets will be archived after xx time. We also want to control how these assets display visually as well as how they're sorted, etc. These displays and sorting may differ from page to page.

Is there a better way to do this?

Pages

Subscribe with RSS Subscribe to RSS - Drupal 8.x