dev-master
9999999-devSymfony bundle
MIT GPLv2
The Requires
by Tom Atom
atom bundle
Symfony bundle
For Symfony 2/3/4, (*1)
For Symfony 5, (*2)
For Symfony 6+, (*3)
For all, (*4)
install stof/doctrine-extensions-bundle - Translatable behavior (quick installation & config instructions), (*5)
install bundle, (*6)
- for Symfony ~2.8:
composer require tomatom/atom-bundle "~1.0"
- for Symfony ~4.2:
composer require tomatom/atom-bundle "~2.0"
- for Symfony ~5:
composer require tomatom/atom-bundle "3.0-alpha-5"
- for Symfony ~6|~7:
composer require tomatom/atom-bundle "^3"
Symfony 6+, (*7)
bundles.php:
TomAtom\AtomBundle\TomAtomAtomBundle::class => ['all' => true],
routing.yaml:
atom: resource: "@TomAtomAtomBundle/src/Controller/" type: attribute
framework.yaml:
framework: # ... translator: { fallbacks: [ "%locale%" ] }
twig.yaml:
twig: # ... base_template_class: TomAtom\AtomBundle\Twig\Template
Symfony < 6, (*8)
AppKernel.php:
new TomAtomAtomBundle\TomAtomAtomBundle(),
routing.yml:
atom: resource: "@TomAtomAtomBundle/Controller/" type: annotation
config.yml:
# Make sure translator is uncommented: framework: translator: { fallbacks: [ "%locale%" ] } # ... # Twig Configuration twig: base_template_class: TomAtom\AtomBundle\Twig\Template # ...
Same for all versions, (*9)
security.yml:
security: # ... # add role 'ROLE_ATOM_EDIT': role_hierarchy: ROLE_ATOM_EDIT: ROLE_USER ROLE_ADMIN: ROLE_ATOM_EDIT ROLE_SUPER_ADMIN: ROLE_ADMIN # ...
translation.yml:
framework: # ... # Add enabled locales for multi language application enabled_locales: [ 'cs', 'en', 'de' ]
::base.html.twig
(or your base layout):{# don't forget to include your jQuery (tested with 1.8.3 - 2.1.4, others may work, 3.0 doesn't): #} {{ render(controller('TomAtom\\AtomBundle\\Controller\\AtomController::_metasAction')) }}
/web/uploads/atom
Atoms intentionally works only in prod
environment!
They are disabled in test
, dev
and all others, so you can always see updated changes right away., (*10)
there are currently 3 Atom types:, (*11)
atom
- Atom with rich text editor (CKEditor)atomline
- Atom Line for editing plaintext inside fixed html tagsatomentity
- Atom Entity display and update column for given entity
{% atom unique_identifier_here %}
and closing tag {% endatom %}
. You can add default content between tags, which will be persisted on first load.{% atom foo %} <p> I am editable! </p> {% endatom %}
{% atomline unique_identifier_here %}
and closing
{% endatomline %}
.<h1> {% atomline bar %} I am editable! {% endatomline %} <h1>
for editing other entities, there is Atom Entity tag, which takes these arguments:, (*12)
AppBundle:Product
)example (no need to add default value, it will be fetched by appropriate getter):, (*13)
<div class="product-price"> {% atomentity AppBundle:Product, setPrice, 123 %}{% endatomentity %} <div>
prod
environment as user with role ROLE_ATOM_EDIT
unlocks editable mode, which _
_can be enabled or disabled__ by icon in bottom-right corner of browser screen._locale
request parameter, you can easily update atoms in specified
language.
Also Atom Entities can be translated from frontend, if they have implemented Gedmo Translatable behavior..env.local
, for example:DEEPL_KEY=xxxxxx
tom_atom_atom.yaml
in config/packages with these
values:tom_atom_atom: automatic_translations: true deepl_key: '%env(DEEPL_KEY)%' # env for your DeepL API KEY
Symfony bundle
MIT GPLv2
atom bundle