You are here

public static function NormalizeTrait::normalizeCallables in Markdown 8.2

Normalizes any callables provided so they can be stored in the database.

Parameters

array|\Traversable $iterable: An iterable value, passed by reference.

array $parents: Internal use only. Keeps track of recursion history. DO NOT USE.

Return value

array The normalized array.

Throws

\Drupal\markdown\Exception\MarkdownUnexpectedValueException When a callback provided isn't callable.

1 call to NormalizeTrait::normalizeCallables()
InstallablePluginManager::getRuntimeDefinitions in src/PluginManager/InstallablePluginManager.php
Retrieves the runtime definitions.

File

src/Traits/NormalizeTrait.php, line 79

Class

NormalizeTrait
Trait for providing normalization methods.

Namespace

Drupal\markdown\Traits

Code

public static function normalizeCallables(&$iterable, array $parents = []) {

  // Immediately return if object isn't traversable.
  if (!static::isTraversable($iterable)) {
    return $iterable;
  }
  foreach ($iterable as $key => $value) {

    // Determine if the value is callable.
    if (static::isCallable($value, $callable)) {
      if (!$callable) {
        throw new MarkdownUnexpectedValueException($value, $key, $parents, isset($e) ? $e : NULL, [
          'The callback "%s" is not publicly accessible.',
          'The callback "%s" set at %s is not publicly accessible.',
        ]);
      }
    }

    // Continue normalizing.
    $iterable[$key] = static::normalizeCallables($value, array_merge($parents, [
      $key,
    ]));
  }
  return $iterable;
}