Installation:
composer require appventus/shortcuts-bundle:dev-master
Add to AppKernel.php:
new AppVentus\Awesome\ShortcutsBundle\AvAwesomeShortcutsBundle(),
Twig Configuration (Symfony 2.x):
# app/config/config.yml
twig:
form:
resources:
- 'AvAwesomeShortcutsBundle::fields.html.twig'
For Symfony 3.x+:
twig:
form_themes:
- 'AvAwesomeShortcutsBundle::fields.html.twig'
Load Assets (in your base template):
{% block stylesheets %}
{{ parent() }}
{{ asset('bundles/avawesomeshortcuts/css/datepicker.css') }}
{% endblock %}
{% block javascripts %}
{{ parent() }}
{{ asset('bundles/avawesomeshortcuts/js/bootstrap-datepicker.js') }}
{% endblock %}
Inject the ShortcutService in a controller to leverage common utilities:
use AppVentus\Awesome\ShortcutsBundle\Service\ShortcutService;
class MyController extends Controller
{
public function indexAction()
{
$shortcuts = $this->get('av.shortcuts');
$shortcuts->congrat('Operation successful!'); // Flash success message
return $this->render('...');
}
}
Flash Messages: Replace repetitive flash bag logic with shortcuts:
$this->get('av.shortcuts')->congrat('Success!');
$this->get('av.shortcuts')->scold('Error occurred!');
Form Error Handling: Convert form errors to a readable string for AJAX responses:
$formErrorService = $this->get('av.form_error_service');
$errors = $formErrorService->getRecursiveReadableErrors($form);
return new JsonResponse(['errors' => $errors]);
Email Shortcuts: Send emails with minimal boilerplate:
$shortcuts->createAndQueueMail(
'user@example.com',
'Welcome',
'email_template.html.twig',
['name' => 'John']
);
Redactor Integration:
Use the RedactorType for rich-text fields:
$builder->add('content', RedactorType::class, [
'options' => [
'lang' => $this->getRequest()->getLocale(),
'plugins' => ['video'],
'buttons' => ['bold', 'italic', 'image', 'link'],
],
]);
AwesomeController (if available) to auto-inject ShortcutService:
class MyController extends \AppVentus\Awesome\ShortcutsBundle\Controller\AwesomeController
{
public function indexAction()
{
$this->congrat('Shortcut method!'); // Direct access
}
}
AvAlertifyBundle templates in your theme to match your design system.getSession()/setSession() for app-wide state without reinventing logic.Deprecated Bundle:
Asset Loading:
datepicker.css/bootstrap-datepicker.js may need updates if using Symfony AssetMapper or Webpack Encore.config.yml or use {% block %} in templates.Redactor Configuration:
imageUpload path (/bundles/avawesomeshortcuts/...) is absolute and may break in subdirectories.asset() or configure a route for uploads:
# config/routes.yml
av_awesome_shortcuts_image_upload:
path: /upload/image
defaults: { _controller: AvAwesomeShortcutsBundle:Default:imageUpload }
Service Naming:
av.shortcuts, av.form_error_service) are case-sensitive. Double-check autowiring if using Symfony 4+.AvAlertifyBundle is installed and configured. Check if the bundle is enabled in AppKernel.php.getRecursiveReadableErrors() is called after $form->submit() and validation.assetic_injector.json is processed (Symfony 2.x only).Add Custom Shortcuts:
Extend ShortcutService and override methods:
class CustomShortcutService extends \AppVentus\Awesome\ShortcutsBundle\Service\ShortcutService
{
public function customMethod($param)
{
// Logic here
}
}
Register as a service:
services:
av.shortcuts:
class: App\Service\CustomShortcutService
parent: av.shortcuts.base
Modify Alert Templates:
Override AvAlertifyBundle templates in app/Resources/AvAlertifyBundle/views/ to customize layouts.
Session Handling:
Extend setSession()/getSession() to add app-specific logic (e.g., encryption, TTL).
How can I help you explore Laravel packages today?