/**
  * @see npOptimizerBase
  */
 public function configure(array $configuration = array())
 {
     parent::configure($configuration);
     if (!isset($configuration['drivers'])) {
         throw new sfConfigurationException('The "drivers" configuration parameter is mandatory in order to use a batch optimizer');
     }
     $this->setDrivers($configuration['drivers']);
 }
 /**
  * @see npOptimizerBase
  */
 public function configure(array $configuration = array())
 {
     parent::configure($configuration);
     if (isset($configuration['files'])) {
         parent::setFiles($configuration['files']);
     } else {
         if (isset($configuration['folders'])) {
             parent::setFiles($this->findPngImages($configuration['folders']));
         } else {
             throw new sfConfigurationException('You must define either a "files" or a "folders" option to use this optimizer');
         }
     }
     // PNG images will be replaced by their optimized versions
     $this->replaceFiles = true;
 }
 /**
  * Combines the results of every file optimization in one single file.
  *
  * @return  array  The list of resulting optimized files
  *
  * @throws RuntimeException if a problem occurs
  */
 public function optimize()
 {
     $results = parent::optimize();
     $optimizedContents = '';
     foreach ($results['statistics'] as $file => $statistic) {
         $optimizedContents .= $statistic['optimizedContent'];
     }
     if (empty($optimizedContents)) {
         throw new RuntimeException('Empty optimized contents!');
     }
     if (!file_put_contents($optimizedFile = sprintf('%s%s', $this->baseAssetsDir, $this->destination), $optimizedContents)) {
         throw new RuntimeException(sprintf('Unable to write optimized and combined asset file "%s"', $optimizedFile));
     }
     return array_merge($results, array('generatedFile' => $optimizedFile));
 }