dreadlabs / kunstmaan-content-api-bundle
Integrates a media type listener and a Content API layer into a Kunstmaan CMS instance.
Installs: 58
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/dreadlabs/kunstmaan-content-api-bundle
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
What does it do?
This bundle configures a Kunstmaan CMS instance in order to easily provide your content through a custom API format.
It uses willdurand/negotation in order to inject a Request attribute media_type which is
used to delegate to a serialization of a Page entity (Node) into a specific response format.
Installation
composer install dreadlabs/kunstmaan-content-api-bundle
How to use?
- 
Load the bundle in your AppKernel// snip new DreadLabs\KunstmaanContentApiBundle\DreadLabsKunstmaanContentApiBundle() // snap
- 
Implement the Kunstmaan\NodeBundle\Controller\SlugActionInterfacein yourPageentities, implement thegetControllerActionand point to the Bundle'sApiController:// 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 }Important: Make sure, you are using the Controllers as Service notation. 
- 
Implement the Bundle's DreadLabs\KunstmaanContentApiBundle\Api\SerializableInterfacein order to point the KunstmaanNodeentity to the API representation:// 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 }
- 
Implement an API type for serialization: // src/Acme/WebsiteBundle/Api/Page/Home.php <?php class Home { /** * @var string */ public $title; public function __construct($title) { $this->title = $title; } }Read the Serializer documentation and the Serializer cookbook to learn more about serialization of your API types. 
TODO
- add configuration possibility for the prioritiesargument ofDreadLabs\KunstmaanContentApiBundle\EventListener\MediaTypeListener
- add configuration of expected mediaTypeinDreadLabs\KunstmaanContentApiBundle\Api\Factory
- add possibility to branch between prodanddevenvironments inDreadLabs/KunstmaanContentApiBundle/DependencyInjection/DreadLabsKunstmaanContentApiExtension
- add possibility to override / configure framework.serializer.cachesetting inDreadLabs/KunstmaanContentApiBundle/DependencyInjection/DreadLabsKunstmaanContentApiExtension- Q: isn't that already possible by just set / unset the configuration keys in app/config/config.yml?
 
- Q: isn't that already possible by just set / unset the configuration keys in