start() public static method

Start and boot the core
public static start ( ) : self
return self
Ejemplo n.º 1
0
 /**
  * Handle a request for a file
  *
  * @param Request $request HTTP request
  * @return Response
  */
 public function getResponse($request)
 {
     $response = new Response();
     $response->prepare($request);
     $path = implode('/', $request->getUrlSegments());
     if (!preg_match('~download-file/g(\\d+)$~', $path, $m)) {
         return $response->setStatusCode(400)->setContent('Malformatted request URL');
     }
     $this->application->start();
     $guid = (int) $m[1];
     $file = get_entity($guid);
     if (!$file instanceof ElggFile) {
         return $response->setStatusCode(404)->setContent("File with guid {$guid} does not exist");
     }
     $filenameonfilestore = $file->getFilenameOnFilestore();
     if (!is_readable($filenameonfilestore)) {
         return $response->setStatusCode(404)->setContent('File not found');
     }
     $last_updated = filemtime($filenameonfilestore);
     $etag = '"' . $last_updated . '"';
     $response->setPublic()->setEtag($etag);
     if ($response->isNotModified($request)) {
         return $response;
     }
     $response = new BinaryFileResponse($filenameonfilestore, 200, array(), false, 'attachment');
     $response->prepare($request);
     $expires = strtotime('+1 year');
     $expires_dt = (new DateTime())->setTimestamp($expires);
     $response->setExpires($expires_dt);
     $response->setEtag($etag);
     return $response;
 }
Ejemplo n.º 2
0
 /**
  * Add CLI tools to the console application
  * @return void
  */
 protected function bootstrap()
 {
     if ($this->isInstalled()) {
         Application::start();
         $commands = elgg_trigger_plugin_hook('commands', 'cli', null, $this->getCommands());
         foreach ($commands as $command) {
             if (class_exists($command) && is_subclass_of($command, Command::class)) {
                 $this->console->add(new $command());
             }
         }
     } else {
         $this->console->add(new InstallCommand());
     }
 }
Ejemplo n.º 3
0
<?php

$autoload_root = dirname(__DIR__);
if (!is_file("{$autoload_root}/vendor/autoload.php")) {
    $autoload_root = dirname(dirname(dirname($autoload_root)));
}
require_once "{$autoload_root}/vendor/autoload.php";
\Elgg\Application::start();
elgg_deprecated_notice('You should load the core using \\Elgg\\Application::start() instead of including start.php', "2.0.0");