Ejemplo n.º 1
0
 /**
  * Chargement des variations de la commande
  *
  * @param Command   $cmd     Commande en cours
  * @param string    $content Resultat de l'aspiration
  * @param Mollicute $moll    Plan d'aspiration
  *
  * @return array
  * @throws \Siwayll\Mollicute\Abort si un plan est chargé
  */
 public function before(Command $cmd, $content, Mollicute $moll)
 {
     if ($cmd->declination !== true) {
         return;
     }
     foreach ($cmd->declGenerator as $key => $generator) {
         $tag = '[' . $key . ']';
         foreach ($cmd->getDeclination($key) as $data) {
             $result = clone $cmd;
             if (is_array($data)) {
                 $result->set('declinationData', $data);
                 $data = $data[0];
             }
             if (is_object($data)) {
                 $result->set('declinationData', $data);
             }
             $url = str_replace($tag, $data, $cmd->getUrl());
             $result->setUrl($url);
             if ($result->hasMethod('getFileName') && strpos($result->getFileName(), $tag) !== false) {
                 $newName = str_replace($tag, $data, $result->getFileName());
                 $result->setFileName($newName);
                 unset($newName);
             }
             $result->declination = false;
             $moll->add($result);
         }
     }
     throw new Abort('cancel');
 }
Ejemplo n.º 2
0
 /**
  * Ecriture du resultat de l'aspiration dans un fichier
  *
  * @param Command   $cmd     Commande en cours
  * @param string    $content Resultat de l'aspiration
  * @param Mollicute $moll    Plan d'aspiration
  *
  * @return array
  */
 public function before(Command $cmd, $content, Mollicute $moll)
 {
     $this->countPlan = $moll->countPlan();
 }