From 9b1a8fb3bee88c880625e3406f5c6d7a51d13fda Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 24 Aug 2020 09:26:44 +0100 Subject: [PATCH] Rename and re-organise custom modules - Rename `opd_talks` to `opdavies_talks` - Rename `custom` to `opdavies_blog` --- config/default/core.extension.yml | 4 +- config/default/views.view.talks.yml | 2 +- web/modules/custom/custom/custom.services.yml | 14 ------ web/modules/custom/opd_talks/opd_talks.module | 33 -------------- .../custom/opd_talks/opd_talks.services.yml | 6 --- .../config/schema/opdavies_blog.schema.yml} | 0 .../drush.services.yml | 4 +- .../hooks/entity_type/build.inc | 2 +- .../hooks/node_links/alter.inc | 2 +- .../hooks/preprocess/block.inc | 2 +- .../hooks/preprocess/node.inc | 2 +- .../opdavies_blog.info.yml} | 4 +- .../opdavies_blog.install} | 4 +- .../opdavies_blog.module} | 0 .../opdavies_blog/opdavies_blog.services.yml | 7 +++ ...ExportBodyValuesForThemePurgingCommand.php | 2 +- .../src/Command/FormatTagNamesCommand.php | 16 +++---- .../src/Entity/Node/Post.php | 2 +- .../PushBlogPostToSocialMedia.php | 4 +- .../src/Repository/PostRepository.php | 2 +- .../field.field.node.post.field_has_tweet.yml | 0 .../field.storage.node.field_has_tweet.yml | 0 .../config/install/node.type.post.yml | 0 .../opdavies_blog_test.info.yml} | 0 .../tests/src/Kernel/Entity/Node/PostTest.php | 8 ++-- .../opdavies_talks.info.yml} | 2 + .../opdavies_talks.install} | 4 +- .../opdavies_talks/opdavies_talks.module | 45 +++++++++++++++++++ .../opdavies_talks.services.yml | 13 ++++++ .../src/Entity/Node/Talk.php | 2 +- .../UpdateTalkNodeBeforeSave.php | 7 ++- .../src/Plugin/views/sort/Event.php | 2 +- .../src/Repository/TalkRepository.php | 4 +- .../src/Service/TalkCounter.php | 3 +- .../src/Service/TalkDateUpdater.php | 6 +-- ...field.field.node.talk.field_event_date.yml | 0 .../field.field.node.talk.field_events.yml | 0 ...field.field.paragraph.event.field_date.yml | 0 ...field.field.paragraph.event.field_name.yml | 0 .../field.storage.node.field_event_date.yml | 0 .../field.storage.node.field_events.yml | 0 .../field.storage.paragraph.field_date.yml | 0 .../field.storage.paragraph.field_name.yml | 0 .../config/install/node.type.talk.yml | 0 .../paragraphs.paragraphs_type.event.yml | 0 .../config/install/views.view.talks.yml | 2 +- .../opdavies_talks_test.info.yml} | 0 .../src/Kernel/CountPreviousTalksTest.php | 4 +- .../Kernel/EventsAreReorderedByDateTest.php | 2 +- .../tests/src/Kernel/TalkEventDateTest.php | 7 ++- .../tests/src/Kernel/TalksPageSortTest.php | 5 +-- .../tests/src/Kernel/TalksTestBase.php | 11 +++-- .../src/Kernel/UpdatesTalkCreatedDateTest.php | 2 +- 53 files changed, 125 insertions(+), 116 deletions(-) delete mode 100644 web/modules/custom/custom/custom.services.yml delete mode 100644 web/modules/custom/opd_talks/opd_talks.module delete mode 100644 web/modules/custom/opd_talks/opd_talks.services.yml rename web/modules/custom/{custom/config/schema/custom.schema.yml => opdavies_blog/config/schema/opdavies_blog.schema.yml} (100%) rename web/modules/custom/{custom => opdavies_blog}/drush.services.yml (56%) rename web/modules/custom/{custom => opdavies_blog}/hooks/entity_type/build.inc (84%) rename web/modules/custom/{custom => opdavies_blog}/hooks/node_links/alter.inc (88%) rename web/modules/custom/{custom => opdavies_blog}/hooks/preprocess/block.inc (82%) rename web/modules/custom/{custom => opdavies_blog}/hooks/preprocess/node.inc (82%) rename web/modules/custom/{custom/custom.info.yml => opdavies_blog/opdavies_blog.info.yml} (62%) rename web/modules/custom/{custom/custom.install => opdavies_blog/opdavies_blog.install} (73%) rename web/modules/custom/{custom/custom.module => opdavies_blog/opdavies_blog.module} (100%) create mode 100644 web/modules/custom/opdavies_blog/opdavies_blog.services.yml rename web/modules/custom/{custom => opdavies_blog}/src/Command/ExportBodyValuesForThemePurgingCommand.php (96%) rename web/modules/custom/{custom => opdavies_blog}/src/Command/FormatTagNamesCommand.php (98%) rename web/modules/custom/{custom => opdavies_blog}/src/Entity/Node/Post.php (95%) rename web/modules/custom/{custom => opdavies_blog}/src/EventSubscriber/PushBlogPostToSocialMedia.php (93%) rename web/modules/custom/{custom => opdavies_blog}/src/Repository/PostRepository.php (92%) rename web/modules/custom/{custom/tests/modules/opdavies_posts_test => opdavies_blog/tests/modules/opdavies_blog_test}/config/install/field.field.node.post.field_has_tweet.yml (100%) rename web/modules/custom/{custom/tests/modules/opdavies_posts_test => opdavies_blog/tests/modules/opdavies_blog_test}/config/install/field.storage.node.field_has_tweet.yml (100%) rename web/modules/custom/{custom/tests/modules/opdavies_posts_test => opdavies_blog/tests/modules/opdavies_blog_test}/config/install/node.type.post.yml (100%) rename web/modules/custom/{custom/tests/modules/opdavies_posts_test/opdavies_posts_test.info.yml => opdavies_blog/tests/modules/opdavies_blog_test/opdavies_blog_test.info.yml} (100%) rename web/modules/custom/{custom => opdavies_blog}/tests/src/Kernel/Entity/Node/PostTest.php (84%) rename web/modules/custom/{opd_talks/opd_talks.info.yml => opdavies_talks/opdavies_talks.info.yml} (60%) rename web/modules/custom/{opd_talks/opd_talks.install => opdavies_talks/opdavies_talks.install} (72%) create mode 100644 web/modules/custom/opdavies_talks/opdavies_talks.module create mode 100644 web/modules/custom/opdavies_talks/opdavies_talks.services.yml rename web/modules/custom/{custom => opdavies_talks}/src/Entity/Node/Talk.php (96%) rename web/modules/custom/{custom => opdavies_talks}/src/EventSubscriber/UpdateTalkNodeBeforeSave.php (90%) rename web/modules/custom/{opd_talks => opdavies_talks}/src/Plugin/views/sort/Event.php (96%) rename web/modules/custom/{opd_talks => opdavies_talks}/src/Repository/TalkRepository.php (89%) rename web/modules/custom/{custom => opdavies_talks}/src/Service/TalkCounter.php (93%) rename web/modules/custom/{opd_talks => opdavies_talks}/src/Service/TalkDateUpdater.php (92%) rename web/modules/custom/{custom/tests/modules/custom_test => opdavies_talks/tests/modules/opdavies_talks_test}/config/install/field.field.node.talk.field_event_date.yml (100%) rename web/modules/custom/{custom/tests/modules/custom_test => opdavies_talks/tests/modules/opdavies_talks_test}/config/install/field.field.node.talk.field_events.yml (100%) rename web/modules/custom/{custom/tests/modules/custom_test => opdavies_talks/tests/modules/opdavies_talks_test}/config/install/field.field.paragraph.event.field_date.yml (100%) rename web/modules/custom/{custom/tests/modules/custom_test => opdavies_talks/tests/modules/opdavies_talks_test}/config/install/field.field.paragraph.event.field_name.yml (100%) rename web/modules/custom/{custom/tests/modules/custom_test => opdavies_talks/tests/modules/opdavies_talks_test}/config/install/field.storage.node.field_event_date.yml (100%) rename web/modules/custom/{custom/tests/modules/custom_test => opdavies_talks/tests/modules/opdavies_talks_test}/config/install/field.storage.node.field_events.yml (100%) rename web/modules/custom/{custom/tests/modules/custom_test => opdavies_talks/tests/modules/opdavies_talks_test}/config/install/field.storage.paragraph.field_date.yml (100%) rename web/modules/custom/{custom/tests/modules/custom_test => opdavies_talks/tests/modules/opdavies_talks_test}/config/install/field.storage.paragraph.field_name.yml (100%) rename web/modules/custom/{custom/tests/modules/custom_test => opdavies_talks/tests/modules/opdavies_talks_test}/config/install/node.type.talk.yml (100%) rename web/modules/custom/{custom/tests/modules/custom_test => opdavies_talks/tests/modules/opdavies_talks_test}/config/install/paragraphs.paragraphs_type.event.yml (100%) rename web/modules/custom/{custom/tests/modules/custom_test => opdavies_talks/tests/modules/opdavies_talks_test}/config/install/views.view.talks.yml (99%) rename web/modules/custom/{custom/tests/modules/custom_test/custom_test.info.yml => opdavies_talks/tests/modules/opdavies_talks_test/opdavies_talks_test.info.yml} (100%) rename web/modules/custom/{custom => opdavies_talks}/tests/src/Kernel/CountPreviousTalksTest.php (93%) rename web/modules/custom/{custom => opdavies_talks}/tests/src/Kernel/EventsAreReorderedByDateTest.php (98%) rename web/modules/custom/{opd_talks => opdavies_talks}/tests/src/Kernel/TalkEventDateTest.php (94%) rename web/modules/custom/{opd_talks => opdavies_talks}/tests/src/Kernel/TalksPageSortTest.php (90%) rename web/modules/custom/{custom => opdavies_talks}/tests/src/Kernel/TalksTestBase.php (86%) rename web/modules/custom/{custom => opdavies_talks}/tests/src/Kernel/UpdatesTalkCreatedDateTest.php (96%) diff --git a/config/default/core.extension.yml b/config/default/core.extension.yml index 281bc3f..c9d0c66 100644 --- a/config/default/core.extension.yml +++ b/config/default/core.extension.yml @@ -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 diff --git a/config/default/views.view.talks.yml b/config/default/views.view.talks.yml index 4bd6586..c41eaea 100644 --- a/config/default/views.view.talks.yml +++ b/config/default/views.view.talks.yml @@ -8,7 +8,7 @@ dependencies: - system.menu.main module: - node - - opd_talks + - opdavies_talks - user id: talks label: Talks diff --git a/web/modules/custom/custom/custom.services.yml b/web/modules/custom/custom/custom.services.yml deleted file mode 100644 index 21c4bb3..0000000 --- a/web/modules/custom/custom/custom.services.yml +++ /dev/null @@ -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 diff --git a/web/modules/custom/opd_talks/opd_talks.module b/web/modules/custom/opd_talks/opd_talks.module deleted file mode 100644 index a10b3af..0000000 --- a/web/modules/custom/opd_talks/opd_talks.module +++ /dev/null @@ -1,33 +0,0 @@ -__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', - ] - ]; -} diff --git a/web/modules/custom/opd_talks/opd_talks.services.yml b/web/modules/custom/opd_talks/opd_talks.services.yml deleted file mode 100644 index 3b6a5cf..0000000 --- a/web/modules/custom/opd_talks/opd_talks.services.yml +++ /dev/null @@ -1,6 +0,0 @@ -services: - Drupal\opd_talks\Repository\TalkRepository: - autowire: true - - Drupal\opd_talks\Service\TalkDateUpdater: - autowire: true diff --git a/web/modules/custom/custom/config/schema/custom.schema.yml b/web/modules/custom/opdavies_blog/config/schema/opdavies_blog.schema.yml similarity index 100% rename from web/modules/custom/custom/config/schema/custom.schema.yml rename to web/modules/custom/opdavies_blog/config/schema/opdavies_blog.schema.yml diff --git a/web/modules/custom/custom/drush.services.yml b/web/modules/custom/opdavies_blog/drush.services.yml similarity index 56% rename from web/modules/custom/custom/drush.services.yml rename to web/modules/custom/opdavies_blog/drush.services.yml index 94ced42..8563617 100644 --- a/web/modules/custom/custom/drush.services.yml +++ b/web/modules/custom/opdavies_blog/drush.services.yml @@ -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 } diff --git a/web/modules/custom/custom/hooks/entity_type/build.inc b/web/modules/custom/opdavies_blog/hooks/entity_type/build.inc similarity index 84% rename from web/modules/custom/custom/hooks/entity_type/build.inc rename to web/modules/custom/opdavies_blog/hooks/entity_type/build.inc index 2a74b80..4978ce1 100644 --- a/web/modules/custom/custom/hooks/entity_type/build.inc +++ b/web/modules/custom/opdavies_blog/hooks/entity_type/build.inc @@ -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); diff --git a/web/modules/custom/custom/hooks/node_links/alter.inc b/web/modules/custom/opdavies_blog/hooks/node_links/alter.inc similarity index 88% rename from web/modules/custom/custom/hooks/node_links/alter.inc rename to web/modules/custom/opdavies_blog/hooks/node_links/alter.inc index e49cfa9..bc94afc 100644 --- a/web/modules/custom/custom/hooks/node_links/alter.inc +++ b/web/modules/custom/opdavies_blog/hooks/node_links/alter.inc @@ -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; } diff --git a/web/modules/custom/custom/hooks/preprocess/block.inc b/web/modules/custom/opdavies_blog/hooks/preprocess/block.inc similarity index 82% rename from web/modules/custom/custom/hooks/preprocess/block.inc rename to web/modules/custom/opdavies_blog/hooks/preprocess/block.inc index e4afdb0..f9032b3 100644 --- a/web/modules/custom/custom/hooks/preprocess/block.inc +++ b/web/modules/custom/opdavies_blog/hooks/preprocess/block.inc @@ -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'; diff --git a/web/modules/custom/custom/hooks/preprocess/node.inc b/web/modules/custom/opdavies_blog/hooks/preprocess/node.inc similarity index 82% rename from web/modules/custom/custom/hooks/preprocess/node.inc rename to web/modules/custom/opdavies_blog/hooks/preprocess/node.inc index aabde2b..5252158 100644 --- a/web/modules/custom/custom/hooks/preprocess/node.inc +++ b/web/modules/custom/opdavies_blog/hooks/preprocess/node.inc @@ -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; } diff --git a/web/modules/custom/custom/custom.info.yml b/web/modules/custom/opdavies_blog/opdavies_blog.info.yml similarity index 62% rename from web/modules/custom/custom/custom.info.yml rename to web/modules/custom/opdavies_blog/opdavies_blog.info.yml index 99f52cc..2469aa4 100644 --- a/web/modules/custom/custom/custom.info.yml +++ b/web/modules/custom/opdavies_blog/opdavies_blog.info.yml @@ -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 diff --git a/web/modules/custom/custom/custom.install b/web/modules/custom/opdavies_blog/opdavies_blog.install similarity index 73% rename from web/modules/custom/custom/custom.install rename to web/modules/custom/opdavies_blog/opdavies_blog.install index 7965eb7..789d9c2 100644 --- a/web/modules/custom/custom/custom.install +++ b/web/modules/custom/opdavies_blog/opdavies_blog.install @@ -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) { diff --git a/web/modules/custom/custom/custom.module b/web/modules/custom/opdavies_blog/opdavies_blog.module similarity index 100% rename from web/modules/custom/custom/custom.module rename to web/modules/custom/opdavies_blog/opdavies_blog.module diff --git a/web/modules/custom/opdavies_blog/opdavies_blog.services.yml b/web/modules/custom/opdavies_blog/opdavies_blog.services.yml new file mode 100644 index 0000000..2f627f8 --- /dev/null +++ b/web/modules/custom/opdavies_blog/opdavies_blog.services.yml @@ -0,0 +1,7 @@ +services: + Drupal\opdavies_blog\EventSubscriber\PushBlogPostToSocialMedia: + tags: + - { name: event_subscriber } + + Drupal\opdavies_blog\Repository\PostRepository: + autowire: true diff --git a/web/modules/custom/custom/src/Command/ExportBodyValuesForThemePurgingCommand.php b/web/modules/custom/opdavies_blog/src/Command/ExportBodyValuesForThemePurgingCommand.php similarity index 96% rename from web/modules/custom/custom/src/Command/ExportBodyValuesForThemePurgingCommand.php rename to web/modules/custom/opdavies_blog/src/Command/ExportBodyValuesForThemePurgingCommand.php index e33447b..24da584 100644 --- a/web/modules/custom/custom/src/Command/ExportBodyValuesForThemePurgingCommand.php +++ b/web/modules/custom/opdavies_blog/src/Command/ExportBodyValuesForThemePurgingCommand.php @@ -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; diff --git a/web/modules/custom/custom/src/Command/FormatTagNamesCommand.php b/web/modules/custom/opdavies_blog/src/Command/FormatTagNamesCommand.php similarity index 98% rename from web/modules/custom/custom/src/Command/FormatTagNamesCommand.php rename to web/modules/custom/opdavies_blog/src/Command/FormatTagNamesCommand.php index 7d83e92..29fe9e9 100644 --- a/web/modules/custom/custom/src/Command/FormatTagNamesCommand.php +++ b/web/modules/custom/opdavies_blog/src/Command/FormatTagNamesCommand.php @@ -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(); diff --git a/web/modules/custom/custom/src/Entity/Node/Post.php b/web/modules/custom/opdavies_blog/src/Entity/Node/Post.php similarity index 95% rename from web/modules/custom/custom/src/Entity/Node/Post.php rename to web/modules/custom/opdavies_blog/src/Entity/Node/Post.php index b119c3c..7744d17 100644 --- a/web/modules/custom/custom/src/Entity/Node/Post.php +++ b/web/modules/custom/opdavies_blog/src/Entity/Node/Post.php @@ -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; diff --git a/web/modules/custom/custom/src/EventSubscriber/PushBlogPostToSocialMedia.php b/web/modules/custom/opdavies_blog/src/EventSubscriber/PushBlogPostToSocialMedia.php similarity index 93% rename from web/modules/custom/custom/src/EventSubscriber/PushBlogPostToSocialMedia.php rename to web/modules/custom/opdavies_blog/src/EventSubscriber/PushBlogPostToSocialMedia.php index fd6581c..70a4097 100644 --- a/web/modules/custom/custom/src/EventSubscriber/PushBlogPostToSocialMedia.php +++ b/web/modules/custom/opdavies_blog/src/EventSubscriber/PushBlogPostToSocialMedia.php @@ -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 { diff --git a/web/modules/custom/custom/src/Repository/PostRepository.php b/web/modules/custom/opdavies_blog/src/Repository/PostRepository.php similarity index 92% rename from web/modules/custom/custom/src/Repository/PostRepository.php rename to web/modules/custom/opdavies_blog/src/Repository/PostRepository.php index 809c9ae..a76f480 100644 --- a/web/modules/custom/custom/src/Repository/PostRepository.php +++ b/web/modules/custom/opdavies_blog/src/Repository/PostRepository.php @@ -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; diff --git a/web/modules/custom/custom/tests/modules/opdavies_posts_test/config/install/field.field.node.post.field_has_tweet.yml b/web/modules/custom/opdavies_blog/tests/modules/opdavies_blog_test/config/install/field.field.node.post.field_has_tweet.yml similarity index 100% rename from web/modules/custom/custom/tests/modules/opdavies_posts_test/config/install/field.field.node.post.field_has_tweet.yml rename to web/modules/custom/opdavies_blog/tests/modules/opdavies_blog_test/config/install/field.field.node.post.field_has_tweet.yml diff --git a/web/modules/custom/custom/tests/modules/opdavies_posts_test/config/install/field.storage.node.field_has_tweet.yml b/web/modules/custom/opdavies_blog/tests/modules/opdavies_blog_test/config/install/field.storage.node.field_has_tweet.yml similarity index 100% rename from web/modules/custom/custom/tests/modules/opdavies_posts_test/config/install/field.storage.node.field_has_tweet.yml rename to web/modules/custom/opdavies_blog/tests/modules/opdavies_blog_test/config/install/field.storage.node.field_has_tweet.yml diff --git a/web/modules/custom/custom/tests/modules/opdavies_posts_test/config/install/node.type.post.yml b/web/modules/custom/opdavies_blog/tests/modules/opdavies_blog_test/config/install/node.type.post.yml similarity index 100% rename from web/modules/custom/custom/tests/modules/opdavies_posts_test/config/install/node.type.post.yml rename to web/modules/custom/opdavies_blog/tests/modules/opdavies_blog_test/config/install/node.type.post.yml diff --git a/web/modules/custom/custom/tests/modules/opdavies_posts_test/opdavies_posts_test.info.yml b/web/modules/custom/opdavies_blog/tests/modules/opdavies_blog_test/opdavies_blog_test.info.yml similarity index 100% rename from web/modules/custom/custom/tests/modules/opdavies_posts_test/opdavies_posts_test.info.yml rename to web/modules/custom/opdavies_blog/tests/modules/opdavies_blog_test/opdavies_blog_test.info.yml diff --git a/web/modules/custom/custom/tests/src/Kernel/Entity/Node/PostTest.php b/web/modules/custom/opdavies_blog/tests/src/Kernel/Entity/Node/PostTest.php similarity index 84% rename from web/modules/custom/custom/tests/src/Kernel/Entity/Node/PostTest.php rename to web/modules/custom/opdavies_blog/tests/src/Kernel/Entity/Node/PostTest.php index 665587b..9c3332b 100644 --- a/web/modules/custom/custom/tests/src/Kernel/Entity/Node/PostTest.php +++ b/web/modules/custom/opdavies_blog/tests/src/Kernel/Entity/Node/PostTest.php @@ -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']); } } diff --git a/web/modules/custom/opd_talks/opd_talks.info.yml b/web/modules/custom/opdavies_talks/opdavies_talks.info.yml similarity index 60% rename from web/modules/custom/opd_talks/opd_talks.info.yml rename to web/modules/custom/opdavies_talks/opdavies_talks.info.yml index a1b07e3..de2957f 100644 --- a/web/modules/custom/opd_talks/opd_talks.info.yml +++ b/web/modules/custom/opdavies_talks/opdavies_talks.info.yml @@ -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 diff --git a/web/modules/custom/opd_talks/opd_talks.install b/web/modules/custom/opdavies_talks/opdavies_talks.install similarity index 72% rename from web/modules/custom/opd_talks/opd_talks.install rename to web/modules/custom/opdavies_talks/opdavies_talks.install index 2db8d5a..9086955 100644 --- a/web/modules/custom/opd_talks/opd_talks.install +++ b/web/modules/custom/opdavies_talks/opdavies_talks.install @@ -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) { diff --git a/web/modules/custom/opdavies_talks/opdavies_talks.module b/web/modules/custom/opdavies_talks/opdavies_talks.module new file mode 100644 index 0000000..4bd265c --- /dev/null +++ b/web/modules/custom/opdavies_talks/opdavies_talks.module @@ -0,0 +1,45 @@ +__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); + } +} diff --git a/web/modules/custom/opdavies_talks/opdavies_talks.services.yml b/web/modules/custom/opdavies_talks/opdavies_talks.services.yml new file mode 100644 index 0000000..8533d2e --- /dev/null +++ b/web/modules/custom/opdavies_talks/opdavies_talks.services.yml @@ -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 diff --git a/web/modules/custom/custom/src/Entity/Node/Talk.php b/web/modules/custom/opdavies_talks/src/Entity/Node/Talk.php similarity index 96% rename from web/modules/custom/custom/src/Entity/Node/Talk.php rename to web/modules/custom/opdavies_talks/src/Entity/Node/Talk.php index 1eed5e1..7d3ec7a 100644 --- a/web/modules/custom/custom/src/Entity/Node/Talk.php +++ b/web/modules/custom/opdavies_talks/src/Entity/Node/Talk.php @@ -1,6 +1,6 @@ getEntity(); $this->reorderEvents($talk); $this->updateCreatedDate($talk); diff --git a/web/modules/custom/opd_talks/src/Plugin/views/sort/Event.php b/web/modules/custom/opdavies_talks/src/Plugin/views/sort/Event.php similarity index 96% rename from web/modules/custom/opd_talks/src/Plugin/views/sort/Event.php rename to web/modules/custom/opdavies_talks/src/Plugin/views/sort/Event.php index 48ad8b5..68bdc16 100644 --- a/web/modules/custom/opd_talks/src/Plugin/views/sort/Event.php +++ b/web/modules/custom/opdavies_talks/src/Plugin/views/sort/Event.php @@ -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; diff --git a/web/modules/custom/opd_talks/src/Repository/TalkRepository.php b/web/modules/custom/opdavies_talks/src/Repository/TalkRepository.php similarity index 89% rename from web/modules/custom/opd_talks/src/Repository/TalkRepository.php rename to web/modules/custom/opdavies_talks/src/Repository/TalkRepository.php index 9977e27..2fe40e5 100644 --- a/web/modules/custom/opd_talks/src/Repository/TalkRepository.php +++ b/web/modules/custom/opdavies_talks/src/Repository/TalkRepository.php @@ -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 { diff --git a/web/modules/custom/custom/src/Service/TalkCounter.php b/web/modules/custom/opdavies_talks/src/Service/TalkCounter.php similarity index 93% rename from web/modules/custom/custom/src/Service/TalkCounter.php rename to web/modules/custom/opdavies_talks/src/Service/TalkCounter.php index 933ab00..de522c8 100644 --- a/web/modules/custom/custom/src/Service/TalkCounter.php +++ b/web/modules/custom/opdavies_talks/src/Service/TalkCounter.php @@ -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; diff --git a/web/modules/custom/opd_talks/src/Service/TalkDateUpdater.php b/web/modules/custom/opdavies_talks/src/Service/TalkDateUpdater.php similarity index 92% rename from web/modules/custom/opd_talks/src/Service/TalkDateUpdater.php rename to web/modules/custom/opdavies_talks/src/Service/TalkDateUpdater.php index afddb44..7af638a 100644 --- a/web/modules/custom/opd_talks/src/Service/TalkDateUpdater.php +++ b/web/modules/custom/opdavies_talks/src/Service/TalkDateUpdater.php @@ -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 { diff --git a/web/modules/custom/custom/tests/modules/custom_test/config/install/field.field.node.talk.field_event_date.yml b/web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/field.field.node.talk.field_event_date.yml similarity index 100% rename from web/modules/custom/custom/tests/modules/custom_test/config/install/field.field.node.talk.field_event_date.yml rename to web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/field.field.node.talk.field_event_date.yml diff --git a/web/modules/custom/custom/tests/modules/custom_test/config/install/field.field.node.talk.field_events.yml b/web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/field.field.node.talk.field_events.yml similarity index 100% rename from web/modules/custom/custom/tests/modules/custom_test/config/install/field.field.node.talk.field_events.yml rename to web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/field.field.node.talk.field_events.yml diff --git a/web/modules/custom/custom/tests/modules/custom_test/config/install/field.field.paragraph.event.field_date.yml b/web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/field.field.paragraph.event.field_date.yml similarity index 100% rename from web/modules/custom/custom/tests/modules/custom_test/config/install/field.field.paragraph.event.field_date.yml rename to web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/field.field.paragraph.event.field_date.yml diff --git a/web/modules/custom/custom/tests/modules/custom_test/config/install/field.field.paragraph.event.field_name.yml b/web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/field.field.paragraph.event.field_name.yml similarity index 100% rename from web/modules/custom/custom/tests/modules/custom_test/config/install/field.field.paragraph.event.field_name.yml rename to web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/field.field.paragraph.event.field_name.yml diff --git a/web/modules/custom/custom/tests/modules/custom_test/config/install/field.storage.node.field_event_date.yml b/web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/field.storage.node.field_event_date.yml similarity index 100% rename from web/modules/custom/custom/tests/modules/custom_test/config/install/field.storage.node.field_event_date.yml rename to web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/field.storage.node.field_event_date.yml diff --git a/web/modules/custom/custom/tests/modules/custom_test/config/install/field.storage.node.field_events.yml b/web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/field.storage.node.field_events.yml similarity index 100% rename from web/modules/custom/custom/tests/modules/custom_test/config/install/field.storage.node.field_events.yml rename to web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/field.storage.node.field_events.yml diff --git a/web/modules/custom/custom/tests/modules/custom_test/config/install/field.storage.paragraph.field_date.yml b/web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/field.storage.paragraph.field_date.yml similarity index 100% rename from web/modules/custom/custom/tests/modules/custom_test/config/install/field.storage.paragraph.field_date.yml rename to web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/field.storage.paragraph.field_date.yml diff --git a/web/modules/custom/custom/tests/modules/custom_test/config/install/field.storage.paragraph.field_name.yml b/web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/field.storage.paragraph.field_name.yml similarity index 100% rename from web/modules/custom/custom/tests/modules/custom_test/config/install/field.storage.paragraph.field_name.yml rename to web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/field.storage.paragraph.field_name.yml diff --git a/web/modules/custom/custom/tests/modules/custom_test/config/install/node.type.talk.yml b/web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/node.type.talk.yml similarity index 100% rename from web/modules/custom/custom/tests/modules/custom_test/config/install/node.type.talk.yml rename to web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/node.type.talk.yml diff --git a/web/modules/custom/custom/tests/modules/custom_test/config/install/paragraphs.paragraphs_type.event.yml b/web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/paragraphs.paragraphs_type.event.yml similarity index 100% rename from web/modules/custom/custom/tests/modules/custom_test/config/install/paragraphs.paragraphs_type.event.yml rename to web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/paragraphs.paragraphs_type.event.yml diff --git a/web/modules/custom/custom/tests/modules/custom_test/config/install/views.view.talks.yml b/web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/views.view.talks.yml similarity index 99% rename from web/modules/custom/custom/tests/modules/custom_test/config/install/views.view.talks.yml rename to web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/views.view.talks.yml index b7fb867..8c564a3 100644 --- a/web/modules/custom/custom/tests/modules/custom_test/config/install/views.view.talks.yml +++ b/web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/config/install/views.view.talks.yml @@ -7,7 +7,7 @@ dependencies: - system.menu.main module: - node - - opd_talks + - opdavies_talks - user id: talks label: Talks diff --git a/web/modules/custom/custom/tests/modules/custom_test/custom_test.info.yml b/web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/opdavies_talks_test.info.yml similarity index 100% rename from web/modules/custom/custom/tests/modules/custom_test/custom_test.info.yml rename to web/modules/custom/opdavies_talks/tests/modules/opdavies_talks_test/opdavies_talks_test.info.yml diff --git a/web/modules/custom/custom/tests/src/Kernel/CountPreviousTalksTest.php b/web/modules/custom/opdavies_talks/tests/src/Kernel/CountPreviousTalksTest.php similarity index 93% rename from web/modules/custom/custom/tests/src/Kernel/CountPreviousTalksTest.php rename to web/modules/custom/opdavies_talks/tests/src/Kernel/CountPreviousTalksTest.php index 861f5fa..ea70f9d 100644 --- a/web/modules/custom/custom/tests/src/Kernel/CountPreviousTalksTest.php +++ b/web/modules/custom/opdavies_talks/tests/src/Kernel/CountPreviousTalksTest.php @@ -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 { diff --git a/web/modules/custom/custom/tests/src/Kernel/EventsAreReorderedByDateTest.php b/web/modules/custom/opdavies_talks/tests/src/Kernel/EventsAreReorderedByDateTest.php similarity index 98% rename from web/modules/custom/custom/tests/src/Kernel/EventsAreReorderedByDateTest.php rename to web/modules/custom/opdavies_talks/tests/src/Kernel/EventsAreReorderedByDateTest.php index 67ba828..7ba60c8 100644 --- a/web/modules/custom/custom/tests/src/Kernel/EventsAreReorderedByDateTest.php +++ b/web/modules/custom/opdavies_talks/tests/src/Kernel/EventsAreReorderedByDateTest.php @@ -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; diff --git a/web/modules/custom/opd_talks/tests/src/Kernel/TalkEventDateTest.php b/web/modules/custom/opdavies_talks/tests/src/Kernel/TalkEventDateTest.php similarity index 94% rename from web/modules/custom/opd_talks/tests/src/Kernel/TalkEventDateTest.php rename to web/modules/custom/opdavies_talks/tests/src/Kernel/TalkEventDateTest.php index 4fe674d..f1a714c 100644 --- a/web/modules/custom/opd_talks/tests/src/Kernel/TalkEventDateTest.php +++ b/web/modules/custom/opdavies_talks/tests/src/Kernel/TalkEventDateTest.php @@ -1,13 +1,12 @@ installEntitySchema('paragraph'); $this->installSchema('node', ['node_access']); - $this->installConfig(['custom_test']); + $this->installConfig(['opdavies_talks_test']); } } diff --git a/web/modules/custom/custom/tests/src/Kernel/UpdatesTalkCreatedDateTest.php b/web/modules/custom/opdavies_talks/tests/src/Kernel/UpdatesTalkCreatedDateTest.php similarity index 96% rename from web/modules/custom/custom/tests/src/Kernel/UpdatesTalkCreatedDateTest.php rename to web/modules/custom/opdavies_talks/tests/src/Kernel/UpdatesTalkCreatedDateTest.php index 3aaecde..74fe12c 100644 --- a/web/modules/custom/custom/tests/src/Kernel/UpdatesTalkCreatedDateTest.php +++ b/web/modules/custom/opdavies_talks/tests/src/Kernel/UpdatesTalkCreatedDateTest.php @@ -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;