LogoLogo
9.0.x
9.0.x
  • Overview
    • About Varbase
    • Roadmap
    • Release Cycle and Supported Versions
    • How to Get Support
  • Developers
    • Getting Started
    • Installing Varbase
      • Requirements
      • Installing Varbase with DDEV
      • Installing Varbase with Lando
    • Understanding Varbase
      • Basic Concepts
      • Core Components
        • Varbase Core
          • Varbase Admin
          • Varbase Page
          • Varbase Security
          • Varbase Webform
          • Varbase Default Content
          • Varbase Tour
        • Varbase Media
        • Varbase Editor
        • Varbase Email
        • Varbase SEO
        • Varbase Workflow
        • Varbase Layout Builder
          • Varbase Landing page (Layout Builder)
          • Varbase Heading Block
          • Varbase Rich Text Block
          • Varbase HTML Code Block
          • Varbase Media (Image/Video) Block
          • Varbase Gallery Block
        • Varbase Total Control Dashboard
        • Vartheme Claro
        • Vartheme BS4
      • Optional Components
        • Varbase API
        • Varbase Internationalization
        • Varbase Media Hero Slider
        • Varbase Carousels
        • Varbase Blog
        • Varbase Search
        • Varbase Social Single Sign-On
        • Varbase Media Twitter
        • Varbase Media Instagram
        • Varbase Content Planner
        • Varbase Bootstrap Paragraphs
          • Varbase Bootstrap Paragraphs Text and Image
        • Varbase Landing Page (Paragraphs)
      • Additional Components
        • Varbase Media Header
        • Varbase FAQs
        • Varbase Reports
        • Varbase Commerce
        • Varbase YouTube Import
      • Development Components
        • Varbase Development
        • Varbase Style Guide
        • Reroute Email
        • Varbase Updates Helper
    • Configuring a Varbase Site
      • Navigation
        • Defining Active Menu Trail Using Menu Position
      • Using View Modes Inventory
      • Content Moderation and Workflows
      • URL Aliases in Varbase/Drupal
        • Configuring URL Aliases
        • Managing URL Aliases
      • Managing URL Patterns for Multilingual Websites
      • Managing Date and Time Formats to Display Across the Site
      • Using Varbase Layout Builder
        • Creating a Landing Page With Varbase Layout Builder
        • Activating Varbase Layout Builder for Content Types
      • Configuring Pathologic When Going Live
      • Configuring SEO Features
        • Disallow Oembed Media Links
      • Configuring Security Features
        • Spam Protection
        • Password Policies
        • Other Security Kits
        • Flood Contorl
        • Enable HTTP Password Authentication
      • Configuring JSON:API Features
      • Configure Varbase Media Hero Slider
      • Configuring Varbase Media Header
      • Configuring Varbase Mailer Settings
        • Configure Symfony Mailer
        • Configure Swift Mailer
        • Switch From Swift Mailer to Symfony Mailer
      • Entity Definition Update Manager Class
      • Module Installer Factory Class
    • Theme Development with Varbase
      • Understanding The Vartheme Base Theme
      • Creating Your Own Theme
      • Local Tasks and Moderation Sidebar
      • Add Preloaded Fonts in Vartheme
      • Switch From Node SASS to Dart SASS for Old Sub-Themes
    • Launching a Varbase Site to Production
    • Updating a Varbase Site
      • Understanding Varbase Updater Package
      • Handling Patches When Updating
      • Handling Configuration Updates
      • Updating Varbase to work with Composer 2.0
      • Updating Drush to the Latest Stable Version
      • Version Update Guides
        • Updating Varbase ~9.0 to Drupal 10
        • Switch from CKEditor 4 to CKEditor 5 in Varbase ~9.1.0
        • Updating from Varbase 8.x to 9.x
    • Varbase Patches
    • Frequently Asked Questions (FAQs)
    • Extending Varbase
      • Overriding Varbase
      • Creating Your Own Feature
      • Creating A Sub Profile From Varbase
        • Varbase Sub Profile Generator
        • Varbase Sub Profile Basic Template
        • Varbase Sub Profile Basic Project Template
      • Install Needed YARN and Gulp Tools
      • Compiling Provided Component Styles
      • Check Standards/Practice Coding And Linting
  • Content Designers
    • Terminology
    • Accessing the Administration Area
      • Website Environments
    • User Management
      • Allow Email/Username Login & Registration
      • Default Roles and Site Personas
        • Edit Roles' Permissions
        • Managing Roles
      • Add User
      • Edit User
      • Masquerading as another user
    • Dashboard
      • Reports
    • Content Structure
      • EntityQueues
      • Menu Management
        • Add Menu Items
        • Update Menu Items
        • Adding a Page to the Menu
      • Taxonomies
        • Manage Vocabulary
        • Edit Vocabulary
        • List Terms
        • Add Terms
        • Reorder and Edit Terms
      • Webforms
        • Setting up Emails Handler Conditions
        • Setting up Confirmations Message Settings Types
    • Content Management
      • Create Content
        • Add a Basic page
        • Add a Landing page
        • Add Blog
        • Add Media
          • Image
          • Remote video
          • Video
      • Modify Content
      • Delete Content
      • Preview Content
      • Bulk Edit Content
      • Content Moderation
      • Publish Content
      • URL Alias
    • About Layout Builder
      • Section
      • Custom Blocks
        • Heading Block
        • Basic Block
        • Media Block(Image/Video)
        • Rich-Text Editor “WYSIWYG”
      • Managing Blocks
    • Search Engine Optimization
      • XML Sitemap
      • Meta Tags in Varbase
      • URL Redirects
      • Domain Redirects
      • Prevent a Single Content From Being Indexed
    • Site Configuration
      • System
        • Clearing Varbase Cache
        • Google analytics
        • Mail templates
      • User interface
      • Development
      • Varbase settings
      • Web services
    • Common Error Handling Tips
  • Contributing
    • Contributing to Documentation
