/**
  * Generates entries to place inside web/.htaccess file.
  * Entries should be placed just after following rule: RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
  *
  * @return string
  */
 public function getWebCode()
 {
     $path = rtrim($this->finder->getRealCacheDir(), '/\\');
     //@formatter:off
     return static::HEADER . "RewriteCond %{REQUEST_METHOD} !^(GET|HEAD) [OR]\n" . "RewriteCond %{QUERY_STRING} !^\$\n" . "RewriteRule . - [S=3]\n" . "\n" . "RewriteCond {$path}/\$1/index.html -f\n" . "RewriteRule ^(.*) {$path}/\$1/index.html [L]\n" . "\n" . "RewriteCond {$path}/\$1/index.js -f\n" . "RewriteRule ^(.*) {$path}/\$1/index.js [L]\n" . "\n" . "RewriteCond {$path}/\$1/index.bin -f\n" . "RewriteRule ^(.*) {$path}/\$1/index.bin [L]\n" . static::FOOTER;
     //@formatter:on
 }
Exemplo n.º 2
0
 /**
  * Provides list of all cached elements.
  *
  * @param null|string $parent Branch to start from. Eg. you can specify /sandbox and you'll get /sandbox,
  *     /sandbox/info but not /test or /test/sandbox.
  *
  * @return array[]
  */
 public function getEntriesList($parent = null)
 {
     $filesList = $this->finder->getFilesList();
     $basePath = $this->finder->getRealCacheDir();
     $basePathLength = mb_strlen($basePath);
     $entries = array();
     foreach ($filesList as $e) {
         $entry = mb_substr($e->getPath(), $basePathLength);
         if ($entry === '') {
             $entry = '/';
         } elseif (DIRECTORY_SEPARATOR !== '/') {
             //Why elseif and not if below? Simple - it's waste of time to call str_replace when $entry was empty before
             $entry = str_replace($entry, DIRECTORY_SEPARATOR, '/');
             //Did I mention I hate Windos?
         }
         if ($parent && strpos($entry, $parent) !== 0) {
             continue;
         }
         $entries[] = $entry;
     }
     return $entries;
 }