Skip to content

Instantly share code, notes, and snippets.

View msankhala's full-sized avatar
🎯
Focusing

mahesh sankhala msankhala

🎯
Focusing
View GitHub Profile
@msankhala
msankhala / custom-form-mode-to-entities.php
Created June 21, 2021 18:32
custom mode form to entities
<?php
// Source https://www.flocondetoile.fr/blog/provide-custom-mode-form-entities-drupal-8
/**
* Implements hook_entity_type_build().
*/
function my_module_entity_type_build(array &$entity_types) {
$entity_types['user']->setFormClass('profil', 'Drupal\user\ProfileForm');
}
@msankhala
msankhala / custom-entity-display-form-mode.php
Last active June 21, 2021 18:29
Creating custom Entity Display form mode
<?php
// Source https://www.droptica.com/blog/custom-entity-forms-example-user-editing-and-registration/
/**
* Implements hook_entity_type_build().
*/
function my_module_entity_type_build(array &$entity_types) {
$form_modes = ['custom_form_mode_1', 'custom_form_mode_2'];
@msankhala
msankhala / TopicsSelection.php
Created June 20, 2021 06:29 — forked from hussainweb/TopicsSelection.php
/web/modules/custom/axl_ks_topics/src/Plugin/EntityReferenceSelection/TopicsSelection.php
<?php
namespace Drupal\axl_ks_topics\Plugin\EntityReferenceSelection;
use Drupal\Component\Utility\Html;
use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\Query\QueryInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
@msankhala
msankhala / ComboForm.php
Created June 20, 2021 05:02 — forked from Eyal-Shalev/ComboForm.php
An example form object (Drupal 8) that combines multiple forms into itself.
<?php
namespace Drupal\sandbox\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormState;
use Drupal\Core\Form\FormStateInterface;
use Drupal\node\Entity\Node;
use Drupal\user\Entity\User;
@msankhala
msankhala / example.php
Created June 10, 2021 07:59 — forked from samuelsolis/example.php
Drupal 8 custom entity without bundle
<?php
/**
* @file
* Contains \Drupal\example\Entity\Example.
*/
namespace Drupal\example\Entity;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition;

Using Git to Manage a Live Web Site

Overview

As a freelancer, I build a lot of web sites. That's a lot of code changes to track. Thankfully, a Git-enabled workflow with proper branching makes short work of project tracking. I can easily see development features in branches as well as a snapshot of the sites' production code. A nice addition to that workflow is that ability to use Git to push updates to any of the various sites I work on while committing changes.

Contents

@msankhala
msankhala / nginx-ssl-config
Created September 9, 2020 06:50 — forked from apollolm/nginx-ssl-config
Nginx Configuration with multiple port apps on same domain, with SSL.
# the IP(s) on which your node server is running. I chose port 3000.
upstream app_geoforce {
server 127.0.0.1:3000;
}
upstream app_pcodes{
server 127.0.0.1:3001;
}
@msankhala
msankhala / nginx-load-balancing-failover.conf
Created April 13, 2020 17:07
Nginx load balancing failover
http {
upstream backend_uat {
server <server 1 ip> max_fails=1 fail_timeout=5s;
server <server 2 ip>;
}
server {
listen <nginx public ip>:443 ssl default_server;
server_name *.test.com www.*.test.com
@msankhala
msankhala / analysis.md
Created October 13, 2019 16:41 — forked from azharuddinkhan3005/analysis.md
Custom IF WBs analysis

Workbooks that were referenced during analysis.(The state of the WBs when referred to, were dated between 20th Aug - 22nd Aug 2019)

  1. UPR - Asia Shared Site - UPR - New Client Request Form_v2.0 (1)
  2. Unilever - Crown NAM - New Client Request Form - UL Domestic v2.6
  3. TWE - New Client Request Form+Custom IF with CP v16
  4. Volvo - Crown Global - New Client Request Form_Volvo_v1.4
  5. BP - Asia - New Client Request Form_British Petroleum Asia Pacific v1.6
  6. HAVI - NAM Client Configuration Workbook v1.8

CDS Mapping

After having a look into the CDS mapping sheet of the above mentioned WBs, I came across three patterns
@msankhala
msankhala / create-custom-info-hook.php
Created March 16, 2019 08:21
create custom info hook.
<?php
// Drupal 7 implement your custom hook_info()
/**
* Gets information about a authentication module.
*
* @param string $module
* The module to get info for.
* @return mixed
* The information array, or FALSE if the information wasn't found.