Powered by GitBook
On this page
  • First Rule in Overriding
  • Custom Tweak Modules
  • Patching Bugs
  • Patch for a New Enhancements
  • Ignoring Patches
  • Recommended Patching Method with Gitlab Issue Forks
  1. Developers
  2. Extending Varbase

Overriding Varbase

PreviousExtending VarbaseNextCreating Your Own Feature

Last updated 1 year ago

First Rule in Overriding

Do not change the original code of Drupal Core, Varbase, Vartheme or any other Varbase components. In another words "Do not hack the original code without a trace for the change"

Use the standard Drupal overriding methods.

Custom Tweak Modules

Create custom modules and have your override in them.

  • Basic hooks like hook alter.

  • Use and dispatches.

  • with a custom or extended Class.

Patching Bugs

In case of capturing a bug. Search if it was filed in an issue. Look if the a patch fix for the issue was uploaded.

Apply the patch using the Composer patching method using:

Do not use the manual patching method in projects.

This action will guarantee the direction of keeping track of changes over the code.

Example: In the composer.json file for the project:

{
  "name": "vardot/varbase-project",
  "description": "Project template for Varbase distribution.",
  "type": "project",
  "license": "GPL-2.0-or-later",
  
  ...
  ...
  ...
  
  "require": {
    "composer/installers": "~1.0 || ~2.0",
    "oomphinc/composer-installers-extender": "~1.0 || ~2.0",
    "cweagans/composer-patches": "~1.0",
    "drupal/core-composer-scaffold": "^9",
    "drupal/core-project-message": "^9",
    "webflo/drupal-finder": "~1.0",
    "webmozart/path-util": "~2.0",
    "vardot/varbase": "~9.0",
    "vardot/varbase-updater": "~2.0"
  },
  "extra": {
    "enable-patching": true,
    "composer-exit-on-patch-failure": true,
    "patchLevel": {
      "drupal/core": "-p2"
    },
    "patches": {
      "drupal/core": {
        "Issue 1543858: Add startup configuration for PHP server":
        "https://www.drupal.org/files/issues/add_a_startup-1543858-30.patch"
      }
    }
  }
}

Please add the "Issue Number" and the URL for the used patch

Patch for a New Enhancements

An introductory patch for an enhancement over a Varbase component or any Drupal project is welcomed.

A patch may not be committed on the spot. It will need review, and testing for what affect it may do for websites.

A patch will work. But although a custom module is the better logic.

Ignoring Patches

There may be situations in which you want to ignore a patch supplied by a dependency. For example:

  • You use a different more recent version of a dependency, and now a patch isn't applying.

  • You have a more up to date patch than the dependency, and want to use yours instead of theirs.

  • A dependency's patch adds a feature to a project that you don't need.

  • Your patches conflict with a dependency's patches.

Example:

Varbase Core's composer.json file for the 9.0.7 version

Let imagine that the Drupal core release team had a new release, But they had committed the following issue:

