getPath() public method

Subdirectories are automatically parsed to correct filesystem. For example: $bar = getPath('root/foo/bar');
public getPath ( string $name ) : string
$name string Name of path
return string
Exemplo n.º 1
0
Arquivo: Cache.php Projeto: bolt/bolt
 /**
  * {@inheritdoc}
  */
 public function check(ExceptionControllerInterface $exceptionController)
 {
     $path = $this->resourceManager->getPath('cache');
     if (!is_dir($path)) {
         return $exceptionController->systemCheck(Validator::CHECK_CACHE, [], ['path' => $path]);
     }
     if (!is_writable($path)) {
         return $exceptionController->systemCheck(Validator::CHECK_CACHE, [], ['path' => $path]);
     }
     return null;
 }
Exemplo n.º 2
0
 /**
  * This check looks for the presence of the .htaccess file inside the web directory.
  * It is here only as a convenience check for users that install the basic version of Bolt.
  *
  * If you see this error and want to disable it, call $config->getVerifier()->disableApacheChecks();
  * inside your bootstrap.php file, just before the call to $config->verify().
  *
  * {@inheritdoc}
  */
 public function check(ExceptionControllerInterface $exceptionController)
 {
     $request = Request::createFromGlobals();
     $serverSoftware = $request->server->get('SERVER_SOFTWARE', '');
     $isApache = strpos($serverSoftware, 'Apache') !== false;
     if ($this->resourceManager->getVerifier()->disableApacheChecks === true || !$isApache) {
         return null;
     }
     $path = $this->resourceManager->getPath('web/.htaccess');
     if (is_readable($path)) {
         return null;
     }
     return $exceptionController->systemCheck(Validator::CHECK_APACHE);
 }
 /**
  * @param string          $locale
  * @param string          $fileContent
  * @param ResourceManager $resources
  */
 protected function initializeFakeTranslationFiles($locale, $fileContent, ResourceManager $resources)
 {
     $fakeAppRoot = $resources->getPath('cache');
     $fakeTranslationDir = "{$fakeAppRoot}/app/resources/translations/{$locale}";
     (new Filesystem())->mkdir($fakeTranslationDir);
     file_put_contents("{$fakeTranslationDir}/messages.{$locale}.yml", $fileContent);
     $resources->setPath('root', $fakeAppRoot);
 }
 public function testBoltAppSetup()
 {
     $config = new ResourceManager(TEST_ROOT);
     $app = new Application(array('resources' => $config));
     $this->assertEquals($config->getPaths(), $app['resources']->getPaths());
     // Test that the Application has initialised the resources, injecting in config values.
     $this->assertContains(TEST_ROOT . "/theme", $config->getPath("theme"));
     $this->assertNotEmpty($config->getUrl("canonical"));
 }
Exemplo n.º 5
0
Arquivo: Queue.php Projeto: bolt/bolt
 /**
  * Insert jQuery, if it's not inserted already.
  *
  * Some of the patterns that 'match' are:
  * - jquery.js
  * - jquery.min.js
  * - jquery-latest.js
  * - jquery-latest.min.js
  * - jquery-1.8.2.min.js
  * - jquery-1.5.js
  *
  * @param Request  $request
  * @param Response $response
  */
 protected function addJquery(Request $request, Response $response)
 {
     if (!$this->config->get('general/add_jquery', false) && !$this->config->get('theme/add_jquery', false)) {
         return;
     }
     if (Zone::isFrontend($request) === false) {
         return;
     }
     $html = $response->getContent();
     $regex = '/<script(.*)jquery(-latest|-[0-9\\.]*)?(\\.min)?\\.js/';
     if (!preg_match($regex, $html)) {
         $jqueryfile = $this->resources->getPath('app/view/js/jquery-2.2.4.min.js');
         $asset = (new Snippet())->setLocation(Target::BEFORE_JS)->setCallback('<script src="' . $jqueryfile . '"></script>');
         $this->injector->inject($asset, $asset->getLocation(), $response);
     }
 }
