getValues() public method

Return all values from core_config_data
public getValues ( string $locale = null, integer $limit = null ) : array
$locale string Locale
$limit integer Limit
return array
Example #1
0
 /**
  * Send a file to the browser
  *
  * @return \Zend\Stdlib\ResponseInterface
  */
 public function downloadAction()
 {
     $translator = new Translator();
     $values = $translator->getValues();
     $zip = new ZipArchive();
     $tmpFilename = tempnam(sys_get_temp_dir(), 'zip');
     $res = $zip->open($tmpFilename, ZipArchive::CREATE);
     if ($res === true) {
         $locales = array();
         foreach ($values as $value) {
             if (!isset($locales[$value['locale']])) {
                 $locales[$value['locale']] = array();
             }
             $locales[$value['locale']][] = sprintf('"%s","%s"', str_replace('"', '"""', $value['source']), str_replace('"', '"""', $value['destination']));
         }
         foreach ($locales as $locale => $content) {
             $zip->addFromString($locale . '.csv', implode(PHP_EOL, $content));
         }
         $zip->close();
         $content = file_get_contents($tmpFilename);
         $filename = 'translations.zip';
         unlink($tmpFilename);
     }
     if (empty($content) or empty($filename)) {
         $this->flashMessenger()->addErrorMessage('Can not save translations');
         return $this->redirect()->toRoute('content/translation');
     }
     $headers = new Headers();
     $headers->addHeaderLine('Pragma', 'public')->addHeaderLine('Cache-control', 'must-revalidate, post-check=0, pre-check=0')->addHeaderLine('Cache-control', 'private')->addHeaderLine('Expires', -1)->addHeaderLine('Content-Type', 'application/octet-stream')->addHeaderLine('Content-Transfer-Encoding', 'binary')->addHeaderLine('Content-Length', strlen($content))->addHeaderLine('Content-Disposition', 'attachment; filename=' . $filename);
     $response = $this->getResponse();
     $response->setHeaders($headers);
     $response->setContent($content);
     return $response;
 }