Skip to content

Commit

Permalink
added drush 9 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
shagel7984 committed Jun 23, 2020
1 parent 42822ec commit 5481548
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drush.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
custom_purge.commands:
class: \Drupal\custom_purge\Commands\CustomPurgeCommands
arguments: ['@custom_purge.url_purger']
tags:
- { name: drush.command }
53 changes: 53 additions & 0 deletions src/Commands/CustomPurgeCommands.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace Drupal\custom_purge\Commands;

use Drupal\custom_purge\UrlPurger;
use Drush\Commands\DrushCommands;

/**
* A Drush commandfile.
*
* In addition to this file, you need a drush.services.yml
* in root of your module, and a composer.json file that provides the name
* of the services file to use.
*
* See these files for an example of injecting Drupal services:
* - http://cgit.drupalcode.org/devel/tree/src/Commands/DevelCommands.php
* - http://cgit.drupalcode.org/devel/tree/drush.services.yml
*/
class CustomPurgeCommands extends DrushCommands {

/**
* The UrlPurger.
*
* @var \Drupal\custom_purge\UrlPurger
*/
protected $urlPurger;

/**
* Construct of CustomPurgeCommands.
*
* @param \Drupal\custom_purge\UrlPurger $url_purger
* The custom purge url purger.
*/
public function __construct(UrlPurger $url_purger) {
parent::__construct();
$this->urlPurger = $url_purger;
}

/**
* Calls the purgeAllProviders method.
*
* @param string $url
* The url to purge.
* @command custom-purge-all-providers
*/
function drushCustomPurgeAllProviders(string $url) {
$this->logger->info($url);
$url_array = explode(',', $url);
$purger = $this->urlPurger;
$purger->purgeAllProviders($url_array);
}

}

0 comments on commit 5481548

Please sign in to comment.