PHP Class Networking\InitCmsBundle\EventListener\LocaleListener

Author: Yorkie Chadwick ([email protected])
Inheritance: implements Symfony\Component\EventDispatcher\EventSubscriberInterface
ファイルを表示 Open project: networking/init-cms-bundle Class Usage Examples

Protected Properties

Property Type Description
$accessMap Symfony\Component\Security\Http\AccessMapInterface
$availableLanguages array
$defaultLocale string
$router string

Public Methods

Method Description
__construct ( Symfony\Component\Security\Http\AccessMapInterface $accessMap, array $availableLanguages, string $defaultLocale = 'en', Symfony\Component\Routing\RouterInterface $router = null )
getBrowserAcceptLanguages ( Request $request ) : array get browser accept languages
getPreferredLocale ( Request $request ) : string get preferred locale
getSubscribedEvents ( ) : array
onKernelRequest ( GetResponseEvent $event )
onSecurityInteractiveLogin ( Symfony\Component\Security\Http\Event\InteractiveLoginEvent $event )
splitHttpAcceptHeader ( string $header ) : array split http accept header

Protected Methods

Method Description
guessFrontendLocale ( mixed $locales ) : string guess frontend locale
matchLocaleInAvailableLanguages ( $locale ) : string try to match browser language with available languages

Method Details

__construct() public method

public __construct ( Symfony\Component\Security\Http\AccessMapInterface $accessMap, array $availableLanguages, string $defaultLocale = 'en', Symfony\Component\Routing\RouterInterface $router = null )
$accessMap Symfony\Component\Security\Http\AccessMapInterface
$availableLanguages array
$defaultLocale string
$router Symfony\Component\Routing\RouterInterface

getBrowserAcceptLanguages() public method

get browser accept languages
public getBrowserAcceptLanguages ( Request $request ) : array
$request Symfony\Component\HttpFoundation\Request
return array

getPreferredLocale() public method

get preferred locale
public getPreferredLocale ( Request $request ) : string
$request Symfony\Component\HttpFoundation\Request
return string

getSubscribedEvents() public static method

public static getSubscribedEvents ( ) : array
return array

guessFrontendLocale() protected method

guess frontend locale
protected guessFrontendLocale ( mixed $locales ) : string
$locales mixed
return string

matchLocaleInAvailableLanguages() protected method

try to match browser language with available languages
protected matchLocaleInAvailableLanguages ( $locale ) : string
$locale
return string

onKernelRequest() public method

public onKernelRequest ( GetResponseEvent $event )
$event Symfony\Component\HttpKernel\Event\GetResponseEvent

onSecurityInteractiveLogin() public method

public onSecurityInteractiveLogin ( Symfony\Component\Security\Http\Event\InteractiveLoginEvent $event )
$event Symfony\Component\Security\Http\Event\InteractiveLoginEvent

splitHttpAcceptHeader() public method

split http accept header
public splitHttpAcceptHeader ( string $header ) : array
$header string
return array

Property Details

$accessMap protected_oe property

protected AccessMapInterface,Symfony\Component\Security\Http $accessMap
return Symfony\Component\Security\Http\AccessMapInterface

$availableLanguages protected_oe property

protected array $availableLanguages
return array

$defaultLocale protected_oe property

protected string $defaultLocale
return string

$router protected_oe property

protected string $router
return string