7rin0/bigfoot-context-bundle
Installation
Add the bundle to your composer.json:
composer require 7rin0/bigfoot-context-bundle
Register the bundle in app/AppKernel.php:
new Sevenrin0\BigfootContextBundle\BigfootContextBundle(),
Configuration
Enable the bundle in config/packages/bigfoot_context.yaml (create if missing):
bigfoot_context:
enabled: true
default_context: "default"
contexts:
default:
theme: "BigfootDefaultThemeBundle"
options: { /* theme-specific options */ }
First Use Case Trigger context switching in a controller:
use Sevenrin0\BigfootContextBundle\Context\ContextManager;
public function switchContextAction(ContextManager $contextManager)
{
$contextManager->setContext('default');
// Theme and options are now applied
}
Resources/doc/ for usage guides (if available).src/Sevenrin0/BigfootContextBundle/Context/ContextManager.php).bigfoot.context.switch events for custom logic.Dynamic Context Switching Use middleware to set contexts based on user roles, locales, or other logic:
use Sevenrin0\BigfootContextBundle\Event\ContextSwitchEvent;
public function onContextSwitch(ContextSwitchEvent $event)
{
if ($event->getNewContext() === 'admin') {
$event->setTheme('BigfootAdminThemeBundle');
}
}
Theme-Specific Options Pass configuration per context:
contexts:
mobile:
theme: "BigfootMobileThemeBundle"
options:
compact_mode: true
hide_sidebar: false
Twig Integration Access current context in templates:
{% if app.request.attributes.get('_bigfoot_context') == 'dark' %}
<link rel="stylesheet" href="{{ asset('css/dark-theme.css') }}">
{% endif %}
ContextManager into services/controllers.bigfoot.context.switch events.bigfoot_context.twig_extension to generate context-aware asset paths.Missing Contexts
Ensure all contexts are defined in config/packages/bigfoot_context.yaml. Undefined contexts will throw InvalidArgumentException.
Theme Bundle Conflicts
Verify theme bundles (e.g., BigfootDefaultThemeBundle) are installed and registered in AppKernel.php.
Caching Issues Clear cache after changing contexts or themes:
php bin/console cache:clear
$contextManager->getCurrentContext();
bigfoot.context.switch events to trace context changes.Custom Context Providers
Implement Sevenrin0\BigfootContextBundle\Context\ContextProviderInterface for dynamic context resolution.
Theme Overrides
Extend default themes by creating custom bundles (e.g., AppBigfootThemeBundle).
Configuration Validation
Add Symfony validator constraints to bigfoot_context.yaml for stricter context definitions.
How can I help you explore Laravel packages today?