App_CLI::__construct PHP Метод

__construct() публичный Метод

Application class is differente, you use "new" keyword because it's the first class to be created. That's why constructor will perform quite a bit of initialization. Do not redefine constructor but instead use init(); $realm defines a top-level name of your application. This impacts all id= prefixes in your HTML code, form field names and many other things, such as session name. If you have two application classes which are part of same web app and may want to use same realm, but in other cases it's preferably that you keep realm unique on your domain in the interests of security.
public __construct ( string $realm = null, array $options = [] )
$realm string Will become $app->name
$options array
    public function __construct($realm = null, $options = array())
    {
        parent::__construct($options);
        if ($realm === null) {
            $realm = get_class($this);
        }
        $this->owner = $this;
        $this->name = $realm;
        $this->app = $this;
        $this->api = $this->app;
        // compatibility with ATK 4.2 and lower
        // Profiler is a class for benchmarking your application. All calls to pr
        /**/
        $this->pr = new Dummy();
        try {
            $this->_beforeInit();
            $this->init();
        } catch (Exception $e) {
            // This exception is used to abort initialisation of the objects,
            // but when normal rendering is still required
            if ($e instanceof Exception_StopInit) {
                return;
            }
            // Handles output of the exception
            $this->caughtException($e);
        }
    }

Usage Example

Пример #1
0
 function __construct($realm = null, $skin = 'default')
 {
     $this->start_time = time() + microtime();
     $this->skin = $skin;
     try {
         parent::__construct($realm);
     } catch (Exception $e) {
         // This exception is used to abort initialisation of the objects but when
         // normal rendering is still required
         if ($e instanceof Exception_Stop) {
             return;
         }
         $this->caughtException($e);
     }
 }