Skip to content

Instantly share code, notes, and snippets.

View nikunjkotecha's full-sized avatar

Nikunj Kotecha nikunjkotecha

View GitHub Profile
function blt() {
if [[ ! -z ${AH_SITE_ENVIRONMENT} ]]; then
PROJECT_ROOT="/var/www/html/${AH_SITE_GROUP}.${AH_SITE_ENVIRONMENT}"
elif [ "`git rev-parse --show-cdup 2> /dev/null`" != "" ]; then
PROJECT_ROOT=$(git rev-parse --show-cdup)
else
PROJECT_ROOT="."
fi
if [ -f "$PROJECT_ROOT/vendor/bin/blt" ]; then
<?php
/** ====================================================================== */
// Create table if not available.
db_query("CREATE TABLE IF NOT EXISTS {lock_test} (
id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
random_id int,
request_time varchar(50),
first_request_time varchar(50)
@nikunjkotecha
nikunjkotecha / MigrateAsymmetricToSymmetric.php
Created November 22, 2018 13:34
Code to migrate content from Asymmetric to Symmetric translations for paragraphs.
<?php
namespace Drupal\module\Helper;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Logger\LoggerChannelInterface;
use Drupal\paragraphs\Entity\Paragraph;
/**
<?php
namespace Drupal\custom_migrate\Plugin\migrate_plus\data_parser;
use Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Json;
/**
* Obtain JSON data for migration.
*
* @DataParser(
{
data: [
{
id: 1
scope: [
[
{
"key": "type",
"value": "1"
},
@nikunjkotecha
nikunjkotecha / module.install
Created October 6, 2017 05:39
Example to demonstrate how to update field config in update hooks.
<?php
/**
* @file
* Contains install, update, uninstall hooks for module.
*/
use Drupal\field\Entity\FieldConfig;
/**
@nikunjkotecha
nikunjkotecha / comment.install
Created October 6, 2017 05:33
Code reference that didn't work
<?php
/**
* Update status field.
*/
function comment_update_8300() {
$entity_definition_update_manager = \Drupal::service('entity.definition_update_manager');
$field_definition = $entity_definition_update_manager->getFieldStorageDefinition('status', 'comment');
$field_definition->setDescription(new TranslatableMarkup('A boolean indicating the published state.'))
->setRevisionable(TRUE);
@nikunjkotecha
nikunjkotecha / mymodule.install.php
Created April 11, 2017 06:17
Drupal 8 - using update hook to revert view
<?php
/**
* @file
* Contains install, update, uninstall hooks for mymodule module.
*/
/**
* Implements hook_update_N().
*
@nikunjkotecha
nikunjkotecha / push-platform.sh
Created March 15, 2017 06:41
Push the code from GITLAB to Platform
#!/usr/bin/env bash
set -e
# This script can be configured by specifying different environment variables in
# your .gitlab-ci.yml file's invocation of the script. If those are omitted, as
# in this example, the defaults below and throughout the script should be used.
# Check basic requirements from Config.
if [ -z "$PLATFORM_PROJECT_ID" ]; then
echo "PLATFORM_PROJECT_ID is required, please contact support if you don't know how to do it."