/**
  * {@inheritDoc}
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!($this->project && $this->getApi())) {
         $this->writelnAlways($output, '<error>No project set or no API received, exiting.</error>');
         return;
     }
     $project = new Project($this->getApi());
     $project->setSlug($this->project);
     $resources = $project->getResources();
     $files = $this->getAllTxFiles($this->baselanguage);
     foreach ($files as $file => $basename) {
         $noext = basename($basename, '.xlf');
         if (array_key_exists($this->prefix . $noext, $resources)) {
             // already present, update.
             $this->writeln($output, sprintf('Updating ressource <info>%s</info>', $this->prefix . $noext));
             /** @var \CyberSpectrum\Transifex\TranslationResource $resource */
             $resource = $resources[$this->prefix . $noext];
             $resource->setContent(file_get_contents($file));
             $resource->updateContent();
         } else {
             $this->writeln($output, sprintf('Creating new ressource <info>%s</info>', $this->prefix . $noext));
             // upload new.
             $resource = new TranslationResource($this->getApi());
             $resource->setProject($this->project);
             $resource->setSlug($this->prefix . $noext);
             $resource->setName($resource->getSlug());
             $resource->setSourceLanguageCode($this->baselanguage);
             $resource->setContent(file_get_contents($file));
             $resource->create();
         }
     }
 }
 /**
  * Create a xliff instance for the passed resource.
  *
  * @param TranslationResource $resource     The resource.
  *
  * @param string              $languageCode The language code.
  *
  * @return XliffFile
  */
 private function getLocalXliffFile(TranslationResource $resource, $languageCode)
 {
     $domain = substr($resource->getSlug(), strlen($this->prefix));
     $localFile = $this->txlang . DIRECTORY_SEPARATOR . substr($languageCode, 0, 2) . DIRECTORY_SEPARATOR . $domain . '.xlf';
     $local = new XliffFile($localFile);
     if (!file_exists($localFile)) {
         // Set base values.
         $local->setDataType('php');
         $local->setOriginal($domain);
         $local->setSrcLang($this->baselanguage);
         $local->setTgtLang(substr($languageCode, 0, 2));
     }
     return $local;
 }