PHP code example of kaliop / content-decorator-bundle

1. Go to this page and download the library: Download kaliop/content-decorator-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kaliop / content-decorator-bundle example snippets


return [
    Kaliop\Bundle\ContentDecorator\KaliopContentDecoratorBundle::class => ['all' => true],
];



declare(strict_types=1);

namespace App\Model;

use Kaliop\ContentDecorator\Attribute\Decorator;
use Kaliop\Contracts\ContentDecorator\Model\ContentDecorator;

#[Decorator(repositoryClass: App\Repository\ArticleRepository::class, contentTypes: ['article'])]
final class Article extends ContentDecorator
{
}



declare(strict_types=1);

namespace App\Repository;

use Kaliop\ContentDecorator\Repository\AbstractContentRepository;

final class ArticleRepository extends AbstractContentRepository
{
    public function findByAuthorId(int $authorId): array
    {
        // Implement query logic
        return [];
    }
}

$repository = $contentDecoratorManager->getRepository(App\Model\Article::class);
$articles = $repository->findByAuthorId(42);

use Kaliop\ContentDecorator\Attribute\Cacheable;

#[Cacheable]
public function getExpensiveComputation(): array
{
    return [];
}