Add daily email
This commit is contained in:
parent
6ce4abc64e
commit
59176d8b00
4 changed files with 179 additions and 0 deletions
|
@ -6484,5 +6484,14 @@
|
|||
],
|
||||
"path_alias.baec19d7-cb5e-4ba8-a181-15aa7cd85aee": [
|
||||
"node.0c66d8de-6dbd-4ab1-b40f-29276d7af5f1"
|
||||
],
|
||||
"node.75f502ee-38a8-45af-b4a4-c5abd82a4082": [
|
||||
"user.b8966985-d4b2-42a7-a319-2e94ccfbb849"
|
||||
],
|
||||
"path_alias.93e6c499-c547-4942-a6d1-e93520789f49": [
|
||||
"node.75f502ee-38a8-45af-b4a4-c5abd82a4082"
|
||||
],
|
||||
"redirect.714cbf00-2159-46b5-893e-67dd5da6013a": [
|
||||
"user.b8966985-d4b2-42a7-a319-2e94ccfbb849"
|
||||
]
|
||||
}
|
92
content/node.75f502ee-38a8-45af-b4a4-c5abd82a4082.json
Normal file
92
content/node.75f502ee-38a8-45af-b4a4-c5abd82a4082.json
Normal file
|
@ -0,0 +1,92 @@
|
|||
{
|
||||
"uuid": [
|
||||
{
|
||||
"value": "75f502ee-38a8-45af-b4a4-c5abd82a4082"
|
||||
}
|
||||
],
|
||||
"langcode": [
|
||||
{
|
||||
"value": "en"
|
||||
}
|
||||
],
|
||||
"type": [
|
||||
{
|
||||
"target_id": "daily_email",
|
||||
"target_type": "node_type",
|
||||
"target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7"
|
||||
}
|
||||
],
|
||||
"revision_timestamp": [
|
||||
{
|
||||
"value": "2025-06-20T23:06:28+00:00"
|
||||
}
|
||||
],
|
||||
"revision_uid": [
|
||||
{
|
||||
"target_type": "user",
|
||||
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
|
||||
}
|
||||
],
|
||||
"revision_log": [],
|
||||
"status": [
|
||||
{
|
||||
"value": true
|
||||
}
|
||||
],
|
||||
"uid": [
|
||||
{
|
||||
"target_type": "user",
|
||||
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
|
||||
}
|
||||
],
|
||||
"title": [
|
||||
{
|
||||
"value": "Drupal Bundle Classes"
|
||||
}
|
||||
],
|
||||
"created": [
|
||||
{
|
||||
"value": "2025-06-17T22:49:40+00:00"
|
||||
}
|
||||
],
|
||||
"changed": [
|
||||
{
|
||||
"value": "2025-06-20T23:06:28+00:00"
|
||||
}
|
||||
],
|
||||
"promote": [
|
||||
{
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"sticky": [
|
||||
{
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"default_langcode": [
|
||||
{
|
||||
"value": true
|
||||
}
|
||||
],
|
||||
"revision_translation_affected": [
|
||||
{
|
||||
"value": true
|
||||
}
|
||||
],
|
||||
"path": [
|
||||
{
|
||||
"alias": "\/daily\/2025\/06\/20\/drupal-bundle-classes",
|
||||
"langcode": "en"
|
||||
}
|
||||
],
|
||||
"body": [
|
||||
{
|
||||
"value": "As someone who writes a lot of custom Drupal modules, one of my favourite additions to Drupal has been Bundle Classes.\r\n\r\nWhat do they do?\r\n\r\nWhen writing Drupal modules, instead of relying on generic classes like `Node` or `Term`, you can create your own class for each entity type (e.g. each content type or taxonomy vocabulary).\r\n\r\nThis makes the code more readable and means you can add behaviour to each class by adding its own methods.\r\n\r\nYou can see how I've done this on my website:\r\n\r\n```php\r\nfunction opd_presentations_entity_bundle_info_alter(array &$bundles): void {\r\n if (isset($bundles['node'])) {\r\n $bundles['node'][Presentation::NODE_TYPE]['class'] = Presentation::class;\r\n }\r\n\r\n if (isset($bundles['paragraph'])) {\r\n $bundles['paragraph'][Event::PARAGRAPH_TYPE]['class'] = Event::class;\r\n }\r\n}\r\n```\r\n\r\nWithin my `opd_presentations.module` file, I override the classes Drupal uses for Presentation nodes and Event paragraph types.\r\n\r\nMy Presentation class looks like this:\r\n\r\n```php\r\nfinal class Presentation extends Node implements NodeInterface {\r\n\r\n public const NODE_TYPE = 'presentation';\r\n\r\n public function getEvents(): Events {\r\n return Events::fromEvents($this->get('field_events')->referencedEntities());\r\n }\r\n\r\n}\r\n```\r\n\r\nWith this, to get the events for any presentation, I can do something like `$presentation->getEvents()` and this code will be used.\r\n\r\nI use the same approach in my podcast module. The [code for my website is public][0] if you want to see other examples of how I'm using this approach.\r\n\r\nP.S. If you have questions about how to use this approach or other ways to improve your Drupal code, [book a one-on-one consulting call with me][1] and I'll help you get started.\r\n\r\n[0]: https:\/\/code.oliverdavies.uk\/opdavies\/oliverdavies.uk\/src\/commit\/8a480121d203ca6f51310f952b15cfa09080b034\/modules\r\n[1]: \/call",
|
||||
"format": "markdown",
|
||||
"processed": "<p>As someone who writes a lot of custom Drupal modules, one of my favourite additions to Drupal has been Bundle Classes.<\/p>\n<p>What do they do?<\/p>\n<p>When writing Drupal modules, instead of relying on generic classes like <code>Node<\/code> or <code>Term<\/code>, you can create your own class for each entity type (e.g. each content type or taxonomy vocabulary).<\/p>\n<p>This makes the code more readable and means you can add behaviour to each class by adding its own methods.<\/p>\n<p>You can see how I've done this on my website:<\/p>\n<pre><code>function opd_presentations_entity_bundle_info_alter(array &$bundles): void {\n if (isset($bundles['node'])) {\n $bundles['node'][Presentation::NODE_TYPE]['class'] = Presentation::class;\n }\n\n if (isset($bundles['paragraph'])) {\n $bundles['paragraph'][Event::PARAGRAPH_TYPE]['class'] = Event::class;\n }\n}\n<\/code><\/pre><p>Within my <code>opd_presentations.module<\/code> file, I override the classes Drupal uses for Presentation nodes and Event paragraph types.<\/p>\n<p>My Presentation class looks like this:<\/p>\n<pre><code>final class Presentation extends Node implements NodeInterface {\n\n public const NODE_TYPE = 'presentation';\n\n public function getEvents(): Events {\n return Events::fromEvents($this->get('field_events')->referencedEntities());\n }\n\n}\n<\/code><\/pre><p>With this, to get the events for any presentation, I can do something like <code>$presentation->getEvents()<\/code> and this code will be used.<\/p>\n<p>I use the same approach in my podcast module. The <a href=\"https:\/\/code.oliverdavies.uk\/opdavies\/oliverdavies.uk\/src\/commit\/8a480121d203ca6f51310f952b15cfa09080b034\/modules\">code for my website is public<\/a> if you want to see other examples of how I'm using this approach.<\/p>\n<p>P.S. If you have questions about how to use this approach or other ways to improve your Drupal code, <a href=\"http:\/\/localhost:8888\/call\">book a one-on-one consulting call with me<\/a> and I'll help you get started.<\/p>\n",
|
||||
"summary": ""
|
||||
}
|
||||
],
|
||||
"field_daily_email_cta": []
|
||||
}
|
27
content/path_alias.93e6c499-c547-4942-a6d1-e93520789f49.json
Normal file
27
content/path_alias.93e6c499-c547-4942-a6d1-e93520789f49.json
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"uuid": [
|
||||
{
|
||||
"value": "93e6c499-c547-4942-a6d1-e93520789f49"
|
||||
}
|
||||
],
|
||||
"langcode": [
|
||||
{
|
||||
"value": "en"
|
||||
}
|
||||
],
|
||||
"path": [
|
||||
{
|
||||
"value": "\/node\/75f502ee-38a8-45af-b4a4-c5abd82a4082"
|
||||
}
|
||||
],
|
||||
"alias": [
|
||||
{
|
||||
"value": "\/daily\/2025\/06\/17\/drupal-bundle-classes"
|
||||
}
|
||||
],
|
||||
"status": [
|
||||
{
|
||||
"value": true
|
||||
}
|
||||
]
|
||||
}
|
51
content/redirect.714cbf00-2159-46b5-893e-67dd5da6013a.json
Normal file
51
content/redirect.714cbf00-2159-46b5-893e-67dd5da6013a.json
Normal file
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"uuid": [
|
||||
{
|
||||
"value": "714cbf00-2159-46b5-893e-67dd5da6013a"
|
||||
}
|
||||
],
|
||||
"hash": [
|
||||
{
|
||||
"value": "b2wW6gKj9XwtvcqQ1htoelrHeduKAOBnXwHVG8nBD3U"
|
||||
}
|
||||
],
|
||||
"type": [
|
||||
{
|
||||
"value": "redirect"
|
||||
}
|
||||
],
|
||||
"uid": [
|
||||
{
|
||||
"target_type": "user",
|
||||
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
|
||||
}
|
||||
],
|
||||
"redirect_source": [
|
||||
{
|
||||
"path": "daily\/2025\/06\/20\/drupal-bundle-classes",
|
||||
"query": []
|
||||
}
|
||||
],
|
||||
"redirect_redirect": [
|
||||
{
|
||||
"uri": "internal:\/node\/47698",
|
||||
"title": null,
|
||||
"options": []
|
||||
}
|
||||
],
|
||||
"language": [
|
||||
{
|
||||
"value": "en"
|
||||
}
|
||||
],
|
||||
"status_code": [
|
||||
{
|
||||
"value": 301
|
||||
}
|
||||
],
|
||||
"created": [
|
||||
{
|
||||
"value": "2025-06-20T23:06:28+00:00"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue