Skip to content

Instantly share code, notes, and snippets.

View shamsher327's full-sized avatar
🏠
Working from home

Shamsher Alam shamsher327

🏠
Working from home
View GitHub Profile
@shamsher327
shamsher327 / content_moderation.install
Created March 23, 2021 08:07 — forked from jhedstrom/content_moderation.install
Custom content moderation update hooks from 8.2.x to 8.3.x
<?php
/**
* @file
* Install file for content_moderation.
*/
use Drupal\content_moderation\Entity\ContentModerationState;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Database\Database;
// Add coder to run command line interface.
- composer require --dev drupal/coder:^8.2.11
// Get dependency for sniffer.
- composer update dealerdirect/phpcodesniffer-composer-installer acquia/blt sensiolabs-de/deprecation-detector --with-all-dependencies
// Check list of standards packages installed.
- vendor/bin/phpcs -i
// Run to know Drupal practice issue.
echo date(DateTime::ISO8601);
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024;sudo /sbin/mkswap /var/swap.1;sudo /sbin/swapon /var/swap.1
https://patternlab.io/
https://www.videodrupal.org/video/20190512/twig-fractal-drupal-decoupling-ui-components-drupal-data-structures
PDF:
https://www.drupalgovcon.org/sites/default/files/session/slides/2018-05/component_theming_ui_patterns.pdf
Modules:
https://www.drupal.org/project/ui_patterns
https://www.drupal.org/project/components

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
composer config --global secure-http false
@shamsher327
shamsher327 / gist:45b7a453b11bae48ab609fd6496d18df
Created February 19, 2019 04:45
Admin User login with code
$uid = '1';
$user = Drupal\user\Entity\User::load( $uid );
user_login_finalize( $user );
$response->send();
@shamsher327
shamsher327 / gist:23c8453e10a60e31773b3b0c7b119e72
Created February 13, 2019 15:56
Drupal composer git repo
Drupal composer git repo
composer config repositories.drupal composer https://packages.drupal.org/8
$user = \Drupal\user\Entity\User::load(2131);
$user->addRole('administrator');
$user->save();