Example #1
0
 protected function globDataFile($pattern, $asId = false)
 {
     $path = $this->folder;
     $folders = \Staq::App()->getExtensions();
     array_walk($folders, function (&$a) use($path) {
         $a = realpath($a . $path);
     });
     $folders = array_filter($folders, function ($a) {
         return !empty($a);
     });
     $files = [];
     foreach ($folders as $folder) {
         $fullFolder = $folder . DIRECTORY_SEPARATOR . $pattern;
         foreach (glob($fullFolder . '\\.*') as $filename) {
             if ($asId) {
                 $id = \UString::notStartWith($filename, $folder . '/');
                 \UString::doSubstrBeforeLast($id, '.');
                 $files[$id] = $id;
             } else {
                 $files[] = $filename;
             }
         }
     }
     if ($asId) {
         array_values($files);
     }
     return array_reverse($files);
 }
Example #2
0
 public function test_do_substr_before_last__no_match()
 {
     $original = 'example.com';
     $pop = \UString::doSubstrBeforeLast($original, '/');
     $this->assertEquals('', $original);
     $this->assertEquals('example.com', $pop);
 }