Route Shutters

The shutter system is a lower level authentication system designed to open only accepted urls when they are visited while other invalid urls remain closed automatically through the Window::close() method. By default, when a window file does not exist and the corresponding url is called, the shutter automatically closes unless the shutter is pended which in turn leaves the url opened. This behaviour is one designed to prevent any access to a non-existing route which can lead to blank pages. However, when a window file exists and is called, the shutters are left opened to be manually closed by the respective window class or method. The closing of windows is a technicality that must be properly understood well in order to be able to close windows efficiently especially when using the call shutter methods. An improper closing of windows can leave some urls opened unknowingly. Hence, developers must have a good knowledge of handling urls to be able to properly close them.

In Windows-View-Model architecture (WinViM), there are two methods specifically designed to close windows. These are the close() and sleep() methods. The sleep method is only used for development purpose as it only closes a url while monitoring it on a live state till it becomes available. This action is powered by the inbuilt live server. When the url becomes alive, then the page is re-routed automatically from a 404 page to the respective page. This method is not applicable on a live environment. It is only introduced for test purposes. Also, by default, shutters naturally shuts a page down if a url cannot be resolved.

The shutter method are designed to take a list of acceptable urls which are permitted to be loaded. The system believes that all urls are invalid except bthe ones specified. Each of the urls specified are expected to have a relative url handler method or class that can be initialized once the url is visited. In the event that a visited url is not in the listed of accepted urls or the handler method (or class) is not understood, a 404 error page will be returned. The beauty of shutters is that they are not solely dependent on a single shutter method. This means that one shutter can be pended for another to allow for more url permissions. The most important concept here is that when these methods are pended, then developers must employ a great deal of care when closing the urls. The general syntax or structure of a shutter system is shown below.

Syntax: (call syntax)
  self::call(instance, urls, close)
        
The following explanation defines each part of the syntax above
Syntax: (definition)
  self      - means that it must be an extension of window class
  
  call      - any of the shutter methods (i.e rootcall, call, basecall, pathcall)
  
  instance  - instance of the current window (i.e $this)
            
  urls      - an array with the list of accepted valid urls and method or class called along with optional keys for arguments and middlewares.
  
  close     - specifies the state of a shutter if it cannot resolve the currently visited url.
              
                [shutter::close|true|1] - load 404 error page. This is the default value
                [shutter::sleep|2]      - load 404 error page on a live state mode
                [shutter::pend|false|0] - pend current shutter for subsequent shutter validations.
              
 


Since we earlier discussed about the {domain} part of urls in logics, we are going to use this term in the course of this tutorial. Let's head on to learn more about route shutters.