OctoberCMS 在 Api/Web 服务中获取主题设置数据

OctoberCMS Get Theme Settings data in Api/Web service

我创建了一个运行良好的 OctoberCMS 主题。我现在和激活的 theme.yaml 是这样的。

theme.yaml

name: 5P Group
description: '5P Group OctoberCMS theme. A client website that contains preconfigured pages for static pages, a blog and client area..'
author: Technobrave
homepage: 'http://technobrave.com/'
code: ''
form:
    fields:
        site_logo:
            label: Site Logo
            comment: The website logo as it should appear on the front-end
            type: fileupload
            mode: image
            imageHeight: 32
            imageWidth: 443

如您所见,我添加了一个 站点徽标 标签,管理员可以通过该标签上传徽标,我会在前面显示它,我可以正常工作像这样在前面区域显示徽标。

menu.htm

{% if this.theme.site_logo  %}
<img src="{{ this.theme.site_logo.path }}" width="100%" height="auto"/>
{% else %}
<img src="{{ 'assets/images/logo.png'|theme }}" width="100%" height="auto"/>
{% endif %}

但问题是我也在创建一个 api,我想在那个 api 中做同样的事情。这就是我正在尝试的。

routes.php

    use System\Classes\SettingsManager;

    /* API to get Website Logo Dynamically Starts */

    Route::post('/getWebsiteLogo', function () 
    {
        $settings = Settings::instance();

        print_r($settings);



    });
    /* API to get Website Logo Dynamically Ends */

但是我说

时出错

Class 'Settings' not found

有人可以指导我或建议我如何完成同样的事情,或说明如何在我的 api 之一中获取动态网站徽标吗?

谢谢

好的伙计们,感谢您的支持..最终我就这样解决了。

routes.php

<?php 
use Cms\Classes\ComponentBase;
use RainLab\Pages\Classes\Router;
use Cms\Classes\Theme;

/* API to get Website Logo Dynamically Starts */
Route::post('/getWebsiteLogo', function () 
{
    $theme = Theme::getActiveTheme();
    $logo_url = '';
    if($theme->site_logo['attributes']['disk_name'])
    {
        echo $theme->site_logo->path; 
    }
}
?>

感谢您的帮助和支持。高度赞赏。