コード例 #1
0
 /**
  * 
  * Controller constructor creates an instance of Staple_View and saves it in the $view
  * property. It then calls the overridable method _start() for additional boot time
  * procedures.
  */
 public function __construct()
 {
     //Set default access levels
     $methods = get_class_methods(get_class($this));
     foreach ($methods as $acMeth) {
         if (substr($acMeth, 0, 1) != '_') {
             $this->accessLevels[$acMeth] = 1;
         }
     }
     //Create a view object
     $this->view = new Staple_View();
     //Assign the default layout to the controller, if specified in config.
     $settings = Staple_Config::get('layout');
     if (array_key_exists('default', $settings)) {
         if ($settings['default'] != '') {
             $this->_setLayout($settings['default']);
             $pageSettings = Staple_Config::get('page');
             if (array_key_exists('title', $pageSettings)) {
                 $this->layout->setTitle($pageSettings['title']);
             }
         }
     }
 }