Jarves\Jarves::getRootDir PHP Method

getRootDir() public method

public getRootDir ( ) : string
return string
    public function getRootDir()
    {
        return $this->rootDir;
    }

Usage Example

Example #1
0
 public function search($query, Condition $condition = null, $max = 20)
 {
     $result = [];
     $finder = Finder::create()->in($webRoot = sprintf('%s/../web', $this->jarves->getRootDir()))->followLinks()->exclude('cache')->exclude('bundles/jarves');
     $query = trim($query);
     $regexSearch = true;
     $regex = '/' . str_replace(['\\*', '_'], ['.*', '.'], preg_quote($query, '/')) . '/';
     if (preg_match('/^[a-zA-Z\\_\\-\\.]+\\*?$/', $query)) {
         //onl query like 'test*';
         $regexSearch = false;
         $query = rtrim($query, '*');
     }
     /** @var SplFileInfo $file */
     foreach ($finder as $file) {
         $path = substr($file->getPath() . '/' . $file->getFilename(), strlen($webRoot));
         if ($regexSearch) {
             if (!preg_match($regex, $file->getFilename())) {
                 continue;
             }
         } else {
             if (0 !== strpos($file->getFilename(), $query)) {
                 continue;
             }
         }
         $result[] = ['path' => $path, '_label' => $path];
         if (count($result) >= $max) {
             return $result;
         }
     }
     return $result;
 }
All Usage Examples Of Jarves\Jarves::getRootDir