Symfony\Component\HttpFoundation\Request::getDefaultLocale PHP Method

getDefaultLocale() public method

Get the default locale.
public getDefaultLocale ( ) : string
return string
    public function getDefaultLocale()
    {
        return $this->defaultLocale;
    }

Usage Example

 /**
  * Finds and displays a Users of a Journal with roles
  *
  * @param  Request  $request
  * @return Response
  */
 public function indexAction(Request $request)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     $eventDispatcher = $this->get('event_dispatcher');
     if (!$this->isGranted('VIEW', $journal, 'userRole')) {
         throw new AccessDeniedException("You are not authorized for view this page");
     }
     $source = new Entity('OjsJournalBundle:JournalUser');
     $source->manipulateRow(function (Row $row) use($request) {
         /* @var JournalUser $entity */
         $entity = $row->getEntity();
         if (!is_null($entity)) {
             $entity->getJournal()->setDefaultLocale($request->getDefaultLocale());
             if (!is_null($entity)) {
                 $row->setField('journal', $entity->getJournal()->getTitle());
             }
         }
         return $row;
     });
     $grid = $this->get('grid');
     $grid->setSource($source);
     $gridAction = $this->get('grid_action');
     $rowAction = [];
     $rowAction[] = $gridAction->editAction('ojs_journal_user_edit', ['journalId' => $journal->getId(), 'id']);
     $rowAction[] = $gridAction->deleteAction('ojs_journal_user_delete', ['journalId' => $journal->getId(), 'id']);
     $actionColumn = new ActionsColumn("actions", "actions");
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $listEvent = new ListEvent();
     $listEvent->setGrid($grid);
     $eventDispatcher->dispatch(JournalUserEvents::LISTED, $listEvent);
     $grid = $listEvent->getGrid();
     return $grid->getGridResponse('OjsJournalBundle:JournalUser:index.html.twig');
 }
All Usage Examples Of Symfony\Component\HttpFoundation\Request::getDefaultLocale