The patch fix for the core issue was added when a fix was needed for the following issue:

At the point of a new release for Drupal core and in case the patch was committed.

Ignore the patch being used as in the following example method:

{
  "name": "vardot/varbase-project",
  "description": "Project template for Varbase distribution.",
  "type": "project",
  "license": "GPL-2.0-or-later",
  
  ...
  ...
  ...
  
  "require": {
    "composer/installers": "~1.0 || ~2.0",
    "oomphinc/composer-installers-extender": "~1.0 || ~2.0",
    "cweagans/composer-patches": "~1.0",
    "drupal/core-composer-scaffold": "^9",
    "drupal/core-project-message": "^9",
    "webflo/drupal-finder": "~1.0",
    "webmozart/path-util": "~2.0",
    "vardot/varbase": "~9.0",
    "vardot/varbase-updater": "~2.0"
  },
  "extra": {
    "enable-patching": true,
    "composer-exit-on-patch-failure": true,
    "patchLevel": {
      "drupal/core": "-p2"
    },
    "patches": {
      "drupal/core": {
        "Issue 1543858: Add startup configuration for PHP server":
        "https://www.drupal.org/files/issues/add_a_startup-1543858-30.patch"
      }
    },
    "patches-ignore": {
      "drupal/varbase_core": {
        "drupal/core": {
          "Issue #3165435: Fix tour <front> route as route name when a selected node had been set as the front page for the site":
          "https://www.drupal.org/files/issues/2020-08-16/3165435-2.patch"
        }
      }
    }
  }
}

Recommended Patching Method with Gitlab Issue Forks

If you use the URL to the Gitlab MR directly, your code base will change without warning, as people work on the merge request.

Recommended to use the local patch method in this case.

  • Download the .diff or .patch file in a patches folder in the project.

  • Add the module name, issue number, and date for the MR changes to the name of the file.

  • Add the patch local patch to patches.

Example ( NOT Recommended ):

    "patches": {
      "drupal/gin_login": {
        "Issue #3342318: Fix Gin Login Wallpaper images with the Origin URL (scheme and HTTP host) of the site":
        "https://git.drupalcode.org/project/gin_login/-/merge_requests/19.diff"
      }
    }

Example ( Recommended remote patch file ):

    "patches": {
      "drupal/gin_login": {
        "Issue #3342318: Fix Gin Login Wallpaper images with the Origin URL (scheme and HTTP host) of the site":
        "https://www.drupal.org/files/issues/2023-02-16/3342318-3.patch"
      }
    }

Example ( Recommended local patch/diff file ):

    "patches": {
      "drupal/gin_login": {
        "Issue #3342318: Fix Gin Login Wallpaper images with the Origin URL (scheme and HTTP host) of the site":
        "patches/gin_login-2023-02-16--3342318-19.diff"
      }
    }

WARNING: The URL for a Merge Request patch file will be named after the MR and will not change as more and more commits are being added to the MR. The contents of the patch file will change, however.

Therefore, it's strongly recommended to lock the patch file versions on production sites. To do so you must download the patch file and use it in composer from a local directory, or upload it to the same issue as a file. If you use the URL to the Gitlab MR directly, your codebase will change without warning, as people work on the merge request.

Do not keep patches or patches-ignore for long in projects.

Keep track of them, and clean not needed patches.

  • Report back if you'd spotted and committed patch. So it will be removed from the module.

  • Report back if you'd spotted a better patch logic and standard. So it will be used instead of the old patch.

Using the composer plugin with

The module is requiring Drupal Core with "drupal/core": "~9.0", . Having number of patches to fix issues or overriding Drupal core.

Issue : Fix tour route as route name when a selected node had been set as the front

Issue : Fix Varbase Welcome message not showing up after install compilation after adding and enabling moderation sidebar on the homepage

The composer plugin will not allow to apply it if it was committed.

This effectively means that you will get the latest version of the code from an issue, but you can't lock the patch file to a previous state, ignoring newer commits, until is fixed. So, it brings a security risk because any new commit to the issue's branch will be automatically deployed to your repo via the next "composer install" launch and can harm your project!

Event Subscribers
Switching a Class for a service
cweagans/composer-patches
cweagans/composer-patches
patches-ignore
Varbase Core
https://github.com/Vardot/varbase_core/blob/9.0.7/composer.json#L138
#3165435
#3164237
cweagans/compsoer-patches
https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupal/creating-issue-forks-and-merge-requests#s-patch-files-f[…]se-with-composer
this issue