예제 #1
0
파일: Bucket.php 프로젝트: thefox/phpchat
 private function nodeAdd(Node $node, $sortNodes = true)
 {
     $nodeId = $node->getIdHexStr();
     $filePath = null;
     if ($this->getDatadirBasePath()) {
         #$filePath = $this->getDatadirBasePath().'/node_'.$node->getIdHexStr().'.yml';
         #$filePath = $this->getDatadirBasePath().'/node_'.$node->getIdHexStr().'_'.mt_rand(1000, 9999).'.yml';
         #$filePath = $this->getDatadirBasePath().'/node_'.substr($nodeId, -5).'_'.time().'.yml';
         #$filePath = $this->getDatadirBasePath().'/node_'.substr($nodeId, -5).'.yml';
         $filePath = $this->getDatadirBasePath() . '/node_' . $nodeId . '.yml';
     }
     if (!$node->getFilePath()) {
         $node->setFilePath($filePath);
     }
     $node->setDatadirBasePath($this->getDatadirBasePath());
     $node->setBucket($this);
     $node->setDataChanged(true);
     #$this->nodesId++;
     #$this->nodes[$this->nodesId] = $node;
     $this->nodes[$nodeId] = $node;
     $this->isFull();
     $this->setDataChanged(true);
     /*if($sortNodes){
     			$this->nodesSort();
     		}*/
 }
예제 #2
0
파일: Table.php 프로젝트: thefox/phpchat
 private function nodeRemove(Node $node)
 {
     $filesystem = new Filesystem();
     $nodeId = $node->getIdHexStr();
     if (isset($this->nodes[$nodeId])) {
         unset($this->nodes[$nodeId]);
     }
     #fwrite(STDOUT, 'node delete: '.$nodeId.' /'.$node->getFilePath().'/'.PHP_EOL);
     $filesystem->remove($node->getFilePath());
 }