Skip to content

Commit

Permalink
VACMS-17885: Reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
omahane committed Jul 3, 2024
1 parent fcd1fa1 commit eed79a7
Showing 1 changed file with 16 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
/**
* VA.gov VBA Facility Event Subscriber.
*/
class VbaFacilitySubscriber implements EventSubscriberInterface
{
class VbaFacilitySubscriber implements EventSubscriberInterface {

use StringTranslationTrait;

Expand Down Expand Up @@ -75,8 +74,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array
{
public static function getSubscribedEvents(): array {
return [
EntityHookEvents::ENTITY_VIEW_ALTER => 'entityViewAlter',
'hook_event_dispatcher.form_node_vba_facility_edit_form.alter' => 'alterVbaFacilityNodeForm',
Expand All @@ -92,8 +90,7 @@ public static function getSubscribedEvents(): array
* @param \Drupal\core_event_dispatcher\Event\Entity\EntityViewAlterEvent $event
* The entity view alter service.
*/
public function entityViewAlter(EntityViewAlterEvent $event): void
{
public function entityViewAlter(EntityViewAlterEvent $event): void {
$this->appendServiceTermDescriptionToVbaFacilityService($event);
}

Expand All @@ -103,8 +100,7 @@ public function entityViewAlter(EntityViewAlterEvent $event): void
* @param \Drupal\core_event_dispatcher\Event\Entity\EntityViewAlterEvent $event
* The entity view alter service.
*/
public function appendServiceTermDescriptionToVbaFacilityService(EntityViewAlterEvent $event): void
{
public function appendServiceTermDescriptionToVbaFacilityService(EntityViewAlterEvent $event): void {
$display = $event->getDisplay();
if (($display->getTargetBundle() === 'vba_facility_service') && ($display->getOriginalMode() === 'full')) {
$build = &$event->getBuild();
Expand All @@ -119,11 +115,12 @@ public function appendServiceTermDescriptionToVbaFacilityService(EntityViewAlter
$referenced_term_content = $view_builder->view($referenced_term, 'vba_facility_service');
$description = $this->renderer->renderRoot($referenced_term_content);
}
} else {
}
else {
$description = new FormattableMarkup(
'<div><strong>Notice: The national service description was not found.</strong></div>',
[]
);
);
}
$formatted_markup = new FormattableMarkup($description, []);
$build['field_service_name_and_descripti']['#suffix'] = $formatted_markup;
Expand All @@ -136,8 +133,7 @@ public function appendServiceTermDescriptionToVbaFacilityService(EntityViewAlter
* @param \Drupal\core_event_dispatcher\Event\Form\FormIdAlterEvent $event
* The event.
*/
public function alterVbaFacilityNodeForm(FormIdAlterEvent $event): void
{
public function alterVbaFacilityNodeForm(FormIdAlterEvent $event): void {
$this->addStateManagementToBannerFields($event);
$this->changeBannerType($event);
$this->changeDismissibleOption($event);
Expand All @@ -152,8 +148,7 @@ public function alterVbaFacilityNodeForm(FormIdAlterEvent $event): void
* @param \Drupal\core_event_dispatcher\Event\Form\FormIdAlterEvent $event
* The event.
*/
protected function changeLinkNewService(FormIdAlterEvent $event): void
{
protected function changeLinkNewService(FormIdAlterEvent $event): void {
$form = &$event->getForm();

if (!isset($form["#fieldgroups"]["group_facility_services"])) {
Expand Down Expand Up @@ -186,8 +181,7 @@ protected function changeLinkNewService(FormIdAlterEvent $event): void
* @param \Drupal\core_event_dispatcher\Event\Form\FormIdAlterEvent $event
* The event.
*/
public function addStateManagementToBannerFields(FormIdAlterEvent $event)
{
public function addStateManagementToBannerFields(FormIdAlterEvent $event) {
$form = &$event->getForm();
$form['#attached']['library'][] = 'va_gov_vba_facility/set_banner_fields_to_required';
$selector = ':input[name="field_show_banner[value]"]';
Expand Down Expand Up @@ -239,8 +233,7 @@ public function addStateManagementToBannerFields(FormIdAlterEvent $event)
* @param \Drupal\core_event_dispatcher\Event\Form\FormIdAlterEvent $event
* The event.
*/
protected function changeBannerType(FormIdAlterEvent $event)
{
protected function changeBannerType(FormIdAlterEvent $event) {
// Add the '- Select a value -' option to replace '- None -'.
$form = &$event->getForm();
if (isset($form['field_alert_type']['widget']['#options']) && array_key_exists('_none', $form['field_alert_type']['widget']['#options'])) {
Expand All @@ -254,8 +247,7 @@ protected function changeBannerType(FormIdAlterEvent $event)
* @param \Drupal\core_event_dispatcher\Event\Form\FormIdAlterEvent $event
* The event.
*/
protected function changeDismissibleOption(FormIdAlterEvent $event)
{
protected function changeDismissibleOption(FormIdAlterEvent $event) {
// Remove N/A option, which is the result of not being a "required" field.
$form = &$event->getForm();
if (isset($form['field_dismissible_option']['widget']['#options']) && array_key_exists('_none', $form['field_dismissible_option']['widget']['#options'])) {
Expand All @@ -269,8 +261,7 @@ protected function changeDismissibleOption(FormIdAlterEvent $event)
* @param \Drupal\core_event_dispatcher\Event\Entity\EntityTypeAlterEvent $event
* The event for entityTypeAlter.
*/
public function entityTypeAlter(EntityTypeAlterEvent $event): void
{
public function entityTypeAlter(EntityTypeAlterEvent $event): void {
$entity_types = $event->getEntityTypes();
if (!empty($entity_types['node'])) {
$entity = $entity_types['node'];
Expand All @@ -284,8 +275,7 @@ public function entityTypeAlter(EntityTypeAlterEvent $event): void
* @param \Drupal\core_event_dispatcher\Event\Entity\EntityPresaveEvent $event
* The event.
*/
public function entityPresave(EntityPresaveEvent $event): void
{
public function entityPresave(EntityPresaveEvent $event): void {
$entity = $event->getEntity();
if ($entity instanceof NodeInterface) {
$this->clearBannerFields($entity);
Expand All @@ -298,8 +288,7 @@ public function entityPresave(EntityPresaveEvent $event): void
* @param \Drupal\Core\Entity\EntityInterface $entity
* Entity.
*/
protected function clearBannerFields(EntityInterface $entity): void
{
protected function clearBannerFields(EntityInterface $entity): void {
/** @var \Drupal\node\NodeInterface $entity */
if ($entity->bundle() === "vba_facility") {
if (
Expand All @@ -321,4 +310,5 @@ protected function clearBannerFields(EntityInterface $entity): void
}
}
}

}

0 comments on commit eed79a7

Please sign in to comment.