dreadlabs / kunstmaan-content-api-bundle
此包已被弃用且不再维护。未建议替代包。
将媒体类型监听器和内容API层集成到Kunstmaan CMS实例中。
0.1.2
2016-10-26 12:51 UTC
Requires
- kunstmaan/bundles-cms: ~3.6.0
- willdurand/negotiation: ~2.0.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ~1.12.1
- pdepend/pdepend: ~2.2.4
- phploc/phploc: ~3.0.1
- phpmd/phpmd: ~2.4.3
- phpunit/phpunit: ~4.4
- sebastian/phpcpd: ~2.0.4
- squizlabs/php_codesniffer: ~2.7.0
This package is not auto-updated.
Last update: 2020-01-24 16:19:11 UTC
README
这是什么?
此包配置Kunstmaan CMS实例,以便通过自定义API格式轻松提供内容。
它使用 willdurand/negotation
注入一个 media_type
的 Request
属性,用于将 Page
实体(Node
)序列化到特定的响应格式。
安装
composer install dreadlabs/kunstmaan-content-api-bundle
如何使用?
-
在您的
AppKernel
中加载此包// snip new DreadLabs\KunstmaanContentApiBundle\DreadLabsKunstmaanContentApiBundle() // snap
-
在您的
Page
实体中实现Kunstmaan\NodeBundle\Controller\SlugActionInterface
,实现getControllerAction
并指向包的ApiController
// src/Acme/WebsiteBundle/Entity/Pages/HomePage.php <?php class HomePage implements [...], SlugActionInterface { // snip /** * @return string * */ public function getControllerAction() { return 'dreadlabs_kunstmaan_content_api.controller:getAction'; } // snap }
重要:请确保您使用的是 将控制器作为服务 的表示法。
-
为了将Kunstmaan的
Node
实体指向API表示,实现包的DreadLabs\KunstmaanContentApiBundle\Api\SerializableInterface
// src/Acme/WebsiteBundle/Entity/Pages/HomePage.php <?php use Acme\WebsiteBundle\Api\Page\Home as ApiType; class HomePage implements [...], SerializableInterface { // snip /** * Returns the name of the API type (class). * * @return string */ public function getApiType() { return ApiType::class; } // snap }
-
实现API类型的序列化
// src/Acme/WebsiteBundle/Api/Page/Home.php <?php class Home { /** * @var string */ public $title; public function __construct($title) { $this->title = $title; } }
待办事项
- 为
DreadLabs\KunstmaanContentApiBundle\EventListener\MediaTypeListener
的priorities
参数添加配置选项 - 在
DreadLabs\KunstmaanContentApiBundle\Api\Factory
中配置预期的mediaType
- 在
DreadLabs/KunstmaanContentApiBundle/DependencyInjection/DreadLabsKunstmaanContentApiExtension
中添加在prod
和dev
环境之间分支的可能性 - 在
DreadLabs/KunstmaanContentApiBundle/DependencyInjection/DreadLabsKunstmaanContentApiExtension
中添加覆盖/配置framework.serializer.cache
设置的可能性- 问:这难道不是通过在
app/config/config.yml
中设置/取消设置配置键就可以实现吗?
- 问:这难道不是通过在