Remove unused export command
This commit is contained in:
parent
f219d81d38
commit
7ea2c8991c
|
@ -1,6 +0,0 @@
|
|||
services:
|
||||
Drupal\opdavies_blog\Command\ExportBodyValuesForThemePurgingCommand:
|
||||
arguments: ['@database']
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: drush.command }
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opdavies_blog\Command;
|
||||
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Tightenco\Collect\Support\Collection;
|
||||
|
||||
final class ExportBodyValuesForThemePurgingCommand {
|
||||
|
||||
private static array $tableNames = [
|
||||
'block_content__body',
|
||||
'node__body',
|
||||
];
|
||||
|
||||
private string $filename = 'body-field-values.txt';
|
||||
|
||||
private Connection $database;
|
||||
|
||||
public function __construct(Connection $database) {
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drush command to export body field values into a file.
|
||||
*
|
||||
* @command opdavies:export-body-values-for-theme-purging
|
||||
*/
|
||||
public function handle(): void {
|
||||
$values = Collection::make(self::$tableNames)
|
||||
->flatMap(fn(string $tableName) => $this->getValuesFromTable($tableName))
|
||||
->implode(PHP_EOL);
|
||||
|
||||
file_put_contents($this->getFilePath(), $values);
|
||||
}
|
||||
|
||||
private function getFilePath(): string {
|
||||
return drupal_get_path('theme', 'opdavies') . DIRECTORY_SEPARATOR . $this->filename;
|
||||
}
|
||||
|
||||
private function getValuesFromTable(string $tableName): array {
|
||||
return $this->database->select($tableName)
|
||||
->fields($tableName, ['body_value'])
|
||||
->execute()
|
||||
->fetchCol();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue