AdminModule/presenters/LanguagesPresenter.php
public function actionExportLanguage($id)
    {
        $language = $this->em->find("WebCMS\Entity\Language", $id);

        $export = array(
            'name' => $language->getName(),
            'abbr' => $language->getAbbr(),
            'translations' => array(),
        );

        foreach ($language->getTranslations() as $translation) {
            if ($translation->getBackend()) {
                $export['translations'][] = array(
                'key' => $translation->getKey(),
                'translation' => $translation->getTranslation(),
                'backend' => $translation->getBackend(),
            );
            }
        }

        $export = json_encode($export);
        $filename = $language->getAbbr().'.json';

        $response = $this->getHttpResponse();
        $response->setHeader('Content-Description', 'File Transfer');
        $response->setContentType('text/plain', 'UTF-8');
        $response->setHeader('Content-Disposition', 'attachment; filename='.$filename);
        $response->setHeader('Content-Transfer-Encoding', 'binary');
        $response->setHeader('Expires', 0);
        $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
        $response->setHeader('Pragma', 'public');
        $response->setHeader('Content-Length', strlen($export));

        ob_clean();
        flush();
        echo $export;

        $this->terminate();
    }
public function actionExportLanguage($id)
    {
        $language = $this->em->find("WebCMS\Entity\Language", $id);

        $export = array(
            'name' => $language->getName(),
            'abbr' => $language->getAbbr(),
            'translations' => array(),
        );

        foreach ($language->getTranslations() as $translation) {
            if ($translation->getBackend()) {
                $export['translations'][] = array(
                'key' => $translation->getKey(),
                'translation' => $translation->getTranslation(),
                'backend' => $translation->getBackend(),
            );
            }
        }

        $export = json_encode($export);
        $filename = $language->getAbbr().'.json';

        $response = $this->getHttpResponse();
        $response->setHeader('Content-Description', 'File Transfer');
        $response->setContentType('text/plain', 'UTF-8');
        $response->setHeader('Content-Disposition', 'attachment; filename='.$filename);
        $response->setHeader('Content-Transfer-Encoding', 'binary');
        $response->setHeader('Expires', 0);
        $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
        $response->setHeader('Pragma', 'public');
        $response->setHeader('Content-Length', strlen($export));

        ob_clean();
        flush();
        echo $export;

        $this->terminate();
    }
public function actionExportLanguage ( $ id ) { $ language = $ this -> em -> find ( "WebCMS\Entity\Language" , $ id ) ; $ export = array ( 'name' => $ language -> getName ( ) , 'abbr' => $ language -> getAbbr ( ) , 'translations' => array ( ) , ) ; foreach ( $ language -> getTranslations ( ) as $ translation ) { if ( $ translation -> getBackend ( ) ) { $ export [ 'translations' ] [ ] = array ( 'key' => $ translation -> getKey ( ) , 'translation' => $ translation -> getTranslation ( ) , 'backend' => $ translation -> getBackend ( ) , ) ; } } $ export = json_encode ( $ export ) ; $ filename = $ language -> getAbbr ( ) . '.json' ; $ response = $ this -> getHttpResponse ( ) ; $ response -> setHeader ( 'Content-Description' , 'File Transfer' ) ; $ response -> setContentType ( 'text/plain' , 'UTF-8' ) ; $ response -> setHeader ( 'Content-Disposition' , 'attachment; filename=' . $ filename ) ; $ response -> setHeader ( 'Content-Transfer-Encoding' , 'binary' ) ; $ response -> setHeader ( 'Expires' , 0 ) ; $ response -> setHeader ( 'Cache-Control' , 'must-revalidate, post-check=0, pre-check=0' ) ; $ response -> setHeader ( 'Pragma' , 'public' ) ; $ response -> setHeader ( 'Content-Length' , strlen ( $ export ) ) ; ob_clean ( ) ; flush ( ) ; echo $ export ; $ this -> terminate ( ) ; }
Export language into JSON file and terminate response for download it.
@param Int $id
Export language into JSON file and terminate response for download it .