lifestyle/sulu-template-api-bundle

安装: 322

依赖: 0

建议者: 0

安全: 0

类型:symfony-bundle

1.2.0 2019-04-11 09:44 UTC

This package is not auto-updated.

Last update: 2020-07-30 16:28:06 UTC


README

... 用于 Sulu CMS

需求

  • Sulu 版本 1.6
  • PHP7.2

安装

composer require lifestyle/sulu-template-api-bundle

1. 将以下代码添加到抽象内核 app/AbstractKernel.php

abstract class AbstractKernel extends SuluKernel
{
    public function registerBundles()
    {
        $bundles = [
            ...
            new LifeStyle\Sulu\TemplateApiBundle\LifeStyleSuluTemplateApiBundle(),
            ...
        ];
        ...
    }
    ...
}

2. 添加路由 app/config/website/routing.yml

life_style_api_route:
    resource: "@LifeStyleSuluTemplateApiBundle/Resources/config/routing.yml"
    prefix: /

3. 将配置添加到您的 app/config/config.yml

life_style_sulu_template_api:
    available_languages: ['de', 'en']
    header_template: '@LifestyleSuluTemplate/templates/includes/header/header.html.twig'
    footer_template: '@LifestyleSuluTemplate/templates/includes/footer/footer.html.twig'

4. 示例请求

GET http://your-domain.tld/{locale}/api/template.json

5. 示例响应

{
    "scriptTimeSec": 0.5397,
    "locale": "de",
    "webspace": "sulu-webspace-name",
    "headerHtml": "some html markup",  
    "footerHtml": "some html markup"
}

祝你好运,玩得开心!