PHP code example of chamber-orchestra / cms-bundle
1. Go to this page and download the library: Download chamber-orchestra/cms-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/ */
use ChamberOrchestra\CmsBundle\Controller\AbstractCrudController;
use ChamberOrchestra\CmsBundle\Controller\SupportsListOperation;
use ChamberOrchestra\CmsBundle\Controller\SupportsCreateOperation;
use ChamberOrchestra\CmsBundle\Controller\SupportsUpdateOperation;
use ChamberOrchestra\CmsBundle\Controller\SupportsDeleteOperation;
#[Route('/cms/articles', name: 'cms_article_')]
class ArticleController extends AbstractCrudController
{
use SupportsListOperation;
use SupportsCreateOperation;
use SupportsUpdateOperation;
use SupportsDeleteOperation;
public function __construct()
{
parent::__construct([
'class' => Article::class,
'form_class' => ArticleType::class,
'data_class' => ArticleDto::class,
]);
}
}
'fields' => [
// Simple list — field name only
'title',
'enabled',
// Named field with format options
'title' => ['format' => 'truncate:50'],
// Named field with sub-formats array
'createdAt' => ['format' => 'date:d.m.Y'],
// Transform callbacks — applied to each row
'fullName' => [fn($entity) => $entity->getFirst().' '.$entity->getLast()],
// Mixed — simple and configured in one array
'title',
'category' => ['format' => 'relation'],
'enabled',
],
class Article implements SoftDeleteInterface
{
private bool $deleted = false;
public function delete(): void { $this->deleted = true; }
public function isDeleted(): bool { return $this->deleted; }
}
class ArticleDto extends AbstractDto
{
public string $title = '';
public bool $enabled = true;
public ?string $slug = null;
public function __construct()
{
parent::__construct(Article::class);
}
}