alengo / alengo-webspace-settings-bundle
Webspace Settings Bundle
Installs: 70
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 0
Open Issues: 0
Type:sulu-bundle
Requires
- php: ^8.2
- ext-iconv: *
- jackalope/jackalope-doctrine-dbal: ^1.10 || ^2.0
- sulu/sulu: ^2.6
- symfony/config: ^7.2
- symfony/dependency-injection: ^7.2
- symfony/framework-bundle: ^7.2
- symfony/http-foundation: ^7.2
- symfony/http-kernel: ^7.2
- symfony/serializer: ^7.2
- symfony/twig-bundle: ^7.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.9
- handcraftedinthealps/zendsearch: ^2.0
- phpstan/extension-installer: ^1.2
- phpstan/phpstan: ^1.4
- phpstan/phpstan-doctrine: ^1.2
- phpstan/phpstan-phpunit: ^1.0
- phpstan/phpstan-symfony: ^1.1
- phpstan/phpstan-webmozart-assert: ^1.0
- phpunit/phpunit: ^9.5
- rector/rector: ^1.0.3
- sulu/sulu-rector: ^1.0.0
- symfony/browser-kit: ^7.2
- symfony/console: ^7.2
- symfony/dotenv: ^7.2
- symfony/error-handler: ^7.2
- symfony/monolog-bundle: ^3.1
README
Sometimes you need to store values that are not directly related to a specific page or content type, but rather to the entire webspace. This Sulu bundle provides a way to manage such settings in a structured manner.
Requirements
- PHP 8.2
- Symfony >=7.2
Install the bundle
Execute the following composer command
composer require alengo/alengo-webspace-settings-bundle
Enable the bundle
Enable the bundle by adding it to the list of registered bundles in the config/bundles.php
file of your project:
return [ /* ... */ Alengo\Bundle\AlengoWebspaceSettingsBundle\AlengoWebspaceSettingsBundle::class => ['all' => true], ];
bin/console do:sch:up --force
Configure the Bundle
Set the following config in your routes_admin.yaml
alengo_webspace_settings_api: type: attribute resource: Alengo\Bundle\AlengoWebspaceSettingsBundle\Controller\Admin\WebspaceSettingsController prefix: /admin/api name_prefix: alengo_webspace_settings.
Make sure you've set the correct permissions in the Sulu backend for this bundle!
Settings > User Roles
Type Selection
Set the property types you want to provide.
config/packages/alengo_webspace_settings.yaml
alengo_webspace_settings: type_select: - 'blocks' - 'category' - 'categories' - 'checkbox' - 'collection' - 'collections' - 'contact' - 'contacts' - 'date' - 'dateTime' - 'event' - 'media' - 'medias' - 'account' - 'accounts' - 'page' - 'pages' - 'snippet' - 'snippets' - 'string' # default type - 'tags' - 'time' - 'textArea' - 'textEditor'
or execute the following command to copy it automatically:
bin/console webspace:settings:copy-config
Twig Extension
The bundle provides a Twig extension to render the webspace settings in your templates.
You can use the webspaceSettings
function to retrieve the settings for a specific webspace and typeKey.
{{ webspaceSettings('metaPublisher') }}
with localization
{{ webspaceSettings('metaTitleFallBack', app.request.locale) }}
Blocks
The bundle supports blocks for webspace settings. Copy the webspace_settings_blocks.xml in your project to the following path:
config/templates/settings/webspace_settings_blocks.xml
or execute the following command to copy it automatically:
bin/console webspace:settings:copy-config
Adjust the blocks as needed in your project.
Events
The bundle dispatches the following events:
WebspaceSettingsCreatedEvent
WebspaceSettingsUpdatedEvent
Create an event listener in your project to listen to these events and perform any necessary actions when webspace settings are created or updated.
It is recommended to use the settings type Event
.
Upgrade
Please read the UPGRADE.md file for upgrade instructions.