You are here

private function Filter::parseYaml in Access Filter 8

Parses YAML string.

Parameters

string $string: The YAML string to parse.

bool $safe: Indicates to return safe value.

Return value

mixed An parsed array if succeeded. On failure, empty array if $safe is TRUE or FALSE otherwise.

1 call to Filter::parseYaml()
Filter::parse in src/Entity/Filter.php
Parses YAML serialized properties.

File

src/Entity/Filter.php, line 180

Class

Filter
Defines the Filter entity.

Namespace

Drupal\access_filter\Entity

Code

private function parseYaml($string, $safe = TRUE) {
  $parsed = NULL;
  if ($string !== NULL) {
    $parser = new Parser();
    try {
      $parsed = $parser
        ->parse($string);
    } catch (\Exception $e) {
    }
  }
  if ($parsed === NULL) {
    if ($safe) {
      $parsed = [];
    }
    else {
      $parsed = FALSE;
    }
  }
  return $parsed;
}