/**
  * Returns a node by name and sets the locale
  *
  * @param string $name
  * @param bool $track
  * @param bool $published
  * @return Node
  */
 public function getNodeAndSetLocale($name, $track = true, $published = true)
 {
     $node = $this->getNode($name, $track, $published);
     $locale = $node->getLocaleForNodeName($name);
     set_app_locale($locale);
     return $node;
 }
Beispiel #2
0
 /**
  * Returns a tag by name and sets the locale
  *
  * @param string $name
  * @param string $locale
  * @return Tag
  */
 public function getTagAndSetLocale($name, $locale = null)
 {
     $tag = $this->getTag($name);
     // Override locale or use tag locale
     // this is for when a tag does not have to be translated
     // and the app locale is determined via route parameter (etiket|tag)
     $locale = $locale ?: $tag->getLocaleForName($name);
     set_app_locale($locale);
     return $tag;
 }
Beispiel #3
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // Set Reactor locale
     if (is_request_install() || is_request_reactor()) {
         $locale = env('REACTOR_LOCALE');
         if (array_key_exists($locale, InstallHelper::$locales)) {
             set_app_locale($locale, false);
         }
         return $next($request);
     }
     // Else set site locale
     $locale = session('_locale', null) ?: (env('APP_AUTO_LOCALE', true) ? mb_substr($request->getPreferredLanguage(), 0, 2) : env('REACTOR_LOCALE'));
     if (in_array($locale, locales())) {
         set_app_locale($locale);
     }
     return $next($request);
 }
 /**
  * Sets the app locale with given key and slug
  *
  * @param string $key
  * @param string $slug
  */
 public function setAppLocaleWith($key, $slug)
 {
     $locale = $this->getLocaleFor($key, $slug);
     set_app_locale($locale);
 }
 /**
  * Populates a mailchimp campaign content
  *
  * @param Client $client
  * @param string $mailingId
  * @param MailingNode $mailing
  * @param MailingList $list
  * @return string $campaignId
  */
 protected function makeUpdateMailchimpCampaignContentRequest(Client $client, $mailingId, MailingNode $mailing, MailingList $list)
 {
     $translation = $mailing->translateOrFirst();
     set_app_locale($translation->locale);
     $_inBrowser = false;
     $mail = view($mailing->getNodeTypeName(), compact('mailing', 'list', 'translation', '_inBrowser'))->render();
     return $client->post('campaigns/' . $mailingId . '/content', ['headers' => ['X-HTTP-Method-Override' => 'PUT'], 'json' => ['html' => $mail, 'url' => route('reactor.mailings.preview', $mailing->translateOrFirst()->node_name)]]);
 }