\Drupal::service('cache_tags.invalidator')->invalidateTags([$tag1, $tag2]);
\Drupal::service('cache.render')->invalidateAll()
SetEnv APP_ENV prod SetEnv DATABASE_URL 'mysql://user:[email protected]:3306/dbname'
<?php | |
declare(strict_types=1); | |
/* | |
A pattern with multiple conditions: | |
- at least one digit. | |
- at least one lowercase letter (including special Scandinavian characters). | |
- at least one uppercase letter (including special Scandinavian characters). | |
- at least one character that is not a letter or a number (including special Scandinavian characters). |
<?php | |
namespace Drupal\your_module\Controller; | |
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; | |
class YourController { | |
public function yourPage() { | |
// Some logic here... |
To retrieve a timezone for Ukraine in PHP 8+
php -r "var_export(DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY, 'UA'));"
Possible output:
array (
<html> | |
<head> | |
<title>Unsubscribe successful</title> | |
</head> | |
<body> | |
<h1>Unsubscribe successful</h1> | |
<p>Your email has been successfully unsubscribed from this list.</p> | |
</body> | |
</html> |
Archive a folder without redundant files using the command line on macOS.
cd <folder_path>
where <folder_path>
— a folder which should be archived.
zip -r .zip . -x "*.git*" -x "*.DS_Store"
/** | |
* Groups an array of objects by object property | |
*/ | |
const groupBy = <T>(array: T[], key: keyof T): { [key: string]: T[] } => { | |
return array.reduce((accumulator: { [key: string]: T[] }, currentElement: T) => { | |
const keyValue = currentElement[key] as unknown as string; | |
if (keyValue in accumulator) { | |
accumulator[keyValue].push(currentElement); | |
} else { |
// This function is quite flexible because it can handle any number of input arrays and | |
// doesn't require them to be of equal length. It interleaves as many elements as possible | |
// from each array, in the order that the arrays (and elements) were provided. | |
/** | |
* Interleaves elements of multiple arrays. | |
* The function takes any number of arrays as arguments. | |
*/ | |
function interleaveArrays(...args) { | |
// Find the maximum length among all arrays |