Пример #1
0
 /**
  * Do whatever processing this filter needs to do.
  * By default it should not return anything during
  * normal execution. However, when an abnormal state
  * is found, it should return an instance of
  * CodeIgniter\HTTP\Response. If it does, script
  * execution will end and that Response will be
  * sent back to the client, allowing for error pages,
  * redirects, etc.
  *
  * @param \CodeIgniter\HTTP\RequestInterface $request
  *
  * @return mixed
  */
 public function before(RequestInterface $request)
 {
     if ($request->isCLI()) {
         return;
     }
     $security = Services::security();
     $security->CSRFVerify($request);
 }
Пример #2
0
 /**
  * Constructor
  * 
  * @param string $viewPath
  * @param type $loader
  * @param bool $debug
  * @param Logger $logger
  */
 public function __construct(string $viewPath = null, $loader = null, bool $debug = null, Logger $logger = null)
 {
     $this->viewPath = rtrim($viewPath, '/ ') . '/';
     $this->loader = is_null($loader) ? Services::locator() : $loader;
     $this->logger = is_null($logger) ? Services::logger() : $logger;
     $this->debug = is_null($debug) ? CI_DEBUG : $debug;
 }
Пример #3
0
 /**
  * A convenience method for working with the timer.
  * If no parameter is passed, it will return the timer instance,
  * otherwise will start or stop the timer intelligently.
  *
  * @param string|null $name
  *
  * @return $this|\CodeIgniter\Debug\Timer|mixed
  */
 function timer(string $name = null)
 {
     $timer = \Config\Services::timer();
     if (empty($name)) {
         return $timer;
     }
     if ($timer->has($name)) {
         return $timer->stop($name);
     }
     return $timer->start($name);
 }
Пример #4
0
 public function loadDependencies()
 {
     if ($this->db === null) {
         $this->db = \Config\Database::connect($this->DBGroup);
         $this->db->initialize();
     }
     if ($this->migrations === null) {
         // Ensure that we can run migrations
         $config = new \Config\Migrations();
         $config->enabled = true;
         $this->migrations = Services::migrations($config, $this->db);
         $this->migrations->setSilent(true);
     }
     if ($this->seeder === null) {
         $this->seeder = \Config\Database::seeder($this->DBGroup);
         $this->seeder->setSilent(true);
     }
 }