示例#1
0
 public function testOverrideRoutesIntoChildConfigurations()
 {
     $routes = new \Nano\Routes();
     include $this->files->get($this, '/parents/default/routes.php');
     include $this->files->get($this, '/parents/basic-child/routes.php');
     include $this->files->get($this, '/parents/ext-child/routes.php');
     $expectedRoutes = $routes;
     unset($routes);
     $this->builder->setSource($this->files->get($this, '/parents'));
     $this->builder->setDestination($this->files->get($this, '/settings'));
     $this->builder->build('ext-child');
     self::assertFileExists($this->files->get($this, '/settings/routes'));
     $data = file_get_contents($this->files->get($this, '/settings/routes'));
     /** @var \Nano\Routes $actualRoutes */
     $actualRoutes = unSerialize($data);
     self::assertEquals($expectedRoutes, $actualRoutes);
 }
 /**
  * This method is overridden to possibly cache (serialize) the element tree if the caching
  * is enabled in the package configuration file.
  * @param  string $fileName  the absolute file name to parse
  * @return  SDElement  the root element of the tree, possibly retrieved from the cache
  * @throws  SDParserException  if something goes wrong
  */
 function parse($fileName) {
   $pkg = Package::getPackageByName('html');
   if($pkg->getProperty('cache.parserCache', false)) {
     $path = $pkg->getProperty('cache.parserCachePath', '/tmp');
     $cacheFile = $path . '/' . crc32($fileName) . '_' . baseName($fileName);
     if(file_exists($cacheFile) && filemtime($cacheFile) >= filemtime($fileName)) {
       $rv = unSerialize(file_get_contents($cacheFile));
       $rv->setDocument($this->doc);
       return $rv;
     } else {
       $rv = parent::parse($fileName);
       $rv->setDocument(null);
       flock($fp = fopen($fileName, 'r'), LOCK_EX);
       file_put_contents($cacheFile, serialize($rv));
       flock($fp, LOCK_UN);
       touch($cacheFile, filemtime($fileName));
       $rv->setDocument($this->doc);
       return $rv;
     }
   } else {
     return parent::parse($fileName);
   }
 }
示例#3
0
文件: Php.php 项目: visor/nano
 /**
  * @return \Nano\Routes
  * @param string $fileName
  */
 public function readRoutes($fileName)
 {
     $result = file_get_contents($fileName);
     $result = unSerialize($result);
     return $result;
 }
示例#4
0
 protected function listField(Setting $setting, $name, $value)
 {
     $options = unSerialize($setting->values);
     return Nano::helper()->ui()->selectField($name, $setting->title, $options, $value, self::CSS, $setting->description);
 }
示例#5
0
function readDataFile($data_file)
{
    global $node;
    $datafilep = @fOpen($data_file, 'rb');
    if (!$datafilep) {
        write_log("Cannot open {$data_file} for reading! Using cluster data from configuration. This will reset *all* states!");
        return 1;
    }
    $datafilesize = fileSize($data_file);
    $save_struct = @fRead($datafilep, $datafilesize);
    $node = unSerialize($save_struct);
    fClose($datafilep);
}
示例#6
0
文件: HttpTest.php 项目: visor/nano
 /**
  * @return array
  * @throws Exception
  */
 protected function getCodeCoverage()
 {
     if (null === $this->request) {
         return array();
     }
     $url = $this->getUrl('/?PHPUNIT_SELENIUM_TEST_ID=' . $this->testId);
     $buffer = @file_get_contents($url);
     if (false === $buffer) {
         return array();
     }
     $coverageData = unSerialize($buffer);
     if (is_array($coverageData)) {
         return $this->matchLocalAndRemotePaths($coverageData);
     }
     throw new \Exception('Empty or invalid code coverage data received from url "' . $url . '"');
 }