Ejemplo n.º 1
0
 public static function unload($path)
 {
     Once::clear('Load::req', [$path]);
     Once::clear('Load::loadJSON', [$path]);
     Once::clear('Load::load', [$path]);
     Once::clear('Load::loadTEXT', [$path]);
 }
Ejemplo n.º 2
0
 public static function clear($name, $args = array())
 {
     $name = 'Cache::clear::' . $name;
     $hash = Once::clear($name, $args);
     Mem::delete($hash);
     return $hash;
 }
Ejemplo n.º 3
0
 public function testOnce()
 {
     $res = Once::exec('test', function ($a, $b) {
         return $a + $b;
     }, [4, 5]);
     $this->assertTrue(9 === $res);
     $res = Once::exec('test', function ($a, $b) {
         return $a + $b;
     }, [10, 5]);
     $this->assertTrue(9 !== $res);
     $this->assertTrue(15 === $res);
     Once::clear('test');
     $res = Once::exec('test', function () {
         $a = 1;
         $b = 2;
         return $a + $b;
     });
     $this->assertTrue(3 === $res);
     $res = Once::exec('test', function () {
         $a = 3;
         $b = 2;
         return $a * $b;
     });
     $this->assertTrue(3 === $res);
     Once::clear('test');
     $res = Once::exec('test', function () {
         $a = 3;
         $b = 2;
         return $a * $b;
     });
     $this->assertTrue(6 === $res);
     Once::clear('test');
     $res = Once::exec('test', function () {
         return true;
     });
     $this->assertTrue(true === $res);
     $res = Once::exec('test', function () {
         $a = 1;
         $b = 2;
         return $a + $b;
     }, array(), true);
     assert(3 === $res);
     $res = Once::exec('test', function () {
         $a = 3;
         $b = 2;
         return $a * $b;
     }, array(), true);
     assert(6 === $res);
 }
Ejemplo n.º 4
0
 public static function mkdir($isrc)
 {
     if (!is_file('vendor/autoload.php')) {
         throw new \Exception("You should setting chdir() on site root directory with vendor/ folder");
     }
     $conf = static::$conf;
     if (!$conf['fs']) {
         return;
     }
     $src = static::resolve($isrc);
     if (!is_dir($src)) {
         mkdir($src);
         Once::clear('Path::theme', [$isrc]);
         return $src;
     }
     return $src;
 }