Example #1
0
 public function __construct($namespace)
 {
     $normalNamespace = Key::normalKey($namespace);
     //get normal key
     $regexNamespace = str_replace('\\', '\\\\', $normalNamespace);
     //for regex, since \ is special char
     //find all where names starts with namespace
     parent::__construct('user', "/^{$regexNamespace}/");
 }
Example #2
0
 /**
  * Deletes the namespace heirarchy.
  * 
  * Deletes the namespace heirarchy. Deletes the directory and all subdirectories and
  * files recursively.
  * 
  * @param string $namespace The namespace heirarchy to delete.
  */
 public function deleteNamespace($namespace)
 {
     $normal = Key::normalKey($namespace);
     $directory = $this->getCachePath($normal);
     //delete directory and children
     if (is_dir($directory)) {
         $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST);
         foreach ($files as $file) {
             $f = $file->isDir() ? 'rmdir' : 'unlink';
             $f($file->getRealPath());
         }
         rmdir($directory);
     }
     //also delete the file
     if (file_exists($normal)) {
         unlink($normal);
     }
 }