Bolt\Storage\Entity\ContentValuesTrait::getExcerpt PHP Method

getExcerpt() public method

Create an excerpt for the content.
public getExcerpt ( integer $length = 200, boolean $includeTitle = false, string | array $focus = null ) : Twig_Markup
$length integer
$includeTitle boolean
$focus string | array
return Twig_Markup
    public function getExcerpt($length = 200, $includeTitle = false, $focus = null)
    {
        $excerptParts = [];
        if (!empty($this->contenttype['fields'])) {
            foreach ($this->contenttype['fields'] as $key => $field) {
                // Skip empty fields, and fields used as 'title'.
                if (!isset($this->values[$key]) || in_array($key, $this->getTitleColumnName())) {
                    continue;
                }
                // add 'text', 'html' and 'textarea' fields.
                if (in_array($field['type'], ['text', 'html', 'textarea'])) {
                    $excerptParts[] = $this->values[$key];
                }
                // add 'markdown' field
                if ($field['type'] === 'markdown') {
                    $excerptParts[] = $this->app['markdown']->text($this->values[$key]);
                }
            }
        }
        $excerpter = new Excerpt(implode(' ', $excerptParts), $this->getTitle());
        $excerpt = $excerpter->getExcerpt($length, $includeTitle, $focus);
        return new \Twig_Markup($excerpt, 'UTF-8');
    }