src/SmartFactory/ErrorHandler.php
public function init($parameters)
    {
        if (!empty($parameters["app_root"])) {
            $this->app_root = $parameters["app_root"];
        }
        
        if (empty($parameters["log_path"])) {
            throw new \Exception("Log path is not specified!");
        }
        
        $this->log_path = $parameters["log_path"];
        
        $file = $this->log_path . "trace.log";
        
        if (!file_exists($this->log_path) || !is_writable($this->log_path) || (file_exists($file) && !is_writable($file))) {
            throw new \Exception(sprintf("The trace file '%s' is not writable!", $file));
        }
        
        return true;
    }
public function init($parameters)
    {
        if (!empty($parameters["app_root"])) {
            $this->app_root = $parameters["app_root"];
        }
        
        if (empty($parameters["log_path"])) {
            throw new \Exception("Log path is not specified!");
        }
        
        $this->log_path = $parameters["log_path"];
        
        $file = $this->log_path . "trace.log";
        
        if (!file_exists($this->log_path) || !is_writable($this->log_path) || (file_exists($file) && !is_writable($file))) {
            throw new \Exception(sprintf("The trace file '%s' is not writable!", $file));
        }
        
        return true;
    }
public function init ( $ parameters ) { if ( ! empty ( $ parameters [ "app_root" ] ) ) { $ this -> app_root = $ parameters [ "app_root" ] ; } if ( empty ( $ parameters [ "log_path" ] ) ) { throw new \ Exception ( "Log path is not specified!" ) ; } $ this -> log_path = $ parameters [ "log_path" ] ; $ file = $ this -> log_path . "trace.log" ; if ( ! file_exists ( $ this -> log_path ) || ! is_writable ( $ this -> log_path ) || ( file_exists ( $ file ) && ! is_writable ( $ file ) ) ) { throw new \ Exception ( sprintf ( "The trace file '%s' is not writable!" , $ file ) ) ; } return true ; }
Initializes the error handler with parameters.

@param array $parameters
Settings for logging as an associative array in the form key => value:

- $parameters["app_root"] - the root directory of the application.

- $parameters["log_path"] - the target file path where the logs should be stored.

@return boolean
Returns true upon successful initialization, otherwise false.

@throws \Exception
It might throw an exception in the case of any errors:

- if the log path is not specified.
- if the trace file is not writable.

@author Oleg Schildt
Initializes the error handler with parameters .