use Symfony\Component\Mime\MimeTypes;
function getFileExtension(string $fileContent): ?string
{
$mimeType = (new \finfo(FILEINFO_MIME_TYPE))->buffer($fileContent);
$mimeTypes = new MimeTypes();
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Drupal\Core\File\FileSystemInterface; | |
| $directory = '/path/to/processed'; | |
| \Drupal::service('file_system') | |
| ->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY); | |
| \Drupal::service('file_system') |
To extend the standard user registration form, use
namespace Drupal\your_module\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\user\RegisterForm;
class YourRegisterForm extends RegisterForm {
public function buildForm(array $form, FormStateInterface $form_state) {We are going to replace "Make it at least 8 characters" from the user core modules (core/modules/user/user.module) with "Make it at least 12 characters".
/**
* Implements hook_element_info_alter().
*/
function <your_module>_element_info_alter(array &$types): void
{
if (isset($types['password_confirm'])) {
$types['password_confirm']['#process'][] = 'users_form_process_password_confirm';ngrok creates a tunnel from the public internet to your local machine.
Sign up for an ngrok account https://dashboard.ngrok.com/
brew install ngrok/ngrok/ngrokTo configure the error messages visibility, set an appropriate configuration in the settings.php file
// Show all error messages, including notices and coding standards warnings.
$config['system.logging']['error_level'] = 'verbose';File: /path/to/docroot/sites/<SITE_NAME>/settings.php.
Then clear the Drupal cache.
One of the ways to create an immediately executed anonymous function
(function() {
'use strict';
// ...
})();