Skip to content

Commit

Permalink
Fix level 1 phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
paul121 committed Jan 7, 2025
1 parent 09416e7 commit 17abcea
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion farm_rothamsted.module
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function farm_rothamsted_form_alter(&$form, FormStateInterface $form_state, $for
function farm_rothamsted_asset_form_move_submit(array &$form, FormStateInterface $form_state) {

// Get the asset.
/** @var \Drupal\asset\Entity\AssetInterface $asset */
/** @var \Drupal\asset\Entity\AssetInterface | NULL $asset */
$asset = $form_state->getFormObject()->getEntity();
if (empty($asset)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,15 +739,18 @@ function farm_rothamsted_experiment_research_preprocess_rothamsted_research_enti

// Make sure this is a research entity.
if (isset($variables['theme_hook_original']) && isset($variables['elements']["#{$variables['theme_hook_original']}"])) {
$entity_id = $variables['theme_hook_original'];
$entity_type_id = $variables['theme_hook_original'];
}
if (empty($entity_type_id)) {
return;
}

// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
$variables['#attached']['library'][] = 'farm_ui_theme/layout';
farm_ui_theme_build_stacked_twocol_layout($variables, $entity_id);
farm_ui_theme_build_stacked_twocol_layout($variables, $entity_type_id);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function setEntity(EntityInterface $entity) {
$this->entity->set($field_name, NULL);
}
$this->entity->set('status', 'draft');
return $this;
}

/**
Expand All @@ -37,6 +38,7 @@ public function setSourceEntity(EntityInterface $entity) {
$status_notes = "This proposal was created by duplicating \"$source_name\". Please refer to that proposal for previous versions and a revision history. $source_link";
$this->entity->set('status_notes', $status_notes);
$this->entity->setRevisionLogMessage($status_notes);
return $this;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ protected function getEntityFieldDifferences(EntityInterface $entity, array $exc
$changed_field_message = "No field changes.";
if (!empty($changed_fields)) {
$field_labels = [];
foreach ($changed_fields ?? [] as $field) {
foreach ($changed_fields as $field) {
$field_labels[] = $entity->get($field)->getFieldDefinition()->getLabel();
}
$field_label_text = implode(', ', $field_labels);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ function farm_rothamsted_notification_entity_base_field_info(EntityTypeInterface
function farm_rothamsted_notification_mail($key, &$message, $params) {

// Get entity type information.
$entity_type_id = NULL;
$entity_type_label = NULL;
if (isset($params['entity_type_id']) && $entity_type_id = $params['entity_type_id']) {
$entity_type_manager = \Drupal::entityTypeManager();
$entity_type_label = $entity_type_manager->getDefinition($entity_type_id)->getLabel();
Expand All @@ -150,8 +152,8 @@ function farm_rothamsted_notification_mail($key, &$message, $params) {
$variables[$entity_type_id] = $entity;

// Set subject and body template.
$subject_template ??= $params['subject_template'];
$body_templates ??= $params['body_template'];
$subject_template = $params['subject_template'];
$body_templates = $params['body_template'];
break;

// Do not send the message.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ protected function getGroupMemberOptions(array $group_names, array $asset_types
$group_members = $this->groupMembership->getGroupMembers($groups);

// If specified, filter group members to a single asset type.
if (!empty($asset_type)) {
if (!empty($asset_types)) {
$group_members = array_filter($group_members, function (AssetInterface $asset) use ($asset_types) {
return in_array($asset->getEntityTypeId(), $asset_types);
});
Expand Down

0 comments on commit 17abcea

Please sign in to comment.