Exemple #1
0
 /**
  * Create an array of statistics drivers that log a particular type of data.
  *
  * @param string $source Name of data type, or null to only obtain objects which
  * log ALL data types.
  * @param bool   $getAll If set to true, this parameter causes the method to
  * ignore $source and return every driver object.  This should only be used
  * when reading data, never when writing.
  *
  * @return array
  */
 public function getDriversForSource($source, $getAll = false)
 {
     $drivers = [];
     // For each mode
     if (isset($this->config->Statistics->mode)) {
         foreach ($this->config->Statistics->mode as $config) {
             $setting = explode(':', $config);
             // If the config setting has a limiter, we may need to skip this
             // record, so we should do some checks (unless we're set to accept
             // any match through the $getAll parameter).
             if (count($setting) > 1 && !$getAll) {
                 // If we only want global drivers, we don't want anything with
                 // limits.
                 if (null === $source) {
                     continue;
                 }
                 // If we got this far, we know that $source is not null; let's
                 // see if the requested source is supported.
                 $legalOptions = array_map('trim', explode(',', $setting[1]));
                 if (!in_array($source, $legalOptions)) {
                     continue;
                 }
             }
             // If we got this far, we want the current option!  Build the driver:
             $newDriver = $this->pluginManager->get($setting[0]);
             // Set the name of the data source;  we use the special value
             // "global" to represent global writer requests (the special null
             // case):
             $newDriver->setSource(null === $source ? 'global' : $source);
             $drivers[] = $newDriver;
         }
     }
     return $drivers;
 }