Returns associative array of name and definition of style.
array Collection of styles.
Overrides StyleDiscoveryInterface::getStyles
public function getStyles() {
$cache_id = 'paragraphs_collection_style';
if ($this->stylesCollection !== NULL) {
return $this->stylesCollection;
}
else {
if ($cached = $this->cache
->get($cache_id)) {
$this->stylesCollection = $cached->data;
}
else {
$yaml_discovery = $this
->getYamlDiscovery();
$this->stylesCollection = [];
foreach ($yaml_discovery
->findAll() as $module => $styles) {
foreach ($styles as $style => $definition) {
if (empty($definition['title'])) {
throw new InvalidStyleException('The "title" of "' . $style . '" must be non-empty.');
}
$definition['title'] = $this
->t($definition['title']);
if (!empty($definition['description'])) {
$definition['description'] = $this
->t($definition['description']);
}
$this->stylesCollection[$style] = [
'name' => $style,
];
$this->stylesCollection[$style] += $definition + [
'libraries' => [],
];
}
}
$this->cache
->set($cache_id, $this->stylesCollection);
}
}
return $this->stylesCollection;
}