Skip to content

Instantly share code, notes, and snippets.

View vishalbandre's full-sized avatar
💭
I may be slow to respond.

Vishal Bandre vishalbandre

💭
I may be slow to respond.
View GitHub Profile
<?php
namespace Drupal\vishal_default_config\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
<?php
namespace Drupal\vishal_ajax_api\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\HtmlCommand;
/**
Get fresh Drupal:
composer create-project drupal/recommended-project d9.dev
Done.
Install Drush:
composer require --dev drush/drush
Done.
Make Drush global:
wget -O drush.phar https://github.com/drush-ops/drush-launcher/releases/latest/download/drush.phar
Copy template inside the templates directory in your module.
Then, reuse this snippet as per your overriden template.
Example:
If you want to override template: page--taxonomy.html.twig
1. Copy the template inside your modules templates directory.
2. Register it with your module preprocessor. i.e. <module_name>.module.
Drupal Modules:
Creating custom twig template in Drupal 8 or Drupal 9
1. https://medium.com/@anupeie.fiem/creating-custom-twig-template-in-drupal-8-or-drupal-9-b67020dfdfff
2. https://www.drupal.org/docs/theming-drupal/twig-in-drupal/create-custom-twig-templates-for-custom-module
3. https://www.drupal.org/forum/support/module-development-and-code-questions/2015-06-03/drupal-8-override-template-with
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeBundleInfo;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
Inside your class where you want to inject the Drupal 9 services:
/**
* Get access to entity type manager.
@vishalbandre
vishalbandre / development-technologies-tracklist.txt
Last active October 30, 2021 03:42
Development Technologies Tracklist
// Boilerplates
// Web Design/Development Boilerplates
https://github.com/sahat/hackathon-starter
https://github.com/ant-design/ant-design-pro
https://github.com/coryhouse/react-slingshot
@vishalbandre
vishalbandre / php-style-guide.md
Created September 7, 2021 06:37 — forked from ryansechrest/php-style-guide.md
PHP style guide with coding standards and best practices.

PHP Style Guide

All rules and guidelines in this document apply to PHP files unless otherwise noted. References to PHP/HTML files can be interpreted as files that primarily contain HTML, but use PHP for templating purposes.

The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Most sections are broken up into two parts:

  1. Overview of all rules with a quick example
  2. Each rule called out with examples of do's and don'ts
@vishalbandre
vishalbandre / Task automation with Gulp
Created September 7, 2021 03:03
This gist creates, automates and watches for three types of tasks - image optimization, sass and autoprefixing
const gulp = require('gulp');
const imagemin = require('gulp-imagemin');
var sass = require('gulp-sass')(require('sass'));
const autoprefixer = require('gulp-autoprefixer');
// Task 1: Converting SASS to CSS
function sassify() {
return gulp.src('app/sass/style.scss')
.pipe(sass().on('error', sass.logError))
@vishalbandre
vishalbandre / webstoemp-gulpfile.js
Created September 5, 2021 14:12 — forked from jeromecoupe/webstoemp-gulpfile.js
Gulp 4 sample gulpfile.js. For a full explanation, have a look at https://www.webstoemp.com/blog/switching-to-gulp4/
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");