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 | |
// For some queries, use `$query->sqlQuery->` instead of `$query->`. | |
str_replace(['{', '}'], ['', ''], str_replace(array_keys($query->getArguments()), array_values($query->getArguments()), $query->__toString())); |
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
drush eval "var_dump(Drupal\Component\Utility\Crypt::randomBytesBase64(55))" |
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
drush eval "module_load_install('module_name'); module_name_update_XXXX();" |
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
drush sql-dump --gzip --result-file=../backup/dump_db_$(date +%Y%m%d-%H%M%S).sql.gz | |
gunzip -c dump.sql.gz | drush sqlc |
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
create an empty repo on GitHub | |
git remote add github https://[email protected]/yourLogin/yourRepoName.git | |
git push --mirror github |
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
// In your settings.php (or custom_settings.php) | |
$config['system.maintenance']['message']['sorry'] = 'Sorry, our site is down now.'; | |
// To retrieve this config in PHP, do this : | |
\Drupal::config('system.maintenance')->get('message')['sorry']; |
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
SELECT concat('DROP TABLE IF EXISTS `', table_name, '`;') | |
FROM information_schema.tables | |
WHERE table_schema = 'MyDatabaseName'; |
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
#!/bin/bash | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" | |
php composer-setup.php --filename=composer --install-dir=/usr/local/bin | |
php -r "unlink('composer-setup.php');" |
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
/** | |
* This function will generate crop automatically. | |
* | |
* This makes it possible to generate the crops automatically | |
* if the contributor forgets to do so. | |
*/ | |
function _generate_crop_auto($form, $form_state) { | |
// Retrieve crop list. | |
$crop_list = $form['field_image']['widget'][0]['image_crop']['#crop_type_list']; | |
foreach ($crop_list as $crop) { |
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
$imageStyle = \Drupal::entityTypeManager()->getStorage('image_style'); | |
$styles = $imageStyle->loadMultiple(); | |
foreach ($styles as $style) { | |
$imageStyle->load($style->get('name'))->flush(); | |
} |