Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Kunstmaan Content Api Bundle Laravel Package

dreadlabs/kunstmaan-content-api-bundle

View on GitHub
Deep Wiki
Context7

Kunstmaan Content API

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?

  1. Load the bundle in your AppKernel

    // snip
    new DreadLabs\KunstmaanContentApiBundle\DreadLabsKunstmaanContentApiBundle()
    // snap
    
  2. Implement the Kunstmaan\NodeBundle\Controller\SlugActionInterface in your Page entities, implement the getControllerAction and point to the Bundle's 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
    }
    

    Important: Make sure, you are using the Controllers as Service notation.

  3. Implement the Bundle's DreadLabs\KunstmaanContentApiBundle\Api\SerializableInterface in order to point the Kunstmaan Node entity 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
    }
    
  4. 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 priorities argument of DreadLabs\KunstmaanContentApiBundle\EventListener\MediaTypeListener
  • add configuration of expected mediaType in DreadLabs\KunstmaanContentApiBundle\Api\Factory
  • add possibility to branch between prod and dev environments in DreadLabs/KunstmaanContentApiBundle/DependencyInjection/DreadLabsKunstmaanContentApiExtension
  • add possibility to override / configure framework.serializer.cache setting in DreadLabs/KunstmaanContentApiBundle/DependencyInjection/DreadLabsKunstmaanContentApiExtension
    • Q: isn't that already possible by just set / unset the configuration keys in app/config/config.yml?
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle