/** * Creates the distribution artifact. * * @param \Generator $emoteGenerator Contains a generator which will yield objects * of type GbsLogistics\Emotes\EmoteBundle\Entity\Emote . * @return ReleaseArtifact */ public function generateArtifact(\Generator $emoteGenerator) { $zipDir = 'GoonfleetEmotes.AdiumEmoticonSet'; $outputFilename = tempnam(sys_get_temp_dir(), $this->getNamespace()); $zip = new \ZipArchive(); if (!$zip->open($outputFilename)) { throw new \RuntimeException(sprintf('Can\'t open file %s for writing', $outputFilename)); } $zip->addEmptyDir($zipDir); $plist = <<<PLISTHEADER <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>AdiumSetVersion</key> <integer>1</integer> <key>Emoticons</key> <dict> PLISTHEADER; foreach ($emoteGenerator as $emote) { $plist .= $this->getPlistEntry($emote); $zip->addFile($this->dataStorage->getImageSourcePath($emote->getPath()), $zipDir . '/' . $emote->getPath()); } $plist .= '</dict></dict></plist>'; $zip->addFromString($zipDir . '/Emoticons.plist', $plist); $zip->close(); $artifact = new ReleaseArtifact(); $artifact->setNamespace($this->getNamespace()); $artifact->setPath($outputFilename); $artifact->setName($this->getNamespace()); return $artifact; }
/** * Creates the distribution artifact. * * @param \Generator $emoteGenerator Contains a generator which will yield objects * of type GbsLogistics\Emotes\EmoteBundle\Entity\Emote . * @return ReleaseArtifact */ public function generateArtifact(\Generator $emoteGenerator) { $zipDir = $this->getNamespace(); $outputFilename = tempnam(sys_get_temp_dir(), $this->getNamespace()); $zip = new \ZipArchive(); if (!$zip->open($outputFilename)) { throw new \RuntimeException(sprintf('Can\'t open file %s for writing', $outputFilename)); } $zip->addEmptyDir($zipDir); $header = $this->generateHeader(); $themeFile = sprintf(<<<EOTXT Name=%s Description=%s Icon=%s Author=%s [default] EOTXT , $header->getName(), $header->getDescription(), $header->getIcon(), $header->getAuthor()); /** @var Emote $emote */ foreach ($emoteGenerator as $emote) { $themeFile .= $this->generateEmoteEntry($emote); $zip->addFile($this->dataStorage->getImageSourcePath($emote->getPath()), $zipDir . '/' . $emote->getPath()); } $zip->addFromString($zipDir . '/theme', $themeFile); $zip->close(); $artifact = new ReleaseArtifact(); $artifact->setNamespace($this->getNamespace()); $artifact->setPath($outputFilename); $artifact->setName($this->getName()); return $artifact; }