Skip to content

Commit

Permalink
Adjusted revalidations and removed usused field
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Nov 20, 2024
1 parent 653efa0 commit 327a5cb
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,6 @@ field_config:
enabled: true
sup_book_e_retailers:
enabled: true
sup_book_excerpts:
enabled: true
sup_book_image:
enabled: true
sup_book_imprint:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dependencies:
- field.field.node.sup_book.sup_book_copublisher_name
- field.field.node.sup_book.sup_book_digital_comp_link
- field.field.node.sup_book.sup_book_e_retailers
- field.field.node.sup_book.sup_book_excerpts
- field.field.node.sup_book.sup_book_image
- field.field.node.sup_book.sup_book_imprint
- field.field.node.sup_book.sup_book_isbn_13_alt
Expand Down Expand Up @@ -47,7 +46,6 @@ dependencies:
- datetime
- field_group
- inline_entity_form
- layout_paragraphs
- link
- media_library
- metatag
Expand Down Expand Up @@ -317,23 +315,6 @@ content:
placeholder_url: ''
placeholder_title: ''
third_party_settings: { }
sup_book_excerpts:
type: layout_paragraphs
weight: 28
region: content
settings:
view_mode: default
preview_view_mode: sup_form_preview
form_display_mode: default
nesting_depth: 0
require_layouts: 1
empty_message: ''
third_party_settings:
change_labels:
add_another: ''
field_label_overwrite: ''
hide_add_another: 0
force_single_cardinality: 0
sup_book_image:
type: media_library_widget
weight: 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dependencies:
- field.field.node.sup_book.sup_book_copublisher_name
- field.field.node.sup_book.sup_book_digital_comp_link
- field.field.node.sup_book.sup_book_e_retailers
- field.field.node.sup_book.sup_book_excerpts
- field.field.node.sup_book.sup_book_image
- field.field.node.sup_book.sup_book_imprint
- field.field.node.sup_book.sup_book_isbn_13_alt
Expand Down Expand Up @@ -44,7 +43,6 @@ dependencies:
module:
- datetime
- empty_fields
- entity_reference_revisions
- field_formatter_class
- field_label
- link
Expand Down Expand Up @@ -154,15 +152,6 @@ content:
third_party_settings: { }
weight: 33
region: content
sup_book_excerpts:
type: entity_reference_revisions_entity_view
label: above
settings:
view_mode: default
link: ''
third_party_settings: { }
weight: 30
region: content
sup_book_image:
type: media_thumbnail
label: above
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies:
- field.field.node.sup_book.sup_book_copublisher_name
- field.field.node.sup_book.sup_book_digital_comp_link
- field.field.node.sup_book.sup_book_e_retailers
- field.field.node.sup_book.sup_book_excerpts
- field.field.node.sup_book.sup_book_image
- field.field.node.sup_book.sup_book_imprint
- field.field.node.sup_book.sup_book_isbn_13_alt
Expand Down Expand Up @@ -107,7 +106,6 @@ hidden:
sup_book_copublisher_name: true
sup_book_digital_comp_link: true
sup_book_e_retailers: true
sup_book_excerpts: true
sup_book_image: true
sup_book_imprint: true
sup_book_intl_cart: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies:
- field.field.node.sup_book.sup_book_copublisher_name
- field.field.node.sup_book.sup_book_digital_comp_link
- field.field.node.sup_book.sup_book_e_retailers
- field.field.node.sup_book.sup_book_excerpts
- field.field.node.sup_book.sup_book_image
- field.field.node.sup_book.sup_book_imprint
- field.field.node.sup_book.sup_book_isbn_13_alt
Expand Down Expand Up @@ -138,7 +137,6 @@ hidden:
sup_book_copublisher_name: true
sup_book_digital_comp_link: true
sup_book_e_retailers: true
sup_book_excerpts: true
sup_book_imprint: true
sup_book_intl_cart: true
sup_book_isbn_13_alt: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies:
- field.field.node.sup_book.sup_book_copublisher_name
- field.field.node.sup_book.sup_book_digital_comp_link
- field.field.node.sup_book.sup_book_e_retailers
- field.field.node.sup_book.sup_book_excerpts
- field.field.node.sup_book.sup_book_image
- field.field.node.sup_book.sup_book_imprint
- field.field.node.sup_book.sup_book_isbn_13_alt
Expand Down Expand Up @@ -137,7 +136,6 @@ hidden:
sup_book_copublisher_name: true
sup_book_digital_comp_link: true
sup_book_e_retailers: true
sup_book_excerpts: true
sup_book_imprint: true
sup_book_intl_cart: true
sup_book_isbn_13_alt: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies:
- field.field.node.sup_book.sup_book_copublisher_name
- field.field.node.sup_book.sup_book_digital_comp_link
- field.field.node.sup_book.sup_book_e_retailers
- field.field.node.sup_book.sup_book_excerpts
- field.field.node.sup_book.sup_book_image
- field.field.node.sup_book.sup_book_imprint
- field.field.node.sup_book.sup_book_isbn_13_alt
Expand Down Expand Up @@ -124,7 +123,6 @@ hidden:
sup_book_copublisher_name: true
sup_book_digital_comp_link: true
sup_book_e_retailers: true
sup_book_excerpts: true
sup_book_imprint: true
sup_book_intl_cart: true
sup_book_isbn_13_alt: true
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
* config_export = {
* "id",
* "label",
* "description",
* "uuid",
* },
* )
Expand All @@ -63,4 +64,18 @@ final class PressEntityType extends ConfigEntityBundleBase {
*/
protected string $label;

/**
* A brief description of this entity type.
*
* @var string|null
*/
protected $description = NULL;

/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->description ?? '';
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use Drupal\core_event_dispatcher\Event\Entity\EntityCreateEvent;
use Drupal\media\MediaInterface;
use Drupal\migrate\Plugin\MigrationPluginManagerInterface;
use Drupal\next\Event\EntityActionEvent;
use Drupal\next\Event\EntityEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
Expand All @@ -27,25 +25,7 @@ public function __construct(protected readonly EntityTypeManagerInterface $entit
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array {
return [
EntityEvents::ENTITY_ACTION => ['onNextEntityAction', 10],
EntityHookEvents::ENTITY_CREATE => ['onEntityCreate'],
];
}

/**
* Change the entity url if the entity is a price object.
*
* @param \Drupal\next\Event\EntityActionEvent $event
* Next entity event.
*/
public function onNextEntityAction(EntityActionEvent $event) {
$entity = $event->getEntity();
if ($entity->getEntityTypeId() == 'press') {
$bundle = $entity->bundle();
$uuid = $entity->uuid();
$event->setEntityUrl("/tags/$bundle:$uuid");
}
return [EntityHookEvents::ENTITY_CREATE => ['onEntityCreate']];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public function form(array $form, FormStateInterface $form_state): array {
'#description' => $this->t('A unique machine-readable name for this press entity type. It must only contain lowercase letters, numbers, and underscores.'),
];

$form['description'] = [
'#title' => $this->t('Description'),
'#type' => 'textarea',
'#default_value' => $this->entity->getDescription(),
];

return $this->protectBundleIdElement($form);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,28 @@ function supress_helper_update_9007() {
$press_entity = \Drupal::entityTypeManager()->getDefinition('press');
\Drupal::entityDefinitionUpdateManager()->installEntityType($press_entity);
}

/**
* Create new next entity configs.
*/
function supress_helper_update_9008() {
$next_storage = \Drupal::entityTypeManager()
->getStorage('next_entity_type_config');
/** @var \Drupal\next\Entity\NextEntityTypeConfigInterface $entity */
$entity = $next_storage->create([
'id' => 'press.prices',
]);
$entity->setSiteResolver('site_selector')
->setSiteResolverConfiguration('site_selector', ['sites' => ['vercel' => 'vercel']])
->setRevalidator('path')
->setRevalidatorConfiguration('path', ['additional_paths' => '/tags/prices:[press:uuid]'])
->save();

if ($entity = $next_storage->load('node.sup_book_ancillary')) {
$entity->setRevalidatorConfiguration('path', [
'revalidate_page' => TRUE,
'additional_paths' => '/tags/excerpts:[node:sup_ancillary_book:entity:uuid]',
])
->save();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ protected function setUp(): void {
$this->eventSubscriber = new SuPressEventSubscriber($entity_type_manager, $migration_manager);
}

public function testNextEntityAction() {
$entity = $this->createMock(ContentEntityInterface::class);
$entity->method('getEntityTypeId')->willReturn('press');
$entity->method('uuid')->willReturn('foobarbaz');
$entity->method('bundle')->willReturn('foo');
$event = new EntityActionEvent($entity, 'action', [], '');
$this->eventSubscriber->onNextEntityAction($event);
$this->assertEquals('/tags/foo:foobarbaz', $event->getEntityUrl());
}

public function testEntityInsertEvent() {
$fieldItem = $this->createMock(FieldItemListInterface::class);
$fieldItem->method('count')->willReturn(1);
Expand Down

0 comments on commit 327a5cb

Please sign in to comment.