예제 #1
0
 /**
  * Builds the right TaskInterface object for you.
  * 
  * @param string $task_module
  * @param string $tak_name
  * @param bool $is_internal
  * @param int $id, if you have it already it's better to give it
  * @return \Drupal\Prod\Stats\TaskInterface
  */
 public static function get($task_module, $task_name, $is_internal, $id = NULL)
 {
     if (!array_key_exists($task_module, self::$tasks)) {
         self::$tasks[$task_module] = array();
     } else {
         if (array_key_exists($task_name, self::$tasks)) {
             // Already have it!
             return self::$tasks[$task_module][$task_name];
         }
     }
     // we do not have it yet...
     if (!$is_internal) {
         // OK, so in fact this is not really a Singleton object that you
         // need. You will need an instance of Task with custom values
         $task = new Task();
         $task->setTaskModule($task_module);
         $task->setTaskName($task_name);
         $task->flagInternal(FALSE);
     } else {
         // Here any TaskInterface implementation should be a Singleton
         // coming for a class derivated from Task().
         $class = $task_module;
         $task = call_user_func(array($class, 'getInstance'));
         $task->setTaskModule($task_module);
         $task->setTaskName($task_name);
         $task->flagInternal(TRUE);
     }
     // Try to get the task Id if it exists
     if (!is_null($id)) {
         $task->setid($id);
     }
     self::$tasks[$task_module][$task_name] = $task;
     return self::$tasks[$task_module][$task_name];
 }
예제 #2
0
 /**
  * Ensure all Helpers (log) are loaded into this object
  *
  */
 public function initHelpers()
 {
     parent::initHelpers();
     $this->logger->log(__METHOD__, NULL, WATCHDOG_DEBUG);
     // register in the Queue of StatsProviders
     $prodQueue = Queue::getInstance();
     $prodQueue->attach($this);
     // register our callback for Cacti Output
     $cactiObservable = Cacti::getInstance();
     $cactiObservable->attach($this);
     return $this;
 }