Skip to content

Commit

Permalink
PXBF-2039-phpstan-fixes: fix undefined method getEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
gchi25 committed Jan 24, 2025
1 parent 090dd56 commit d37e906
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
*/

use Drupal\Core\Database\Database;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
use Drupal\node\NodeInterface;
use Drupal\node\Entity\Node;

/**
Expand Down Expand Up @@ -482,8 +484,16 @@ function usagov_benefit_finder_content_form_node_bears_life_event_form_edit_form
function _usagov_benefit_finder_content_check_life_event_form_criteria_depth(array &$form, FormStateInterface $form_state) {
$error_flag = FALSE;
$criteria_depths = [];
$life_event_form_node = NULL;

$form_object = $form_state->getFormObject();
if ($form_object instanceof EntityForm) {
$entity = $form_object->getEntity();
if ($entity instanceof NodeInterface) {
$life_event_form_node = $entity;
}
}

$life_event_form_node = $form_state->getFormObject()->getEntity();
$sections = $life_event_form_node->get('field_b_sections_elg_criteria')->referencedEntities();

foreach ($sections as $section) {
Expand Down

0 comments on commit d37e906

Please sign in to comment.