<?php
declare(strict_types=1);
namespace Drupal\my_module;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
class Example {
public function __construct(
#[Autowire(service: 'current_user')]
private readonly AccountInterface $currentUser,
) {
}
public function getCurrentUser(): AccountInterface {
return $this->currentUser;
}
}
SELECT table_name AS `table`, round(((data_length + index_length) / 1024 / 1024), 2) `size in MB`
FROM information_schema.TABLES
WHERE table_schema = "DATABASE_NAME"
ORDER BY `size in MB` DESC
LIMIT 10;
<?php
$error_message = t('There is an error with this.');
\Drupal::messenger()->addError($error_message));
\Drupal::logger('my_module')->log('error', $error_message);