Replace null parameters with their defaults.

@param array $parameters

@return array
768621
protected function replaceDefaults(array $parameters)
    {
        foreach ($parameters as $key => &$value) {
            $value = isset($value) ? $value : ArrayHelper::get($this->defaults, $key);
        }
        foreach ($this->defaults as $key => $value) {
            if (!isset($parameters[$key])) {
                $parameters[$key] = $value;
            }
        }

        return $parameters;
    }
1046085
public static function normalizeParameters(array $parameters) {
    $normalized = $parameters;

    $timezone = new \DateTimeZone(\Drupal::config('system.date')->get('timezone')['default']);

    // The old site has a habit to provide empty filter_date. Fix it here.
    if (empty($normalized['filter_date'])) {
      $date = DrupalDateTime::createFromTimestamp(REQUEST_TIME, $timezone);
      $normalized['filter_date'] = $date->format(self::$dateFilterFormat);
    }

    // Convert date parameter to timestamp.
    // Date parameter can by with leading zero or not.
    $origin_dtz = new \DateTimeZone(date_default_timezone_get());
    $remote_dtz = new \DateTimeZone(\Drupal::config('system.date')->get('timezone')['default']);
    $origin_dt = new \DateTime('now', $origin_dtz);
    $remote_dt = new \DateTime('now', $remote_dtz);
    $offset = $origin_dtz->getOffset($origin_dt) - $remote_dtz->getOffset($remote_dt);

    // Add offset. Function strtotime() uses default timezone.
    if ($timestamp = strtotime($normalized['filter_date'])) {
      $timestamp += $offset;
    }
    else {
      $date = DrupalDateTime::createFromTimestamp(REQUEST_TIME, $timezone);
      $timestamp = $date->format('U');
    }

    // Add timestamp.
    $normalized['filter_timestamp'] = $timestamp;

    // Finally, normalize filter_date.
    $date = DrupalDateTime::createFromTimestamp($normalized['filter_timestamp'], $timezone);
    $normalized['filter_date'] = $date->format(self::$dateFilterFormat);

    // Add default filter_length.
    if (!isset($normalized['filter_length'])) {
      $normalized['filter_length'] = 'day';
    }

    // Apply 'week' logic if class is selected.
    if (isset($parameters['class']) && is_numeric($parameters['class'])) {
      $normalized['filter_length'] = 'week';
      $normalized['view_mode'] = 'class';
      $normalized['groupex_class'] = 'groupex_table_class_individual';
    }

    return $normalized;
  }
88799
public function setParameters(array $parameters) {
		$this->parameters = [];
		foreach ($parameters as $parameter) {
			$this->addParameter($parameter);
		}

		return $this;
	}
723212
protected function proxyToEval(array $parameters)
    {
        return $this->command(
            'eval', [
            isset($parameters[0]) ? $parameters[0] : null,
            array_slice($parameters, 2),
            isset($parameters[1]) ? $parameters[1] : null,
            ]
        );
    }
657852
public function addDefaultBodyParameters($parameters)
    {
        foreach ($parameters as $name => $value) {
            $this->addDefaultBodyParameter($name, $value);
        }

        return $this;
    }
181245
public function addParameters(array $parameters)
    {
        self::$global_parameters = array_merge(self::$global_parameters, $parameters);

        return self::getInstance();
    }
370670
private function buildRequestParameters($parameters)
    {
        if (NULL === $parameters || empty($parameters)) {
            return null;
        }

        if (is_string($parameters)) {
            return $parameters;
        }

        $paramOut = '';
        foreach ($parameters as $key=>$value) {
            $paramOut .= $key.'=';
            if (is_array($value)){
                $paramOut .= join(',', $value);
            }else{
                $paramOut .= $value;
            }
            $paramOut .= '&';
        }

        return $paramOut;
    }
