Rename and re-organise custom modules
- Rename `opd_talks` to `opdavies_talks` - Rename `custom` to `opdavies_blog`
This commit is contained in:
parent
e4e898f22c
commit
9b1a8fb3be
|
@ -11,7 +11,6 @@ module:
|
|||
config_split: 0
|
||||
contextual: 0
|
||||
ctools: 0
|
||||
custom: 0
|
||||
datetime: 0
|
||||
dblog: 0
|
||||
discoverable_entity_bundle_classes: 0
|
||||
|
@ -40,7 +39,8 @@ module:
|
|||
migrate_plus: 0
|
||||
migrate_tools: 0
|
||||
node: 0
|
||||
opd_talks: 0
|
||||
opdavies_blog: 0
|
||||
opdavies_talks: 0
|
||||
options: 0
|
||||
page_cache: 0
|
||||
path: 0
|
||||
|
|
|
@ -8,7 +8,7 @@ dependencies:
|
|||
- system.menu.main
|
||||
module:
|
||||
- node
|
||||
- opd_talks
|
||||
- opdavies_talks
|
||||
- user
|
||||
id: talks
|
||||
label: Talks
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
services:
|
||||
Drupal\custom\EventSubscriber\UpdateTalkNodeBeforeSave:
|
||||
tags:
|
||||
- { name: event_subscriber }
|
||||
|
||||
Drupal\custom\EventSubscriber\PushBlogPostToSocialMedia:
|
||||
tags:
|
||||
- { name: event_subscriber }
|
||||
|
||||
Drupal\custom\Repository\PostRepository:
|
||||
autowire: true
|
||||
|
||||
Drupal\custom\Service\TalkCounter:
|
||||
autowire: true
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Custom code for talks pages.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Drupal\opd_talks\Service\TalkDateUpdater;
|
||||
|
||||
/**
|
||||
* Implements hook_cron().
|
||||
*/
|
||||
function opd_talks_cron(): void {
|
||||
$dateUpdater = Drupal::service(TalkDateUpdater::class);
|
||||
$dateUpdater->__invoke();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_data_alter().
|
||||
*/
|
||||
function opd_talks_views_data_alter(array &$data): void {
|
||||
$data['node__field_event_date']['event_sort'] = [
|
||||
'title' => t('Custom event sort'),
|
||||
'group' => t('Content'),
|
||||
'help' => t('Sort events by past/future, then distance from now.'),
|
||||
'sort' => [
|
||||
'field' => 'field_event_date_value',
|
||||
'id' => 'event_sort',
|
||||
]
|
||||
];
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
services:
|
||||
Drupal\opd_talks\Repository\TalkRepository:
|
||||
autowire: true
|
||||
|
||||
Drupal\opd_talks\Service\TalkDateUpdater:
|
||||
autowire: true
|
|
@ -1,11 +1,11 @@
|
|||
services:
|
||||
Drupal\custom\Command\ExportBodyValuesForThemePurgingCommand:
|
||||
Drupal\opdavies_blog\Command\ExportBodyValuesForThemePurgingCommand:
|
||||
arguments: ['@database']
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: drush.command }
|
||||
|
||||
Drupal\custom\Command\FormatTagNamesCommand:
|
||||
Drupal\opdavies_blog\Command\FormatTagNamesCommand:
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: drush.command }
|
|
@ -12,7 +12,7 @@ use Drupal\discoverable_entity_bundle_classes\Storage\Node\NodeStorage;
|
|||
/**
|
||||
* Implements hook_entity_type_build().
|
||||
*/
|
||||
function custom_entity_type_build(array &$entityTypes): void {
|
||||
function opdavies_blog_entity_type_build(array &$entityTypes): void {
|
||||
/** @var \Drupal\Core\Entity\EntityTypeInterface[] $entityTypes */
|
||||
if (isset($entityTypes['node'])) {
|
||||
$entityTypes['node']->setStorageClass(NodeStorage::class);
|
|
@ -13,7 +13,7 @@ use Drupal\node\NodeInterface;
|
|||
/**
|
||||
* Implements hook_node_links_alter().
|
||||
*/
|
||||
function custom_node_links_alter(array &$links, NodeInterface $node): void {
|
||||
function opdavies_blog_node_links_alter(array &$links, NodeInterface $node): void {
|
||||
if (!method_exists($node, 'getExternalLink')) {
|
||||
return;
|
||||
}
|
|
@ -10,7 +10,7 @@ declare(strict_types=1);
|
|||
/**
|
||||
* Implements hook_preprocess_HOOK().
|
||||
*/
|
||||
function custom_preprocess_block(array &$variables): void {
|
||||
function opdavies_blog_preprocess_block(array &$variables): void {
|
||||
// Add the 'markup' class to blocks.
|
||||
if (in_array($variables['plugin_id'], ['views_block:featured_blog_posts-block_1'])) {
|
||||
$variables['attributes']['class'][] = 'markup';
|
|
@ -10,7 +10,7 @@ declare(strict_types=1);
|
|||
/**
|
||||
* Implements hook_preprocess_HOOK().
|
||||
*/
|
||||
function custom_preprocess_node(array &$variables): void {
|
||||
function opdavies_blog_preprocess_node(array &$variables): void {
|
||||
if (!method_exists($variables['node'], 'getExternalLink')) {
|
||||
return;
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
name: Oliver Davies custom module
|
||||
name: Oliver Davies blog
|
||||
type: module
|
||||
core_version_requirement: ^8 || ^9
|
||||
package: Custom
|
||||
dependencies:
|
||||
- drupal:node
|
||||
- discoverable_entity_bundle_classes:discoverable_entity_bundle_classes
|
||||
- hook_event_dispatcher:hook_event_dispatcher
|
||||
- paragraphs:paragraphs
|
||||
package: Custom
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Drupal\custom\Repository\PostRepository;
|
||||
use Drupal\opdavies_blog\Repository\PostRepository;
|
||||
|
||||
/**
|
||||
* Mark existing blog posts as sent to social media.
|
||||
*/
|
||||
function custom_update_8001(): void {
|
||||
function opdavies_blog_update_8001(): void {
|
||||
$posts = \Drupal::service(PostRepository::class)->getAll();
|
||||
|
||||
foreach ($posts as $post) {
|
|
@ -0,0 +1,7 @@
|
|||
services:
|
||||
Drupal\opdavies_blog\EventSubscriber\PushBlogPostToSocialMedia:
|
||||
tags:
|
||||
- { name: event_subscriber }
|
||||
|
||||
Drupal\opdavies_blog\Repository\PostRepository:
|
||||
autowire: true
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\custom\Command;
|
||||
namespace Drupal\opdavies_blog\Command;
|
||||
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Illuminate\Support\Collection;
|
|
@ -2,20 +2,13 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\custom\Command;
|
||||
namespace Drupal\opdavies_blog\Command;
|
||||
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drush\Commands\DrushCommands;
|
||||
|
||||
final class FormatTagNamesCommand extends DrushCommands {
|
||||
|
||||
/**
|
||||
* The taxonomy term storage.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityStorageInterface
|
||||
*/
|
||||
private $termStorage;
|
||||
|
||||
/**
|
||||
* A lookup table for new name overrides.
|
||||
*
|
||||
|
@ -90,6 +83,13 @@ final class FormatTagNamesCommand extends DrushCommands {
|
|||
'virtualhostx' => 'VirtualHostX',
|
||||
];
|
||||
|
||||
/**
|
||||
* The taxonomy term storage.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityStorageInterface
|
||||
*/
|
||||
private $termStorage;
|
||||
|
||||
public function __construct(EntityTypeManagerInterface $entityTypeManager) {
|
||||
parent::__construct();
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\custom\Entity\Node;
|
||||
namespace Drupal\opdavies_blog\Entity\Node;
|
||||
|
||||
use Drupal\discoverable_entity_bundle_classes\ContentEntityBundleInterface;
|
||||
use Drupal\node\Entity\Node;
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\custom\EventSubscriber;
|
||||
namespace Drupal\opdavies_blog\EventSubscriber;
|
||||
|
||||
use Drupal\custom\Entity\Node\Post;
|
||||
use Drupal\hook_event_dispatcher\Event\Entity\BaseEntityEvent;
|
||||
use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;
|
||||
use Drupal\opdavies_blog\Entity\Node\Post;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
final class PushBlogPostToSocialMedia implements EventSubscriberInterface {
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\custom\Repository;
|
||||
namespace Drupal\opdavies_blog\Repository;
|
||||
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
|
@ -4,9 +4,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Drupal\Tests\custom\Kernel\Entity\Node;
|
||||
|
||||
use Drupal\custom\Entity\Node\Post;
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\opdavies_blog\Entity\Node\Post;
|
||||
|
||||
final class PostTest extends EntityKernelTestBase {
|
||||
|
||||
|
@ -18,8 +18,8 @@ final class PostTest extends EntityKernelTestBase {
|
|||
'discoverable_entity_bundle_classes',
|
||||
|
||||
// Custom.
|
||||
'custom',
|
||||
'opdavies_posts_test',
|
||||
'opdavies_blog',
|
||||
'opdavies_blog_test',
|
||||
];
|
||||
|
||||
/** @test */
|
||||
|
@ -39,7 +39,7 @@ final class PostTest extends EntityKernelTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installConfig(['opdavies_posts_test']);
|
||||
$this->installConfig(['opdavies_blog_test']);
|
||||
}
|
||||
|
||||
}
|
|
@ -3,3 +3,5 @@ description: Custom code for talks pages.
|
|||
type: module
|
||||
core_version_requirement: ^8 || ^9
|
||||
package: Custom
|
||||
dependencies:
|
||||
- discoverable_entity_bundle_classes:discoverable_entity_bundle_classes
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Drupal\opd_talks\Repository\TalkRepository;
|
||||
use Drupal\opdavies_talks\Repository\TalkRepository;
|
||||
|
||||
/**
|
||||
* Set talk type for all existing talks.
|
||||
*/
|
||||
function opd_talks_update_8001(): void {
|
||||
function opdavies_talks_update_8001(): void {
|
||||
$talkRepository = \Drupal::service(TalkRepository::class);
|
||||
|
||||
foreach ($talkRepository->getAll() as $talk) {
|
45
web/modules/custom/opdavies_talks/opdavies_talks.module
Normal file
45
web/modules/custom/opdavies_talks/opdavies_talks.module
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Custom code for talks pages.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\discoverable_entity_bundle_classes\Storage\Node\NodeStorage;
|
||||
use Drupal\opdavies_talks\Service\TalkDateUpdater;
|
||||
|
||||
/**
|
||||
* Implements hook_cron().
|
||||
*/
|
||||
function opdavies_talks_cron(): void {
|
||||
$dateUpdater = Drupal::service(TalkDateUpdater::class);
|
||||
$dateUpdater->__invoke();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_data_alter().
|
||||
*/
|
||||
function opdavies_talks_views_data_alter(array &$data): void {
|
||||
$data['node__field_event_date']['event_sort'] = [
|
||||
'title' => t('Custom event sort'),
|
||||
'group' => t('Content'),
|
||||
'help' => t('Sort events by past/future, then distance from now.'),
|
||||
'sort' => [
|
||||
'field' => 'field_event_date_value',
|
||||
'id' => 'event_sort',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_entity_type_build().
|
||||
*/
|
||||
function opdavies_talks_entity_type_build(array &$entityTypes): void {
|
||||
/** @var EntityTypeInterface[] $entityTypes */
|
||||
if (isset($entityTypes['node'])) {
|
||||
$entityTypes['node']->setStorageClass(NodeStorage::class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
services:
|
||||
Drupal\opdavies_talks\EventSubscriber\UpdateTalkNodeBeforeSave:
|
||||
tags:
|
||||
- { name: event_subscriber }
|
||||
|
||||
Drupal\opdavies_talks\Repository\TalkRepository:
|
||||
autowire: true
|
||||
|
||||
Drupal\opdavies_talks\Service\TalkCounter:
|
||||
autowire: true
|
||||
|
||||
Drupal\opdavies_talks\Service\TalkDateUpdater:
|
||||
autowire: true
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\custom\Entity\Node;
|
||||
namespace Drupal\opdavies_talks\Entity\Node;
|
||||
|
||||
use Drupal\discoverable_entity_bundle_classes\ContentEntityBundleInterface;
|
||||
use Drupal\node\Entity\Node;
|
|
@ -2,13 +2,12 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\custom\EventSubscriber;
|
||||
namespace Drupal\opdavies_talks\EventSubscriber;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Drupal\custom\Entity\Node\Talk;
|
||||
use Drupal\custom\Entity\Paragraph\Event;
|
||||
use Drupal\hook_event_dispatcher\Event\Entity\BaseEntityEvent;
|
||||
use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;
|
||||
use Drupal\opdavies_talks\Entity\Node\Talk;
|
||||
use Drupal\paragraphs\ParagraphInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
|
@ -32,7 +31,7 @@ final class UpdateTalkNodeBeforeSave implements EventSubscriberInterface {
|
|||
return;
|
||||
}
|
||||
|
||||
/** @var \Drupal\custom\Entity\Node\Talk $talk */
|
||||
/** @var \Drupal\opdavies_blog\Entity\Node\Talk $talk */
|
||||
$talk = $event->getEntity();
|
||||
$this->reorderEvents($talk);
|
||||
$this->updateCreatedDate($talk);
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opd_talks\Plugin\views\sort;
|
||||
namespace Drupal\opdavies_talks\Plugin\views\sort;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Drupal\Component\Datetime\TimeInterface;
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opd_talks\Repository;
|
||||
namespace Drupal\opdavies_talks\Repository;
|
||||
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\custom\Entity\Node\Talk;
|
||||
use Drupal\opdavies_blog\Entity\Node\Talk;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
final class TalkRepository {
|
|
@ -2,12 +2,11 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\custom\Service;
|
||||
namespace Drupal\opdavies_talks\Service;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\custom\Entity\Node\Talk;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\paragraphs\ParagraphInterface;
|
||||
use Illuminate\Support\Collection;
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opd_talks\Service;
|
||||
namespace Drupal\opdavies_talks\Service;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Drupal\Component\Datetime\TimeInterface;
|
||||
use Drupal\custom\Entity\Node\Talk;
|
||||
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
|
||||
use Drupal\opd_talks\Repository\TalkRepository;
|
||||
use Drupal\opdavies_talks\Entity\Node\Talk;
|
||||
use Drupal\opdavies_talks\Repository\TalkRepository;
|
||||
use Drupal\paragraphs\ParagraphInterface;
|
||||
|
||||
final class TalkDateUpdater {
|
|
@ -7,7 +7,7 @@ dependencies:
|
|||
- system.menu.main
|
||||
module:
|
||||
- node
|
||||
- opd_talks
|
||||
- opdavies_talks
|
||||
- user
|
||||
id: talks
|
||||
label: Talks
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Drupal\Tests\custom\Kernel;
|
||||
namespace Drupal\Tests\opdavies_talks\Kernel;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Drupal\custom\Service\TalkCounter;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\opdavies_talks\Service\TalkCounter;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class CountPreviousTalksTest extends TalksTestBase {
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\Tests\custom\Kernel;
|
||||
namespace Drupal\Tests\opdavies_talks\Kernel;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Drupal\paragraphs\ParagraphInterface;
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\opd_talks\Kernel;
|
||||
namespace Drupal\Tests\opdavies_talks\Kernel;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Drupal\custom\Entity\Node\Talk;
|
||||
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\opd_talks\Service\TalkDateUpdater;
|
||||
use Drupal\Tests\custom\Kernel\TalksTestBase;
|
||||
use Drupal\opdavies_talks\Entity\Node\Talk;
|
||||
use Drupal\opdavies_talks\Service\TalkDateUpdater;
|
||||
|
||||
final class TalkEventDateTest extends TalksTestBase {
|
||||
|
|
@ -2,10 +2,9 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\Tests\opd_talks\Kernel;
|
||||
namespace Drupal\Tests\opdavies_talks\Kernel;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Drupal\Tests\custom\Kernel\TalksTestBase;
|
||||
use Drupal\views\ResultRow;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
@ -13,7 +12,7 @@ final class TalksPageSortTest extends TalksTestBase {
|
|||
|
||||
public static $modules = [
|
||||
'views',
|
||||
'opd_talks',
|
||||
'opdavies_talks',
|
||||
];
|
||||
|
||||
/**
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\Tests\custom\Kernel;
|
||||
namespace Drupal\Tests\opdavies_talks\Kernel;
|
||||
|
||||
use Drupal\custom\Entity\Node\Talk;
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\opdavies_talks\Entity\Node\Talk;
|
||||
use Drupal\paragraphs\Entity\Paragraph;
|
||||
use Drupal\paragraphs\ParagraphInterface;
|
||||
|
||||
|
@ -28,9 +28,8 @@ abstract class TalksTestBase extends EntityKernelTestBase {
|
|||
'hook_event_dispatcher',
|
||||
|
||||
// Custom.
|
||||
'custom',
|
||||
'custom_test',
|
||||
'opd_talks',
|
||||
'opdavies_talks',
|
||||
'opdavies_talks_test',
|
||||
];
|
||||
|
||||
protected $strictConfigSchema = FALSE;
|
||||
|
@ -59,7 +58,7 @@ abstract class TalksTestBase extends EntityKernelTestBase {
|
|||
$this->installEntitySchema('paragraph');
|
||||
$this->installSchema('node', ['node_access']);
|
||||
|
||||
$this->installConfig(['custom_test']);
|
||||
$this->installConfig(['opdavies_talks_test']);
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\Tests\custom\Kernel;
|
||||
namespace Drupal\Tests\opdavies_talks\Kernel;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
|
Loading…
Reference in a new issue