Commit b823335b authored by Yas Naoi's avatar Yas Naoi
Browse files

Issue #3290795 by yas, sekinet, Ryo Yamashita, Xiaohua Guan, Masami: Refactor...

Issue #3290795 by yas, sekinet, Ryo Yamashita, Xiaohua Guan, Masami: Refactor the source code based on Drupal best practices (2) (Unused variable)
parent e757f1db
Loading
Loading
Loading
Loading
+5 −3
Changes for modules/cloud_service_providers/aws_cloud/aws_cloud.module: 5 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -2639,15 +2639,17 @@ function aws_cloud_form_cloud_config_aws_cloud_add_form_alter(array &$form, Form
  $form['#validate'][] = 'aws_cloud_form_cloud_config_aws_cloud_check_iam_permissions_validate';
  // Get all regions.
  $regions = \Drupal::service('aws_cloud.ec2')->getRegions();
  $region_names = preg_replace('/^.*(\(.*\))/', '$1', $regions);
  $region_names = array_values(preg_replace('/^.*(\(.*\))/', '$1', $regions));
  // Get the <max length of region code> + 1 (one white space)
  $max_region_name = 0;
  foreach ($region_names as $key => $region_name) {
  foreach ($region_names ?: [] as $region_name) {
    $max_region_name = max($max_region_name, strlen($region_name));
  }
  $max_region_code_length = CloudConfigInterface::MAX_NAME_LENGTH - ($max_region_name + 1);
  $max_name_length = CloudConfigInterface::MAX_NAME_LENGTH;
  $form['name']['widget'][0]['value']['#description'] = "Enter the name of the cloud service provider. The region name will be automatically added. The maximum number of characters of the name including the region name is {$max_name_length}.";
  $form['name']['widget'][0]['value']['#description'] = t('Enter the name of the cloud service provider. The region name will be automatically added. The maximum number of characters of the name including the region name is %max_name_length.', [
    '%max_name_length' => $max_name_length,
  ]);
  $form['name']['widget'][0]['value']['#maxlength'] = $max_region_code_length;

  aws_cloud_form_cloud_config_aws_cloud_form_common_alter($form, $form_state, $form_id);
+0 −1
Changes for modules/cloud_service_providers/aws_cloud/src/Plugin/Field/FieldFormatter/UserDataFormatter.php: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ class UserDataFormatter extends FormatterBase implements ContainerFactoryPluginI
  public function viewElements(FieldItemListInterface $items, $langcode): array {
    $elements = [];

    $entity = $items->getEntity();
    foreach ($items ?: [] as $delta => $item) {

      $user_data_decoded = base64_decode($item->value);
+0 −1
Changes for modules/cloud_service_providers/aws_cloud/src/Plugin/QueueWorker/AwsCloudUpdateIamPermissionsQueueWorker.php: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ class AwsCloudUpdateIamPermissionsQueueWorker extends CloudBaseUpdateResourcesQu
   * {@inheritdoc}
   */
  public function processItem($data): void {
    $cloud_context = $data['cloud_context'];
    $aws_cloud_method_name = $data['aws_cloud_method_name'];

    try {
+0 −6
Changes for modules/cloud_service_providers/aws_cloud/src/Plugin/cloud/launch_template/AwsCloudLaunchTemplatePlugin.php: 0 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -501,17 +501,11 @@ class AwsCloudLaunchTemplatePlugin extends CloudPluginBase implements CloudLaunc
    ];

    // Security groups.
    $htmls = [];
    $security_group_link = '';
    foreach ($entity->get('field_security_group') ?: [] as $group) {
      if ($group->entity !== NULL) {
        $group_id = $group->entity->getGroupId();

        $cloud_properties = [
          'type' => ['aws_cloud'],
          'cloud_context' => [$entity->getCloudContext()],
        ];
        $cloud_config = $this->getEntityObject('cloud_config', $cloud_properties);
        $sg_properties = [
          'group_id' => $group_id,
        ];
+0 −1
Changes for modules/cloud_service_providers/k8s/k8s.install: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -2795,7 +2795,6 @@ function k8s_update_8317(): void {
 * Uninstall fields about time scheduler from cloud_project.
 */
function k8s_update_8318(): void {
  $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $db = \Drupal::database();

  $entity_type = 'cloud_project';
Loading