959839
protected function getFormParams($parameters = array())
    {
        $formParams = $parameters;

        if (!array_key_exists('api_output', $formParams)) {
            $formParams['api_output'] = Api::DEFAULT_OUTPUT;
        }

        if (!array_key_exists('api_key', $formParams)) {
            $formParams['api_key'] = $this->apiKey;
        }

        return $formParams;
    }
330785
protected function parseQueryParameters(array $parameters = [])
    {
        foreach ($parameters as $key => $candidate) {
            if (is_a($candidate, 'Tmdb\Model\Common\QueryParameter\QueryParameterInterface')) {
                $interfaces = class_implements($candidate);

                if (array_key_exists('Tmdb\Model\Common\QueryParameter\QueryParameterInterface', $interfaces)) {
                    unset($parameters[$key]);

                    $parameters[$candidate->getKey()] = $candidate->getValue();
                }
            }
        }

        return $parameters;
    }
290927
private function createRequestBody(array $parameters): array
    {
        $resources = [];
        foreach ($parameters as $key => $values) {
            if (!is_array($values)) {
                $values = [$values];
            }
            foreach ($values as $value) {
                $resources[] = [
                    'name' => $key,
                    'content' => $value,
                ];
            }
        }

        return $resources;
    }
189616
public static function cleanUpArray(array $parameters)
    {
        $cleanup = [];

        foreach ($parameters as $name => $value) {
            if (array_key_exists($name, self::CONFIRMATION_PROPERTIES)) {
                $cleanup[$name] = $value;
            }
        }

        return $cleanup;
    }
1300441
private function resolveParameters($parameters): array
    {
        // this will hold our dependencies information
        $dependencies = [];

        // Then loop through the parameters to see what is in the constructor.
        foreach ($parameters as $key => $parameter) {
            // Extract the class name to a dependency.
            $dependency = $parameter->getClass();

            // If it is null, then it is not a class, so we need to see if we've been
            // given a default value. If so, store the value for now.
            if (is_null($dependency)) {
                if ($parameter->isDefaultValueAvailable()) {
                    $dependencies[$key]['type'] = 'default';
                    $dependencies[$key]['value'] = $parameter->getDefaultValue();
                } else {
                    throw new ContainerException('Non class dependency ('.$parameter->name.') requires default value.');
                }
            }
            // Otherwise, it's a class dependency. We will store the class name
            // so that we can create it later.
            else {
                $dependencies[$key]['type'] = 'class';
                $dependencies[$key]['value'] = $dependency->name;
            }
        }

        return $dependencies;
    }
686903
public static function find($parameters = null)
    {
        $results = parent::find($parameters);
        $newResult = [];

        if ($results) {
            foreach ($results as $result) {
                $customFields = $result->getAllCustomFields();
                if (is_array($customFields)) {
                    //field the object
                    foreach ($customFields as $key => $value) {
                        $result->{$key} = $value;
                    }

                    $newResult[] = $result;
                }
            }

            unset($results);
        }
        return $newResult;
    }
681210
protected function implicitGetScope(array $parameters): ?array
    {
        $scope = $this->implicitReadStringValue($parameters, 'scope');

        return empty($scope) === false ? explode(' ', $scope) : null;
    }
1023385
private function parameters($parameters): array
    {
        $values = (!is_array($parameters)) ? [$parameters] : $parameters;

        $strings = [];

        foreach ($values as $value) {
            $strings[] = self::make($value, $this->encoding);
        }

        return $strings;
    }
1252940
public function setParametersAttribute(array $parameters)
    {
        $defaultParameters = $this->getDefaultParameters();
        $this->attributes['parameters'] = json_encode(
            array_merge($defaultParameters, $parameters)
        );
    }
141298
protected function mergeParametersDefaults(array $criteriaParameters, array $parameters)
    {
        $tmp = [];
        foreach ($criteriaParameters as $cpValues) {
            $tmp = $this->collectionMergeDefault($tmp, $cpValues);
        }

        $parameters = $this->collectionMergeDefault($tmp, $parameters);

        return $parameters;
    }