Exemplo n.º 6
0
 /**
  * Insert jQuery, if it's not inserted already.
  *
  * Some of the patterns that 'match' are:
  * - jquery.js
  * - jquery.min.js
  * - jquery-latest.js
  * - jquery-latest.min.js
  * - jquery-1.8.2.min.js
  * - jquery-1.5.js
  *
  * @param string $html
  *
  * @return string HTML
  */
 protected function addJquery($html)
 {
     if (!$this->config->get('general/add_jquery', false) && !$this->config->get('theme/add_jquery', false)) {
         return $html;
     }
     $zone = Zone::FRONTEND;
     if ($request = $this->requestStack->getCurrentRequest()) {
         $zone = Zone::get($request);
     }
     $regex = '/<script(.*)jquery(-latest|-[0-9\\.]*)?(\\.min)?\\.js/';
     if ($zone === Zone::FRONTEND && !preg_match($regex, $html)) {
         $jqueryfile = $this->resources->getPath('app/view/js/jquery-2.1.4.min.js');
         $asset = (new Snippet())->setLocation(Target::BEFORE_JS)->setCallback('<script src="' . $jqueryfile . '"></script>');
         $html = $this->injector->inject($asset, $asset->getLocation(), $html);
     }
     return $html;
 }
Exemplo n.º 7
0
 protected function doDatabaseSqliteCheck(Controller\Exception $exceptionController, array $dbConfig)
 {
     if (extension_loaded('pdo_sqlite') === false) {
         return $exceptionController->databaseDriver('missing', 'SQLite', 'pdo_sqlite');
     }
     // If in-memory connection, skip path checks
     if (isset($dbConfig['memory']) && $dbConfig['memory'] === true) {
         return null;
     }
     $fs = new Filesystem();
     $file = $dbConfig['path'];
     // If the file is present, make sure it is writable
     if ($fs->exists($file)) {
         try {
             $fs->touch($file);
         } catch (IOException $e) {
             return $exceptionController->databasePath('file', $file, 'is not writable');
         }
         return null;
     }
     // If the file isn't present, make sure the directory
     // exists and is writable so the file can be created
     $dir = dirname($file);
     if (!$fs->exists($dir)) {
         // At this point, it is possible that the site has been moved and
         // the configured Sqlite database file path is no longer relevant
         // to the site's root path
         $cacheJson = $this->resourceManager->getPath('cache/config-cache.json');
         if ($fs->exists($cacheJson)) {
             $fs->remove($cacheJson);
             $this->config->initialize();
             if (!$fs->exists($dir)) {
                 return $exceptionController->databasePath('folder', $dir, 'does not exist');
             }
         } else {
             return $exceptionController->databasePath('folder', $dir, 'does not exist');
         }
     }
     try {
         $fs->touch($dir);
     } catch (IOException $e) {
         return $exceptionController->databasePath('folder', $dir, 'is not writable');
     }
     return null;
 }
Exemplo n.º 8
0
 public function testBoltAppSetup()
 {
     $config = new ResourceManager(new \Pimple(['rootpath' => TEST_ROOT, 'pathmanager' => new PlatformFileSystemPathFactory()]));
     $config->compat();
     $app = new Application(['resources' => $config]);
     $this->assertEquals($config->getPaths(), $app['resources']->getPaths());
     // Test that the Application has initialised the resources, injecting in config values.
     $this->assertContains(Path::fromString(TEST_ROOT . '/theme')->string(), $config->getPath('theme'));
     $this->assertNotEmpty($config->getUrl('canonical'));
 }
Exemplo n.º 9
0
 /**
  * Internal pre-boot checks.
  *
  * @param ResourceManager $resourceManager
  */
 private function preBoot(ResourceManager $resourceManager)
 {
     PreBoot\ConfigurationFile::checkConfigFiles(['config', 'contenttypes', 'menu', 'permissions', 'routing', 'taxonomy'], $resourceManager->getPath('src/../app/config'), $resourceManager->getPath('config'));
 }