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

Seven Manager Bundle Laravel Package

7rin0/seven-manager-bundle

View on GitHub
Deep Wiki
Context7
## 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
  1. Enable the Bundle: Add to config/bundles.php:

    SevenManagerBundle\SevenManagerBundle::class => ['all' => true],
    
  2. First Use Case:

    • Run migrations (if provided by the bundle or its dependencies):
      php bin/console doctrine:migrations:migrate
      
    • Access the Sonata Admin dashboard at /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.
  3. Key Entry Points:

    • Sonata Admin: /admin/app/seven_manager (check for custom routes in the bundle’s Resources/config/routing.yml).
    • CMF Routing: Verify cmf_routing is configured in config/packages/cmf_routing.yaml.
    • Twig Extensions: Look for custom Twig functions/filters in SevenManagerBundle/Resources/views/ or Twig/.

Implementation Patterns

1. Extending Content Types

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; }
}
  • Register in Sonata Admin:
    # config/packages/sonata_admin.yaml
    sonata_admin:
        options:
            models:
                App\Entity\CustomPage:
                    label: Custom Page
                    list: ~
                    form: ~
    

2. Customizing CMF Routing

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
  • Controller Example:
    // 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]);
        }
    }
    

3. Twig Integration

Use the bundle’s Twig extensions (if any) or create your own:

{# Example: Rendering a SevenManager block #}
{{ render_block(seven_manager_block) }}
  • Extend Twig Globals (in SevenManagerBundle/Resources/config/services.yaml):
    services:
        seven_manager.twig.extension:
            class: SevenManagerBundle\Twig\SevenExtension
            tags: ['twig.extension']
    

4. Event Listeners/Subscribers

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');
    }
}

5. Media Handling

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

Gotchas and Tips

Pitfalls

  1. No Standalone Usage:

    • This bundle requires Symfony CMF or SevenManager. Installing it in a vanilla Symfony project will break routing/admin features.
    • Fix: Use cmf-sandbox or SevenManager as a base.
  2. Missing Documentation:

    • The bundle’s README is minimal. Key configurations (e.g., sonata_admin mappings, cmf_routing rules) may need reverse-engineering from the SevenManager project.
    • Tip: Check SevenManagerBundle/Resources/config/ for default YAML/XML configs.
  3. Entity Inheritance Issues:

    • Extending SevenPage/SevenBlock may cause Doctrine mapping conflicts if the parent entity uses unsupported annotations (e.g., @ORM\Table without inheritance strategy).
    • Fix: Explicitly define inheritance in child entities:
      #[ORM\InheritanceType("JOINED")]
      #[ORM\DiscriminatorColumn(name="type", type="string")]
      #[ORM\DiscriminatorMap({"seven_page" => SevenPage::class, "custom_page" => CustomPage::class})]
      
  4. Routing Conflicts:

    • CMF routing can override Symfony’s default router. If dynamic routes fail:
      • Clear cache: php bin/console cache:clear.
      • Verify cmf_routing.dynamic is properly configured in config/packages/cmf_routing.yaml.
  5. Sonata Admin Permissions:

    • By default, the bundle may not expose all features to non-admin users. Override security in config/packages/security.yaml:
      access_control:
          - { path: ^/admin/seven_manager, roles: ROLE_USER }
      

Debugging Tips

  1. Enable CMF Debug:

    # config/packages/dev/cmf_routing.yaml
    cmf_routing:
        debug: true
    
    • Check generated routes at /_wdt/cmf_routing.
  2. Doctrine Logging:

    php bin/console doctrine:query-logging enable
    
    • Inspect SQL queries for entity hydration issues.
  3. Twig Debug:

    {% if app.debug %}
        {{ dump(seven_manager_block) }}
    {% endif %}
    

Extension Points

  1. Custom Content Types:

    • Override the bundle’s default content types by creating new entities and configuring Sonata Admin to use them exclusively.
  2. Block Templates:

    • Extend Twig templates in templates/SonataAdmin/CRUD/ or override bundle paths in twig/config.yaml:
      twig:
          paths:
              '%kernel.project_dir%/templates/seven_manager': SevenManager
      
  3. Media Providers:

    • Add custom providers to fos_media to handle uploads beyond the bundle’s defaults.
  4. Event Dispatching:

    • Listen for seven_manager.* events (if the bundle defines any) or extend existing CMF events (e.g., cmf.content.publish).
  5. API Integration:

    • Use Symfony’s serializer to expose 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']
  • Localization: If the bundle supports i18n, configure CMF’s routing.localization:
    cmf_routing:
        dynamic:
            localization:
                locales: [en, fr]
    
  • Testing: Use 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
    
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.
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle
dmstr/api-platform-utils-bundle
dmstr/api-configuration-bundle
chrisdev/ux-components
baks-dev/finances
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle