public static function Identifier::createFromArray in Markdown 8.2
Creates a new Identifier instance from an array of values.
Parameters
array $values: The values which contain an identifier, passed by reference.
string $property: Optional. The property which should contain the identifier.
Return value
static
1 call to Identifier::createFromArray()
- AnnotationObject::__construct in src/
Annotation/ AnnotationObject.php - AnnotationObject constructor.
File
- src/
Annotation/ Identifier.php, line 91
Class
- Identifier
- Creates an identifier for use in annotation objects.
Namespace
Drupal\markdown\AnnotationCode
public static function createFromArray(array &$values, $property = 'id') {
// Assign a random identifier if one wasn't provided. This is necessary
// so that a proper list of definitions can be created.
if (!isset($values[$property])) {
$values[$property] = Crypt::hashBase64(Crypt::randomBytesBase64() . serialize($values));
}
elseif ($values[$property] instanceof static) {
return $values[$property];
}
$values[$property] = new static($values[$property]);
return $values[$property];
}