symfony2 - SF2 - Sonata: How to get parameter from parameter.yml in entity -



symfony2 - SF2 - Sonata: How to get parameter from parameter.yml in entity -

i used sonata admin bundle. how can create entity engage parameters.yml to? either straight or via service ....

i have tidying work in postremove, need here disclosures paths, access info , more. not write hard entitiy, parameters.yml pick from.

timo

entity class not place putting business logic. far know can't define entity service.

what want should solved creating event listener can define service , pass value parameters.yml. listener should hear on postremove event.

your services.yml:

services: service_name: class: acme\your\listenerclass arguments: [%your_parameter_from_yml%] tags: - { name: doctrine.event_listener, event: postremove }

your listenerclass:

class listenerclass { public function __construct($your_param_from_parameters) { $this->param = $your_param_from_parameters } /** * @param lifecycleeventargs $args */ public function postremove(lifecycleeventargs $args) { $entity = $args->getentity(); if ($entity instanceof yourentity) { //do magic!! } } }

symfony2 sonata-admin

Comments

Popular posts from this blog

php - How to pass multiple values from url -

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

database - php search bar when I press submit with nothing in the search bar it shows all the data -