"Home"
and "home"
are regarded to mean the same thing.
There are certain situations that developers may want to be strict in defining window urls, especially
in situations where urls are generated using base64_encode()
function. In this case,
handling case sensitive urls might be an issue. In order to fix this issue, spoova introduces two approaches which can be used to define
case sensitive urls.
SELF::STRICT
key, when defined on a shutter, will set all urls to case sensitive. The value must be
set as a boolean of true
. Once declared within a shutter, the shutter will remember to set all urls to case sensitive
unless an inverse is declared which naturally negates the SELF::STRICT
key.
<?php use Window; class Home extends Window { function __construct() { self::call($this, [ 'home/user' => 'root', // case sensitive url 'home/profile' => 'root', // case sensitive url SELF::STRICT => true, // set all urls as case sensitive ]) } }
!
)<?php use Window; class Home extends Window { function __construct() { self::call($this, [ 'home/user' => 'root', // case insensitive url '!home/profile' => 'root', // case sensitive url (inverse) ]) } }
SELF::STRICT
option to generally
make urls become case sensitive, we can reverse this behaviour by also using the inverse operator.
<?php use Window; class Home extends Window { function __construct() { self::call($this, [ SELF::STRICT => true, // set all urls as case-sensitive 'home/user' => 'root', // case sensitive url '!home/pro' => 'root', // case insensitive url (inverse) ]) } }
SELF::STRICT
on urls was altered using the same operator. It is important to note that the window()
method has also been integerated with the inverse method. Hence, the inverse operator can be used within the window method, for example,
as window('!:user')
. This is shown below.
<?php use Window; class Home extends Window { function __construct() { self::call($this, [ window(':user') => 'root', // case sensitive "home/user" window('!:pro') => 'root', // case insensitive "home/pro" SELF::STRICT => true, // set all urls as strict except inverse ]) } }
home
, then while window(':user')
will return home/user
which will be compared as case-insensitive,
window('!:user')
will return !home/user
which will be compared as a case-sensitive url unless this behaviour is inversely altered with
SELF::STRICT
constant. In the sample above, the SELF::STRICT
option was set as true
which will negate the default behaviour.
Hence, window(':user')
will become case-sensitive while the window('!:user')
will become case-insensitive.
Also, note that the SELF::STRICT
inverse behaviour only affect shutters. Function such as invoke()
, windowExcludes()
and windowIncludes()
will respond in
their own individual default ways.
"@"
is usually applied to the window()
function to
ensure that a index page url always return the index
name even if it is not defined in the current url. When working with inverse urls,
we can supply this character by only after the inverse operator has been defined. This means that the inverse operator preceeds the index resolver. A sample
format is shown below:
window('!@root:HoMe')
window(':')
is equivalent to an empty string because no root name was defined on the url above,
then window('@root:')
will properly assign the name "index"
even if not defined. However, as in the case of
window('@root:HoMe')
, when working on index routes, this will be equivalent to index/HoMe
which is case-insensitive while the
window('!@root:HoMe')
will specify that the url is
case-sensitive. However, it is important to note that in order to fix case-sensitity of window roots, this operation can only be done with a
map file. More information can also be found on map files here.