Example #1
0
 public function generate(Element $campaign)
 {
     //Change the uri of the documents to a valid one for a ftp package
     /** @var \Maileva\Element\Request $request */
     $i = 1;
     foreach ($campaign->getRequests() as $request) {
         /** @var \Maileva\Element\Document $document */
         foreach ($request->getDocumentData() as $document) {
             if ($this->save_src) {
                 file_put_contents($this->directory . '/src/' . $i . '.' . basename($document->getContent()->getUri()), file_get_contents($document->getContent()->getUri()));
             }
             $filename = $this->addFile($document->getContent()->getUri());
             $document->getContent()->setUri($filename);
             $i++;
         }
     }
     //Creation de lelement root pour le xml
     $domDoc = Element::getDomFromCampaign($campaign);
     // Beautiful output
     $domDoc->preserveWhiteSpace = false;
     $domDoc->formatOutput = true;
     //sauvegarde dans un fichier
     $filename_pjs = ($this->save_src ? $this->directory . '/src/' : sys_get_temp_dir() . '/') . 'pjs.xml';
     file_put_contents($filename_pjs, $domDoc->saveXML());
     //ajout dans le fichier de command
     $this->addFile($filename_pjs);
     //generation du fichier de command
     $filename_command = $this->directory . ($this->save_src ? '/ftp/' : '') . '/' . $this->name . '.tmp';
     $this->command->saveInFile($filename_command);
     if ($this->save_src) {
         $this->command->saveInFile($this->directory . '/src/' . $this->name . '.' . $this->command->getExtensionFile());
     }
     $this->files_packages[] = $filename_command;
 }