Skip to content
Snippets Groups Projects
Commit f3703bcd authored by Igor Biki's avatar Igor Biki
Browse files

ISTWCMS-5409: Adding drush command to get lightweight cron key and url.

parent 3336eb4a
No related branches found
No related tags found
1 merge request!229ISTWCMS-5409: Removing host from drush command, and using path instead that...
services:
uw_cfg_common.commands:
class: Drupal\uw_cfg_common\Commands\UwDrushCommands
arguments: ['@entity_type.manager', '@uw_cfg_common.missing_blocks']
arguments: ['@entity_type.manager', '@uw_cfg_common.missing_blocks', '@config.factory', '@request_stack']
tags:
- { name: drush.command }
......@@ -2,11 +2,13 @@
namespace Drupal\uw_cfg_common\Commands;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\uw_cfg_common\Service\UWMissingBlocks;
use Drupal\uw_cfg_common\UwRoles\UwRoles;
use Drush\Commands\DrushCommands;
use Drush\Utils\StringUtils;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* Drush commands for uw_cfg_common module.
......@@ -29,12 +31,28 @@ class UwDrushCommands extends DrushCommands {
*/
protected $missingBlocks;
/**
* Config factory from core.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* Request from core.
*
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $request;
/**
* {@inheritDoc}
*/
public function __construct(EntityTypeManagerInterface $entityTypeManager, UWMissingBlocks $missingBlocks) {
public function __construct(EntityTypeManagerInterface $entityTypeManager, UWMissingBlocks $missingBlocks, ConfigFactoryInterface $configFactory, RequestStack $requestStack) {
$this->entityTypeManager = $entityTypeManager;
$this->missingBlocks = $missingBlocks;
$this->configFactory = $configFactory;
$this->request = $requestStack->getCurrentRequest();
}
/**
......@@ -167,4 +185,42 @@ class UwDrushCommands extends DrushCommands {
$this->logger()->success('Missing blocks removed from saved and unsaved layouts.');
}
/**
* Command to retrieve scheduler's lightweight cron key.
*
* @return string
* Lightweight cron key.
*
* @command uw:lightweight-cron-key
* @aliases uw-lwc-key
* @usage drush uw-lwc-key
* - Return light weight cron key.
*/
public function getLightWeightCronKey(): string {
$key = '';
$config = $this->configFactory->get('scheduler.settings');
if (!empty($config)) {
$key = $config->get('lightweight_cron_access_key');
}
return $key;
}
/**
* Command to retrieve scheduler's lightweight cron url.
*
* @return string
* Lightweight cron url.
*
* @command uw:lightweight-cron-url
* @aliases uw-lwc-url
* @usage drush uw-lwc-url
* - Return light weight cron url with key.
*/
public function getLightWeightCronUrl(): string {
$host = $this->request->getSchemeAndHttpHost();
return $host . '/scheduler/cron/' . $this->getLightWeightCronKey();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment