public function ContentLoaderBase::parseContent in YAML Content 8.2
Parse the given yaml content file into an array.
Parameters
string $content_file: A file name for the content file to be loaded.
Return value
array The parsed content array from the file.
Overrides ContentLoaderInterface::parseContent
1 call to ContentLoaderBase::parseContent()
- ContentLoaderBase::loadContentBatch in src/
ContentLoader/ ContentLoaderBase.php - Load a batch of content files.
File
- src/
ContentLoader/ ContentLoaderBase.php, line 101
Class
- ContentLoaderBase
- A base ContentLoader implementation to be extended by new content loaders.
Namespace
Drupal\yaml_content\ContentLoaderCode
public function parseContent($content_file) {
// @todo Handle parsing failures.
$this->contentFile = $this->path . '/content/' . $content_file;
$this->parsedContent = $this->parser
->decode(file_get_contents($this->contentFile));
// Never leave this as null, even on a failed parsing process.
// @todo Output a warning for empty content files or failed parsing.
$this->parsedContent = isset($this->parsedContent) ? $this->parsedContent : [];
// Dispatch the event notification.
$content_parsed_event = new ContentParsedEvent($this, $this->contentFile, $this->parsedContent);
$this->dispatcher
->dispatch(YamlContentEvents::CONTENT_PARSED, $content_parsed_event);
return $this->parsedContent;
}