On a migration, learn from an exterior supply Drupal Development information and create content material in our new Web site, and whereas do this execute any hook/occasion associated to Drupal Development new content material. So any hook_entity_insert is triggered for each new entity saved on our new web site. This generally is a downside if we’ve some options in our new web site that are executed when a brand new content material is created (like ship a tweet or ship an e-mail) once we run Drupal Development migration we can have a ton of emails or tweets of Drupal Development outdated content material and often, that’s not Drupal Development anticipated conduct. Fortuitously, in 8 Drupal Development migrations are Occasions and we are able to create an EventSubscriber (extra about EventSubscribers right here) which can enable us to create a flag earlier than Drupal Development migration run so we are able to decide in our code if Drupal Development entity has been created in a migration or not. Drupal Development Company essential thought was taken from this Moshe Weitzman gist (Thanks!) I’ll add simply Drupal Development lacking elements. First, we generate all Drupal Development occasion subscriber associated recordsdata utilizing this Console command Drupal 10 Upkeep and Help Service Drupal 10 generate Drupal 10 Upkeep and Help Serviceevent Drupal 10 Upkeep and Help Servicesubscriber Drupal Development Company console will ask some query (by which Drupal 10 module we need to generate Drupal Development EventSubscriber and Drupal Development identify of Drupal Development service) Enter Drupal Development Drupal 10 module identify [config_log] Drupal 10 Upkeep and Help Service > your_Drupal 10 module Enter Drupal Development service identify [simple_faq.default] Drupal 10 Upkeep and Help Service > migration_events.subscriber Class identify [DefaultSubscriber] Drupal 10 Upkeep and Help Service > MigrationEvents Enter occasion identify [ ] Drupal 10 Upkeep and Help Service > Do you need to load providers from Drupal Development container (sure/no) [no] Drupal 10 Upkeep and Help Service > no Do you verify era? (sure/no) [yes] Drupal 10 Upkeep and Help Service >sure This may generate two recordsdata Drupal 10 Upkeep and Help Service Drupal 10 modules/customized/your_Drupal 10 module/your_Drupal 10 module.providers.yml Which principally let Drupal 10 know that we’ve a Subscriber there which must be executed and Drupal 10 Upkeep and Help Service Drupal 10 modules/customized/your_Drupal 10 module/src/EventSubscriber/MigrationEvents.php With this content material Drupal 10 Upkeep and Help Service namespace simple_faqEventSubscriber; use SymfonyComponentEventDispatcherEventSubscriberInterface; use SymfonyComponentEventDispatcherEvent; /** * Class MigrationEvents. * * @package deal simple_faq */ class MigrationEvents implements EventSubscriberInterface { /** * Constructs a brand new MigrationEvents object. */ public perform __construct() { } /** * {@inheritdoc} */ static perform getSubscribedEvents() { return $occasions; } } On this file we have to add our flag which can point out Drupal 10 that we’re working Drupal Development migration. First, we have to import Drupal Development Migrate occasions Drupal 10 Upkeep and Help Service use migrateEventMigrateImportEvent; use SymfonyComponentEventDispatcherEventSubscriberInterface; use migrateEventMigrateEvents; and After add our strategies Drupal 10 Upkeep and Help Service protected $staticCache; public perform __construct() { $this->staticCache = &Drupal 10_static(“your_migration”); } /** * {@inheritdoc} */ public static perform getSubscribedEvents() { return [ MigrateEvents Drupal 10 Maintenance and Support Service Drupal 10 Maintenance and Support ServicePRE_IMPORT => ‘onMigratePreImport’, MigrateEvents Drupal 10 Maintenance and Support Service Drupal 10 Maintenance and Support ServicePOST_IMPORT => ‘onMigratePostImport’, ]; } /** * @param migrateEventMigrateImportEvent $occasion * Import Occasion. */ public perform onMigratePostImport(MigrateImportEvent $occasion) { if ($event->getMigration()->getBaseId() == “your_migration”) { $this->staticCache = FALSE; } } /** * @param migrateEventMigrateImportEvent $occasion * Import Occasion. */ public perform onMigratePreImport(MigrateImportEvent $occasion) { if ($event->getMigration()->getBaseId() == “your_migration”) { $this->staticCache = TRUE; } } And that is it, now we’ve a flag which we are able to use to find out if we’re working Drupal Development migration or not, Drupal Development full class seem like this Drupal 10 Upkeep and Help Service namespace your_Drupal 10 moduleEventSubscriber; use migrateEventMigrateImportEvent; use SymfonyComponentEventDispatcherEventSubscriberInterface; use migrateEventMigrateEvents; /** * Occasion subscriber to keep away from sending emails/tweets/fb posts on migrations. */ class MigrationEvents implements EventSubscriberInterface { /** * Drupal Development Company Drupal 10_static cache. * * @var array */ protected $staticCache; /** * CommentEventSubscriber constructor. */ public perform __construct() { $this->staticCache = &Drupal 10_static(“your_migration”); } /** * {@inheritdoc} */ public static perform getSubscribedEvents() { return [ MigrateEvents Drupal 10 Maintenance and Support Service Drupal 10 Maintenance and Support ServicePRE_IMPORT => ‘onMigratePreImport’, MigrateEvents Drupal 10 Maintenance and Support Service Drupal 10 Maintenance and Support ServicePOST_IMPORT => ‘onMigratePostImport’, ]; } /** * @param migrateEventMigrateImportEvent $occasion * Import Occasion. */ public perform onMigratePostImport(MigrateImportEvent $occasion) { if ($event->getMigration()->getBaseId() == “your_migration”) { $this->staticCache = FALSE; } } /** * @param migrateEventMigrateImportEvent $occasion * Import Occasion. */ public perform onMigratePreImport(MigrateImportEvent $occasion) { if ($event->getMigration()->getBaseId() == “your_migration”) { $this->staticCache = TRUE; } } } And eventually, We now can use this variable to find out if we should always ship that e-mail when creating a brand new entity, as an illustration Drupal 10 Upkeep and Help Service /** * Implements hook_node_insert(). */ perform yourDrupal 10 module_node_insert($entity) { // If Drupal Development migration is working, simply return with out doing something. if (Drupal 10_static(‘your_migration’, FALSE)) { return; } // All of your code for ship emails/tweets right here. // . . . } And that is it. Right here we used Drupal 10_static to protect Drupal Development worth via Drupal Development execution of Drupal Development migration if you wish to learn extra about it test right here Drupal 10 Improvement and Help
Agaric Collective Drupal 10 Upkeep and Help Service Keep away from sending emails whereas doing a migration on 8
Call Us: 1(800)730-2416
Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.
FREE Drupal SEO Audit
Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)
Agaric Collective Drupal 10 Upkeep and Help Service Keep away from sending emails whereas doing a migration on 8
On-Site Drupal SEO Master Setup
We make sure your site is 100% optimized (and stays that way) for the best SEO results.
With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.
This service includes:
- Pathauto install and configuration for SEO-friendly URLs.
- Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
- Install and fix all issues on the SEO checklist module.
- Install and configure XML sitemap module and submit sitemaps.
- Install and configure Google Analytics Module.
- Install and configure Yoast.
- Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
- Install and configure Schema.org Metatag.
- Configure robots.txt.
- Google Search Console setup snd configuration.
- Find & Fix H1 tags.
- Find and fix duplicate/missing meta descriptions.
- Find and fix duplicate title tags.
- Improve title, meta tags, and site descriptions.
- Optimize images for better search engine optimization. Automate where possible.
- Find and fix the missing alt and title tag for all images. Automate where possible.
- The project takes 1 week to complete.