public function createAssetsAction(Request $request, $token)
    {
        if (!$request->isXmlHttpRequest()) {
            return $this->redirectToRoute('_profiler', ['token' => $token]);
        }

        $messages = $this->getSelectedMessages($request, $token);

        if ($messages instanceof Data) {
            $messages = $messages->getValue(true);
        }

        if (empty($messages)) {
            return new Response('No translations selected.');
        }

        $uploaded = array();
        $trans = $this->get('happyr.translation');
        foreach ($messages as $message) {
            if ($trans->createAsset($message)) {
                $uploaded[] = $message;
            }
        }

        $saved = count($uploaded);
        if ($saved > 0) {
            $this->get('happyr.translation.filesystem')->updateMessageCatalog($uploaded);
        }

        return new Response(sprintf('%s new assets created!', $saved));
    }
public function createAssetsAction(Request $request, $token)
    {
        if (!$request->isXmlHttpRequest()) {
            return $this->redirectToRoute('_profiler', ['token' => $token]);
        }

        $messages = $this->getSelectedMessages($request, $token);

        if ($messages instanceof Data) {
            $messages = $messages->getValue(true);
        }

        if (empty($messages)) {
            return new Response('No translations selected.');
        }

        $uploaded = array();
        $trans = $this->get('happyr.translation');
        foreach ($messages as $message) {
            if ($trans->createAsset($message)) {
                $uploaded[] = $message;
            }
        }

        $saved = count($uploaded);
        if ($saved > 0) {
            $this->get('happyr.translation.filesystem')->updateMessageCatalog($uploaded);
        }

        return new Response(sprintf('%s new assets created!', $saved));
    }
public function createAssetsAction ( Request $ request , $ token ) { if ( ! $ request -> isXmlHttpRequest ( ) ) { return $ this -> redirectToRoute ( '_profiler' , [ 'token' => $ token ] ) ; } $ messages = $ this -> getSelectedMessages ( $ request , $ token ) ; if ( $ messages instanceof Data ) { $ messages = $ messages -> getValue ( true ) ; } if ( empty ( $ messages ) ) { return new Response ( 'No translations selected.' ) ; } $ uploaded = array ( ) ; $ trans = $ this -> get ( 'happyr.translation' ) ; foreach ( $ messages as $ message ) { if ( $ trans -> createAsset ( $ message ) ) { $ uploaded [ ] = $ message ; } } $ saved = count ( $ uploaded ) ; if ( $ saved > 0 ) { $ this -> get ( 'happyr.translation.filesystem' ) -> updateMessageCatalog ( $ uploaded ) ; } return new Response ( sprintf ( '%s new assets created!' , $ saved ) ) ; }
Save the selected translation to resources.

@author Damien Alexandre (damienalexandre)

@param Request $request
@param string  $token

@Route("/{token}/translation/create-asset", name="_profiler_translations_create_assets")
@Method("POST")

@return Response
Save the selected translation to resources .