Habari\Theme::theme_content PHP Метод

theme_content() публичный Метод

Display an object using a template designed for the type of object it is The $object is assigned into the theme using the $content template variable
public theme_content ( Theme $theme, object $object, string $context = null )
$theme Theme The theme used to display the object
$object object An object to display
$context string The context in which the object will be displayed
    public function theme_content($theme, $object, $context = null)
    {
        $fallback = array();
        $content_types = array();
        if ($object instanceof IsContent) {
            $content_types = Utils::single_array($object->content_type());
        }
        if (is_object($object)) {
            $content_types[] = strtolower(Utils::class_only($object));
        }
        $content_types[] = 'content';
        $content_types = array_flip($content_types);
        if (isset($context)) {
            foreach ($content_types as $type => $type_id) {
                $fallback[] = strtolower($context . '.' . $type);
            }
        }
        foreach ($content_types as $type => $type_id) {
            $fallback[] = strtolower($type);
        }
        if (isset($context)) {
            $fallback[] = strtolower($context);
        }
        $fallback = array_unique($fallback);
        $this->content = $object;
        if (isset($context)) {
            $this->context[] = $context;
        }
        $result = $this->display_fallback($fallback, 'fetch');
        if (isset($context)) {
            array_pop($this->context);
        }
        if ($result === false && DEBUG) {
            $fallback_list = implode(', ', $fallback);
            $result = '<p>' . _t('Content could not be displayed. One of the following templates - %s - has to be present in the active theme.', array($fallback_list)) . '</p>';
        }
        return $result;
    }