projet-normandie / page-bundle
Normandie PageBundle
Installs: 223
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^8.3
- a2lix/translation-form-bundle: ^3.2
- api-platform/doctrine-orm: ^4.0
- api-platform/symfony: ^4.0
- doctrine/orm: ^3.3
- gedmo/doctrine-extensions: ^3.11
- sonata-project/admin-bundle: ^4.0
- sonata-project/doctrine-orm-admin-bundle: ^4.0
- sonata-project/translation-bundle: ^3.0
- symfony/dependency-injection: ^6.4 | ^7.2
- symfony/intl: ^6.4 | ^7.2
- webmozart/assert: ^1.11
Requires (Dev)
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.10
- phpstan/phpstan-doctrine: ^1.3
- phpstan/phpstan-symfony: ^1.3
- squizlabs/php_codesniffer: ^3.7
- symfony/phpunit-bridge: ^6.4 | ^7.2
This package is auto-updated.
Last update: 2025-05-04 15:54:33 UTC
README
A Symfony bundle for managing pages with multi-language support, status management, and API Platform integration.
Features
- Page management with multi-language support (EN/FR) using A2lix Translation Bundle
- Page status management (PUBLIC/PRIVATE)
- Automatic slug generation using Gedmo extensions
- Integration with Sonata Admin for backend management
- API Platform support with read endpoints
- Rich text editor for page content
- Search functionality through API filters
Installation
- Install the bundle using composer:
composer require projet-normandie/page-bundle
- Enable the bundle in your
config/bundles.php
:
return [ // ... ProjetNormandie\PageBundle\ProjetNormandiePageBundle::class => ['all' => true], ];
- Update your database schema:
php bin/console doctrine:schema:update --force
Or create a migration:
php bin/console make:migration php bin/console doctrine:migrations:migrate
Configuration
Required Dependencies
This bundle requires the following dependencies:
- PHP ^8.3
- Symfony 6.4+ or 7.2+
- Doctrine ORM 3.3+
- A2lix Translation Form Bundle
- API Platform 4.0+
- Sonata Admin Bundle 4.0+
- Gedmo Doctrine Extensions
Database Tables
The bundle creates the following tables:
pnp_page
- Main page tablepnp_page_translation
- Page translations
API Endpoints
The bundle exposes the following API endpoints:
GET /api/pages
- Get collection of pagesGET /api/pages/{id}
- Get specific page- Filter by slug:
/api/pages?slug=my-page
Usage
Creating a Page
Via Sonata Admin
- Navigate to the Pages admin section
- Click "Add new"
- Fill in the page details:
- Name
- Status (PUBLIC/PRIVATE)
- Enabled (yes/no)
- Translations (title and text for each language)
Via Code
use ProjetNormandie\PageBundle\Entity\Page; use ProjetNormandie\PageBundle\ValueObject\PageStatus; $page = new Page(); $page->setName('My Page'); $page->setStatus(PageStatus::PUBLIC); $page->setEnabled(true); // Add translations $page->translate('en')->setTitle('English Title'); $page->translate('en')->setText('English content...'); $page->translate('fr')->setTitle('Titre Français'); $page->translate('fr')->setText('Contenu français...'); $entityManager->persist($page); $entityManager->flush();
Page Status
The bundle supports two page statuses:
PageStatus::PUBLIC
- Visible to all usersPageStatus::PRIVATE
- Not visible in public API
API Usage
Get all public pages
GET /api/pages
Response:
{ "@context": "/api/contexts/Page", "@id": "/api/pages", "@type": "hydra:Collection", "hydra:member": [ { "@id": "/api/pages/1", "@type": "Page", "id": 1, "slug": "my-page", "text": "Page content..." } ] }
Get page by slug
GET /api/pages?slug=my-page
Rich Text Editor
The bundle includes a custom form type RichTextEditorType
for editing page content with rich text capabilities.
Events
The bundle includes an entity listener that automatically updates the page's updatedAt
timestamp when translations are modified.
Internationalization
The bundle supports the following languages:
- English (en)
- French (fr)
Translation files are located in:
src/Resources/translations/messages.en.yml
src/Resources/translations/messages.fr.yml
Development
Running Tests
composer lint:phpcs composer lint:phpstan
License
This bundle is under the Apache-2.0 license. See the complete license in the bundle:
LICENSE
Credits
- Benard David - Developer
Support
For support, please open an issue in the GitHub repository.