Class Media
Core router: - main store for all routes - application request routing process before request dispatching in core - currently matched route store - application url completing - by configured routes into mod_rewrite form - or into query string form, containing controller and action params - params query string building - primitive param value or array value representation possible
- MvcCore\Router
-
MvcCore\Ext\Router\Media
public static
|
|
public
|
#
SetSessionExpirationSeconds( $sessionExpirationSeconds = 3600 )
Set session expiration seconds for remembering detected media site version by user agent. Session record is always used to compare if user is requesting different media site version then he has in session - if there is difference - user is redirected to session media site version and this seconds is time to remember that sessio record for described redirection. |
public
|
#
SetAllowedSiteKeysAndUrlPrefixes( array $allowedSiteKeysAndUrlPrefixes = array() )
Set url prefixes prepended before url paths to describe media site version in url and by defined keys in given array - set only allowed media versions to work with. Key is media site version value and value is url prefix how to describe media site version in url. |
public
|
#
SetStricModeBySession( boolean $stricModeBySession = TRUE )
Set session strict mode. If true, process media site version strictly by session stored version, so if request contains some version and in session is different, redirect user to session version value adress, only when media site switching param is contained in $_GET, switch the version in session. If false, process media site version more benevolently, so if request contains some version and in session is different, store in session media site version from request and do not redirect user. |
protected
string
|
#
urlByRoute( string $controllerActionOrRouteName, array $params )
Complete url by route instance reverse info |
public
|
#
ProcessMediaSiteVersion(
Process media site version before request is routed by \MvcCore\Router Prepare: - media version from request - media version from session (setted by any previous request) - detect if there is any special media site switching parameter in $_GET (static::MEDIA_SITE_KEY_SWITCH_URL_PARAM) For each GET request - do: - if there is special media site switching param in request $_GET and it's allowed - switch media site version in session by it and redirect to the same url with new media site version substring in url - if there is no media site version in session or if media site version from sesson is not allowed - recognize media site version by Mobile_Detect third party library and store recognized version in this context and in session - else set up media site version from session - later if detected media site version is not the same as requested media site version - redirect to detected version |
protected
|
#
manageSwitchingAndRedirect( )
Store new media site key from url into session, remove it from $_GET, redirect to the same url as reqest without switch media site version param and exit inside redirect function |
protected
|
#
manageDetectionAndStoreInSession( )
Detect media site version by sended user agent string (Mobile_Detect library) and store detected result in session for next requests |
protected
|
#
checkMediaSiteVersionWithRequestVersionAndRedirectIfDifferent( )
If local media site version (completed previously from session or Mobile_Detect library) is different then media site version from request - redirect to url with media site version from local $this context and exit (inside redirect function) |
protected
|
#
setUpSession( )
If session namespace by this class is not initialized, init namespace and move expiration to next hour |
protected
|
#
setUpRequestMediaSiteKeyFromUrl( )
Try to set up into \MvcCore\Request object a MediaSiteKey property by requested url by defined url prefixes founded in requested url. |
string |
VERSION
MvcCore Extension - Router Media - version: Comparation by PHP function version_compare(); |
#
'4.2.0'
|
string |
MEDIA_SITE_KEY_URL_PARAM
Key name for media version in second argument $params in $router->Url(); method, to tell $router->Url() method to generate different media version url. |
#
'mediaSiteKey'
|
string |
MEDIA_SITE_KEY_SWITCH_URL_PARAM
Special $_GET param name for session strict mode, how to change site media version. |
#
'media_site_key'
|
public
integer
|
$SessionExpirationSeconds
Session expiration seconds for remembering detected media site version by user agent. Session record is always used to compare if user is requesting different media site version then he has in session - if there is difference - user is redirected to session media site version and this seconds is time to remember that sessio record for described redirection. |
#
3600
|
public
array
|
$AllowedSiteKeysAndUrlPrefixes
Url prefixes prepended before url paths to describe media site version in url. Key is media site version value and value in array is url prefix how to describe media site version in url. |
#
array(
MediaSiteKey::MOBILE => '/m',
MediaSiteKey::TABLET => '/t',
MediaSiteKey::FULL => '',
)
|
protected
|
$session
Session record is always used to compare if user is requesting different media site version then he has in session - if there is difference - user is redirected to session media site version |
#
NULL
|
protected
string
|
$sessionMediaSiteKey
Media site version founded in session. |
#
''
|
protected
string
|
$mediaSiteKey
Final media site key used in \MvcCore\Request object |
#
''
|
protected
string|boolean
|
$mediaSiteKeySwitchUriParam
Media site version for switching, always initialized by special switching $_GET param. |
#
FALSE
|
protected
boolean
|
$stricModeBySession
If true, process media site version strictly by session stored version, so if request contains some version and in session is different, redirect user to session version value adress, only when media site switching param is contained in $_GET, switch the version in session. If false, process media site version more benevolently, so if request contains some version and in session is different, store in session media site version from request and do not redirect user. |
#
FALSE
|
$currentRoute,
$instance,
$request,
$routeToDefaultIfNotMatch,
$routes,
$urlRoutes
|