Skip to content

Instantly share code, notes, and snippets.

View vincentmoulene's full-sized avatar

Vincent Moulene vincentmoulene

View GitHub Profile
./vendor/bin/drush user:create newuser --mail="newuser@mail.com" --password="newpassword"
./vendor/bin/drush user-add-role "administrator" newuser
```
drush eval "\$module_data = \Drupal::config('core.extension')->get('module'); unset(\$module_data['bamboo_twig_loader']); \Drupal::configFactory()->getEditable('core.extension')->set('module', \$module_data)->save();"
```
SELECT value FROM key_value WHERE collection="system.schema" AND name = 'block';
Then
drush updb
@vincentmoulene
vincentmoulene / strpos_arr.php
Created August 29, 2019 10:19 — forked from irazasyed/strpos_arr.php
PHP: Strpos Array, Find in array!
<?php
/* strpos that takes an array of values to match against a string note the stupid argument order (to match strpos) */
function strpos_arr($haystack, $needle) {
if(!is_array($needle)) $needle = array($needle);
foreach($needle as $what) {
if(($pos = strpos($haystack, $what))!==false) return $pos;
}
return false;
}
# ------------------------------------
# Docker alias and function
# ------------------------------------
# Get latest container ID
alias dl="docker ps -l -q"
# Get container process
alias dps="docker ps"
<?php
function as_blocks_button_render( $attributes, $context ) {
// Get the text of the button.
preg_match('/<a[\s]+([^>]+)>((?:.(?!\<\/a\>))*.)<\/a>/',$context, $match);
$return['buttonText'] = parse_url($match[2])['path'];
// Get the text of the url.
preg_match_all('/<a\s+(?:[^>]*?\s+)?href=(["\'])(.*?)\1/', $context, $matches, PREG_SET_ORDER, 0);
$return['url'] = $matches[0][2];
@vincentmoulene
vincentmoulene / gist:f08004dbc112182e4129f5ffb5b07962
Created March 25, 2019 15:13
DRUPAL 8 update admin password
```
./../vendor/bin/drush user:password admin "admin"
```
And d'ont forget to check status of the admin user to `1`.
@vincentmoulene
vincentmoulene / mails.inc
Created November 28, 2018 11:07
Override contact form API drupal 8 to send copy message
<?php
/**
* @file
* Form and Mail hooks.
*
* The contact form API disable to send email to an anonymous user.
* We need to override the form before it was displayed and
* before send the email get the value of the field email of the
* person that filled the form.
Redirect 301 /home /
@vincentmoulene
vincentmoulene / Export xls with symfony
Created May 2, 2018 15:42
Export xls with symfony
use Symfony\Component\HttpFoundation\Request;
/**
* Create a zip file with excel contain the list of clubs.
*
* @param Request $request
* @param $the_response_excel_file
* @param $the_file_name
*/
public function exportAction(Request $request, $the_response_excel_file, $the_file_name)