## Getting Started
### Minimal Setup
1. **Prerequisite Check**: Ensure your project is either a Symfony CMF-based project (e.g., `cmf-sandbox`) or the [SevenManager](https://github.com/7rin0/SevenManager) project. This bundle is **not standalone**—it relies on CMF/Sonata’s core features.
```bash
composer require 7rin0/seven-manager-bundle
Enable the Bundle: Add to config/bundles.php:
SevenManagerBundle\SevenManagerBundle::class => ['all' => true],
First Use Case:
php bin/console doctrine:migrations:migrate
/admin to explore pre-configured content types (e.g., pages, blocks, media). The bundle likely extends or demonstrates CMF/Sonata’s Page, Block, or Media entities with custom logic.Key Entry Points:
/admin/app/seven_manager (check for custom routes in the bundle’s Resources/config/routing.yml).cmf_routing is configured in config/packages/cmf_routing.yaml.SevenManagerBundle/Resources/views/ or Twig/.The bundle likely provides base content types (e.g., SevenPage, SevenBlock) that you can extend. Example workflow:
// src/Entity/CustomPage.php
namespace App\Entity;
use SevenManagerBundle\Entity\SevenPage;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class CustomPage extends SevenPage
{
// Add custom fields/methods
#[ORM\Column]
private string $customField;
public function getCustomField(): string { return $this->customField; }
}
# config/packages/sonata_admin.yaml
sonata_admin:
options:
models:
App\Entity\CustomPage:
label: Custom Page
list: ~
form: ~
Leverage the bundle’s routing examples to create dynamic routes tied to your content:
# config/packages/cmf_routing.yaml
cmf_routing:
dynamic:
controllers_by_class:
App\Entity\CustomPage: App\Controller\CustomPageController
// src/Controller/CustomPageController.php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use SymfonyCMF\Bundle\Routing\RouteObjectInterface;
use SevenManagerBundle\Entity\SevenPage;
class CustomPageController extends AbstractController
{
public function showAction(RouteObjectInterface $routeObject): Response
{
/** @var SevenPage $page */
$page = $routeObject->getRouteObject();
return $this->render('custom_page/show.html.twig', ['page' => $page]);
}
}
Use the bundle’s Twig extensions (if any) or create your own:
{# Example: Rendering a SevenManager block #}
{{ render_block(seven_manager_block) }}
SevenManagerBundle/Resources/config/services.yaml):
services:
seven_manager.twig.extension:
class: SevenManagerBundle\Twig\SevenExtension
tags: ['twig.extension']
Hook into CMF/Sonata events (e.g., sonata.admin.event.configure):
// src/EventSubscriber/SonataSubscriber.php
namespace App\EventSubscriber;
use Sonata\AdminBundle\Event\ConfigureEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class SonataSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
'sonata.admin.event.configure' => 'onConfigure',
];
}
public function onConfigure(ConfigureEvent $event): void
{
$event->getAdminPool()->getAdminByAdminCode('seven_manager_page')->setTemplate('custom_template');
}
}
If the bundle includes media management (e.g., SevenMedia), integrate with FOSMediaBundle:
# config/packages/fos_media.yaml
fos_media:
cdns:
seven_manager:
options:
base_urls: ['%seven_manager_media_cdn%']
file_provider: seven_manager_media_provider
No Standalone Usage:
cmf-sandbox or SevenManager as a base.Missing Documentation:
sonata_admin mappings, cmf_routing rules) may need reverse-engineering from the SevenManager project.SevenManagerBundle/Resources/config/ for default YAML/XML configs.Entity Inheritance Issues:
SevenPage/SevenBlock may cause Doctrine mapping conflicts if the parent entity uses unsupported annotations (e.g., @ORM\Table without inheritance strategy).#[ORM\InheritanceType("JOINED")]
#[ORM\DiscriminatorColumn(name="type", type="string")]
#[ORM\DiscriminatorMap({"seven_page" => SevenPage::class, "custom_page" => CustomPage::class})]
Routing Conflicts:
php bin/console cache:clear.cmf_routing.dynamic is properly configured in config/packages/cmf_routing.yaml.Sonata Admin Permissions:
config/packages/security.yaml:
access_control:
- { path: ^/admin/seven_manager, roles: ROLE_USER }
Enable CMF Debug:
# config/packages/dev/cmf_routing.yaml
cmf_routing:
debug: true
/_wdt/cmf_routing.Doctrine Logging:
php bin/console doctrine:query-logging enable
Twig Debug:
{% if app.debug %}
{{ dump(seven_manager_block) }}
{% endif %}
Custom Content Types:
Block Templates:
templates/SonataAdmin/CRUD/ or override bundle paths in twig/config.yaml:
twig:
paths:
'%kernel.project_dir%/templates/seven_manager': SevenManager
Media Providers:
fos_media to handle uploads beyond the bundle’s defaults.Event Dispatching:
seven_manager.* events (if the bundle defines any) or extend existing CMF events (e.g., cmf.content.publish).API Integration:
SevenPage/SevenBlock entities via API Platform or custom controllers:
#[ORM\Entity]
#[ApiResource]
class CustomPage extends SevenPage {}
---
```markdown
## Additional Notes for Daily Use
- **Performance**: CMF/Sonata can be heavy. Use `sonata.block` caching for dynamic blocks:
```yaml
sonata_block:
default_contexts: [cms]
caches: ['array']
routing.localization:
cmf_routing:
dynamic:
localization:
locales: [en, fr]
sonata_admin fixtures or cmf_routing tests to verify content rendering:
// tests/Functional/CustomPageTest.php
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class CustomPageTest extends WebTestCase
{
public function testPageRendering(): void
{
$client = static::createClient();
$client->request('GET', '/custom-page');
$this->assert
How can I help you explore Laravel packages today?