parent
79eb9bef0b
commit
165b6e8195
|
@ -22,6 +22,7 @@
|
||||||
"drupal/config_split": "^1.4",
|
"drupal/config_split": "^1.4",
|
||||||
"drupal/core-composer-scaffold": "^8.8",
|
"drupal/core-composer-scaffold": "^8.8",
|
||||||
"drupal/core-recommended": "^8.8",
|
"drupal/core-recommended": "^8.8",
|
||||||
|
"drupal/discoverable_entity_bundle_classes": "^1.0",
|
||||||
"drupal/google_analytics": "^2.4",
|
"drupal/google_analytics": "^2.4",
|
||||||
"drupal/honeypot": "^2.0",
|
"drupal/honeypot": "^2.0",
|
||||||
"drupal/hook_event_dispatcher": "^1.28",
|
"drupal/hook_event_dispatcher": "^1.28",
|
||||||
|
|
52
composer.lock
generated
52
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "45ee4839265d8526697b7d951fc351a2",
|
"content-hash": "94cf3f9b73a5a2ae184de25fd2a302b7",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "asm89/stack-cors",
|
"name": "asm89/stack-cors",
|
||||||
|
@ -2322,6 +2322,56 @@
|
||||||
"issues": "https://www.drupal.org/project/issues/ctools"
|
"issues": "https://www.drupal.org/project/issues/ctools"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "drupal/discoverable_entity_bundle_classes",
|
||||||
|
"version": "1.0.0-alpha2",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.drupalcode.org/project/discoverable_entity_bundle_classes.git",
|
||||||
|
"reference": "8.x-1.0-alpha2"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://ftp.drupal.org/files/projects/discoverable_entity_bundle_classes-8.x-1.0-alpha2.zip",
|
||||||
|
"reference": "8.x-1.0-alpha2",
|
||||||
|
"shasum": "c8f1e27475f3a1b7d7694949baaf337ed126c05a"
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"drupal/core": "~8.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"drupal/paragraphs": "*"
|
||||||
|
},
|
||||||
|
"type": "drupal-module",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-1.x": "1.x-dev"
|
||||||
|
},
|
||||||
|
"drupal": {
|
||||||
|
"version": "8.x-1.0-alpha2",
|
||||||
|
"datestamp": "1553798282",
|
||||||
|
"security-coverage": {
|
||||||
|
"status": "not-covered",
|
||||||
|
"message": "Project has not opted into security advisory coverage!"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packages.drupal.org/8/downloads",
|
||||||
|
"license": [
|
||||||
|
"GPL-2.0+"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "amcgowanca",
|
||||||
|
"homepage": "https://www.drupal.org/user/802138"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "An experimental approach for implementing entity classes for specific bundles.",
|
||||||
|
"homepage": "https://www.drupal.org/project/discoverable_entity_bundle_classes",
|
||||||
|
"support": {
|
||||||
|
"source": "https://git.drupalcode.org/project/discoverable_entity_bundle_classes"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "drupal/entity_reference_revisions",
|
"name": "drupal/entity_reference_revisions",
|
||||||
"version": "1.8.0",
|
"version": "1.8.0",
|
||||||
|
|
|
@ -14,6 +14,7 @@ module:
|
||||||
custom: 0
|
custom: 0
|
||||||
datetime: 0
|
datetime: 0
|
||||||
dblog: 0
|
dblog: 0
|
||||||
|
discoverable_entity_bundle_classes: 0
|
||||||
dynamic_page_cache: 0
|
dynamic_page_cache: 0
|
||||||
entity_reference_revisions: 0
|
entity_reference_revisions: 0
|
||||||
field: 0
|
field: 0
|
||||||
|
|
|
@ -7,14 +7,15 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Drupal\custom\Entity\Node;
|
use Drupal\discoverable_entity_bundle_classes\Storage\Node\NodeStorage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements hook_entity_type_build().
|
* Implements hook_entity_type_build().
|
||||||
*/
|
*/
|
||||||
function custom_entity_type_build(array &$entityTypes): void {
|
function custom_entity_type_build(array &$entityTypes): void {
|
||||||
|
/** @var \Drupal\Core\Entity\EntityTypeInterface[] $entityTypes */
|
||||||
if (isset($entityTypes['node'])) {
|
if (isset($entityTypes['node'])) {
|
||||||
$entityTypes['node']->setClass(Node::class);
|
$entityTypes['node']->setStorageClass(NodeStorage::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
25
web/modules/custom/custom/src/Entity/Node/Post.php
Normal file
25
web/modules/custom/custom/src/Entity/Node/Post.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Drupal\custom\Entity\Node;
|
||||||
|
|
||||||
|
use Drupal\node\Entity\Node;
|
||||||
|
use Drupal\discoverable_entity_bundle_classes\ContentEntityBundleInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines an blog post node class.
|
||||||
|
*
|
||||||
|
* @ContentEntityBundleClass(
|
||||||
|
* label = @Translation("Blog post"),
|
||||||
|
* entity_type = "node",
|
||||||
|
* bundle = "post"
|
||||||
|
* );
|
||||||
|
*/
|
||||||
|
class Post extends Node implements ContentEntityBundleInterface {
|
||||||
|
|
||||||
|
public function hasTweet(): bool {
|
||||||
|
return (bool) $this->get('field_has_tweet')->getString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ abstract class TalksTestBase extends EntityKernelTestBase {
|
||||||
'datetime',
|
'datetime',
|
||||||
|
|
||||||
// Contrib.
|
// Contrib.
|
||||||
|
'discoverable_entity_bundle_classes',
|
||||||
'entity_reference_revisions',
|
'entity_reference_revisions',
|
||||||
'paragraphs',
|
'paragraphs',
|
||||||
'hook_event_dispatcher',
|
'hook_event_dispatcher',
|
||||||
|
|
|
@ -5,20 +5,22 @@
|
||||||
* Functions to support theming in the Tailwind CSS theme.
|
* Functions to support theming in the Tailwind CSS theme.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Drupal\custom\Entity\Node\Post;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements hook_preprocess_HOOK().
|
* Implements hook_preprocess_HOOK().
|
||||||
*/
|
*/
|
||||||
function opdavies_preprocess_page(array &$variables): void {
|
function opdavies_preprocess_page(array &$variables): void {
|
||||||
/** @var \Drupal\Core\Entity\EntityInterface $node */
|
/** @var \Drupal\custom\Entity\Node\Post $node */
|
||||||
if (!$node = \Drupal::routeMatch()->getParameter('node')) {
|
if (!$node = $variables['node']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($node->getType() != 'post') {
|
if (!$node instanceof Post) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($node->get('field_has_tweet')->getString()) {
|
if ($node->hasTweet()) {
|
||||||
$variables['#attached']['library'][] = 'opdavies/twitter';
|
$variables['#attached']['library'][] = 'opdavies/twitter';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue