protected function _loadLogger() { $this->_container->set('logger', function (Collection $container) { /** @var Config $config */ $config = $container->get('settings'); $logger = new Logger($config->get('app.name')); $type = $config->get('logger.type'); //TODO add more types $handler = null; $filename = $config->get('logger.filename', 'app.log'); switch ($type) { case 'rotating': $handler = new RotatingFileHandler(ROOT_PATH . '/logs/' . $filename, $config->get('rotating_times', 10)); break; } $logger->pushHandler($handler); return $logger; }); }
/** * @param string $sql * @param array $binding * * @return BaseModel[]|Collection */ public static function findAll($sql = null, $binding = []) { $model = new static(); $result = R::findAll($model->_table, $sql, $binding); $collection = new Collection(); foreach ($result as $key => $bean) { $innerModel = new static(); $innerModel->_bean = $bean; $collection->set($key, $innerModel); } return $collection; }
public function redirect($url, $status = 302) { $this->setStatus($status); $this->_headers->set('Location', $url); return $this; }