Rename custom module directories

- Rename `opdavies_blog` to `blog`.
- Rename `opdavies_blog_test` to `blog_test`.
- Rename `opdavies_talks` to `talks`.
- Rename `opdavies_talks_test` to `talks_test`.

The files within the directories haven't changed, so there is no
breaking change caused by renaming the directories.

 Please enter the commit message for your changes. Lines starting
This commit is contained in:
Oliver Davies 2020-09-04 21:19:17 +01:00
parent d7d5a6c8a3
commit cbe60209e6
59 changed files with 0 additions and 0 deletions
web/modules/custom/blog/src/Command

View file

@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace Drupal\opdavies_blog\Command;
use Drupal\Core\Database\Connection;
use Illuminate\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();
}
}