Skip to main content

Posts

Showing posts from August, 2018

How to Create/Apply Patches in drupal git

======== git patch A- Create new branch fix the changes After fix add & commit now create the patch with in the patch directory Now i am at patch branch & compare the changes to master branch command : git format-patch master -o patches patches/ : in this folder create the patch files Examples1 :  git format-patch TARGET_BRANCH  -o PATCH_FOLDER/ Lets suppose we are in patch branch and i do 5 commits to this branch, now to create the patch we will match the code to the traget branch like master in our case, so all the codes which is present in patch branch & not availbale in master branch would be create as patch files, 1 commit for 1 patch. i.e we do 5 commits so 5 commit files will be generated, Here:  -o reprents to store the patch as a directory and specify the director name   Example 2 : Single patch file based on commit id Lets consider the above example, but now i need only one commit changes instead of all, so first check...

Alter entity value before save

How to list the name of Entity types in site to use hooks, use Drupal\Core\Entity\EntityInterface; function hook_entity_presave(EntityInterface $entity) { } or function hook_entity_type_presave(EntityInterface $entity) { } but you should know the exact name of entity type , to do so use : drupal debug:entity (drush command) so for taxonomy case use, function itg_multi_category_entity_insert(Drupal\Core\Entity\EntityInterface $entity) {   if(!empty($entity->bundle()) && $entity->bundle() == 'category_management'){     $entity_values = $entity->toArray();     //Get the custom parent cat id      $parent_custom = $entity_values['field_relation'][0]['target_id'];     if($parent_custom == ''){       $parent_custom = 0;     }     $term_load = \Drupal\taxonomy\Entity\Term::load($entity_values['tid'][0]['value']);     $term_load->set('parent...