Commits

Arkadiusz Dzięgiel committed 43069f8

ContainerAwareInterface for Query classes

  • Participants
  • Parent commits bc2b42c
  • Tags v1.2.4

Comments (0)

Files changed (2)

Resources/config/services.xml

         <service id="glorpen.propel.listeners.container_aware" class="%glorpen.propel.listeners.container_aware.class%">
         	<argument type="service" id="service_container" />
         	<tag name="propel.event" method="onModelConstruct" event="model.construct" />
+        	<tag name="propel.event" method="onQueryConstruct" event="query.construct" />
         </service>
         <service id="glorpen.propel.listeners.transaction_aware" class="%glorpen.propel.listeners.transaction_aware.class%">
         	<tag name="propel.event" />

Services/ContainerAwareModel.php

 use Glorpen\Propel\PropelBundle\Events\ModelEvent;
 
 use Symfony\Component\DependencyInjection\ContainerInterface;
+use Glorpen\Propel\PropelBundle\Events\QueryEvent;
 
 /**
  * @author Arkadiusz Dzięgiel
 			$m->setContainer($this->container);
 		}
 	}
+
+	public function onQueryConstruct(QueryEvent $event){
+		$q = $event->getQuery();
+		if($q instanceof ContainerAwareInterface){
+			$q->setContainer($this->container);
+		}
+	}
 }