Merge pull request #2326 from eileenmcnaughton/CRM-14069
[civicrm-core.git] / Civi / Core / Container.php
index eb0b13f11d5c8b01bc6761be50812a46f53a0ba5..d1a0578c37923c2fb37a1c6fd9f6b3b75165e308 100644 (file)
@@ -13,6 +13,10 @@ use Symfony\Component\DependencyInjection\Reference;
 
 // TODO use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
 
+/**
+ * Class Container
+ * @package Civi\Core
+ */
 class Container {
 
   const SELF = 'civi_container_factory';
@@ -23,10 +27,11 @@ class Container {
   private static $singleton;
 
   /**
+   * @param bool $reset whether to forcibly rebuild the entire container
    * @return \Symfony\Component\DependencyInjection\TaggedContainerInterface
    */
-  public static function singleton() {
-    if (self::$singleton === NULL) {
+  public static function singleton($reset = FALSE) {
+    if ($reset || self::$singleton === NULL) {
       $c = new self();
       self::$singleton = $c->createContainer();
     }
@@ -84,6 +89,10 @@ class Container {
    */
   public function createEventDispatcher() {
     $dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
+    $dispatcher->addListener('hook_civicrm_post::Activity', array('\Civi\CCase\Events', 'fireCaseChange'));
+    //$dispatcher->addListener('hook_civicrm_post::Case', array('\Civi\CCase\Events', 'fireCaseChange'));
+    $dispatcher->addListener('hook_civicrm_caseChange', array('\Civi\CCase\Events', 'delegateToXmlListeners'));
+    $dispatcher->addListener('hook_civicrm_caseChange', array('\Civi\CCase\SequenceListener', 'onCaseChange_static'));
     return $dispatcher;
   }