Skip to content

Instantly share code, notes, and snippets.

View achraf-jeday's full-sized avatar
🏠
Working from home

Achraf Jeday achraf-jeday

🏠
Working from home
View GitHub Profile
@achraf-jeday
achraf-jeday / git-rebase.txt
Last active December 9, 2020 14:05
Git: git rebase and git -D
10225 gco develop
10226 git fetch --all
10227 git pull
10228 git branch -D feature/DevOps-Refonte-du-docker
10229 git fetch --all
10230 gco feature/DevOps-Refonte-du-docker
10232 git branch
10234 git rebase origin/develop
10236 git add composer.lock
10238 git rebase --continue
@achraf-jeday
achraf-jeday / docker4drupal.txt
Last active January 8, 2020 10:28
We are going to use composer to create a codebase with the latest version of Drupal 8.
We are going to use composer to create a codebase with the latest version of Drupal 8 or 7:
Drupal 8:
composer create-project drupal-composer/drupal-project:8.x-dev docker_drupal --stability dev --no-interaction
Drupal 7:
composer create-project drupal-composer/drupal-project:7.x-dev docker_drupal --no-interaction
Then we are going to clone the latest version of docker4drupal and remove the .git folder from it:
git clone git@github.com:wodby/docker4drupal.git docker_drupal_server
@radheymkumar
radheymkumar / Get current user in drupal 8
Created October 18, 2019 04:24
Get current user in drupal 8
get current user in drupal 8
Description: In drupal 7 we get the current user object by defining global $user but in drupal 8 this quite different. If you want to get current user object then follow below code.
$current_user = \Drupal::currentUser();
$uid = $current_user->id();
It returns user id of current user.
$user_mail = $current_user->getEmail();
It returns user email id.
@achraf-jeday
achraf-jeday / my_module.install
Last active March 2, 2020 14:15
Drupal 8: Log error messages programmatically in a custom module.
// Logs a notice
\Drupal::logger('my_module')->notice($message);
// Logs an error
\Drupal::logger('my_module')->error($message);
// Logs an info
\Drupal::logger('my_module')->info($message);
@achraf-jeday
achraf-jeday / Docker most used commands and drush for drupal 8
Last active June 21, 2022 14:07
Docker and drush most used commands (drupal 8)
List all containers (only IDs):
docker ps -aq
Stop all running containers:
docker stop $(docker ps -aq)
Or this one:
docker-compose down --remove-orphans
Or this one:
@mablae
mablae / register.html.twig
Created October 17, 2018 00:55 — forked from ThePeterMick/register.html.twig
Display label and checkbox separately for bootstrap 4 in Twig for Symfony 4
{% form_theme form _self %}
{% block checkbox_widget -%}
{%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%}
{%- if 'checkbox-custom' in parent_label_class -%}
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' custom-control-input')|trim}) -%}
<div class="custom-control custom-checkbox{{ 'checkbox-inline' in parent_label_class ? ' custom-control-inline' }}">
{{ block('checkbox_widget_base') }}
</div>
{%- else -%}
@modcab
modcab / module.php
Created July 12, 2017 12:41
Drupal 8 - Get MIME type from file uri.
<?php
$mime = \Drupal::service('file.mime_type.guesser')->guess($uri);
@MOOOWOOO
MOOOWOOO / py-gitignore
Last active April 15, 2024 03:41
python pycharm gitignore
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
@colorfield
colorfield / drupal8-links.php
Last active February 3, 2021 18:04
Drupal 8 links, or where is my l() function
@Jaesin
Jaesin / delete_content_entities.d8.php
Created June 22, 2015 07:14
Delete all content entities in Drupal 8.
<?php
// Delete all nodes.
entity_delete_multiple('node', \Drupal::entityQuery('node')->execute());
// Delete all files.
entity_delete_multiple('file', \Drupal::entityQuery('file')->execute());
// Delete all taxonomy terms.
entity_delete_multiple('taxonomy_term', \Drupal::entityQuery('taxonomy_term')->execute());