-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42822ec
commit 5481548
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |