/** * Given a list of migrations will compile dependencies and run the up method * of all needed migrations. * * @param string|array $migrations * * @return boolean */ public function up($migrations) { $migrations = (array) $migrations; $this->dc->reset(); //Add the migration to the DC, if it does not need to be run the list //returned will be empty foreach ($migrations as $migration) { $this->dc->addMigration($migration); } $toRun = $this->dc->getList(); //Start running the migrations foreach ($toRun as $class => $migration) { $result = $this->runMigration($migration); //If this is a bad migration then start the rollback process. if ($result == Migration::BAD) { return false; } // All is good so log the migration as having run $this->storage->add($class); } return true; }
/** * @param NodesProvider $storage */ public function __construct(StorageInterface $storage) { $node = new Node(); $node->valueType = 1; $data = $node->pack(); $blockSize = strlen(bin2hex($data)) / 2; $storage->setBlockSize($blockSize); $storage->lock(); if ($storage->isEmpty()) { $storage->add($data); } $storage->unlock(); $this->setStorage($storage); $this->setHeadNodePointer(0); }
private function saveNode(Node $node = null) { if ($node === null) { return; } $this->saveNode($node->rightNode); $this->saveNode($node->leftNode); if ($node->valueType === 1 && $node->subNode !== null) { $node->value = $this->saveNode($node->subNode); } if ($node->pointer === 0) { $node->pointer = $this->storage->add($node->pack()); } else { $this->storage->update($node->pointer, $node->pack()); } return $node->pointer; }
/** * Add identifier to storage * @param $identifier * @return mixed */ public function add($identifier) { return $this->onlineUsers->add($identifier); }
/** * Adds a value to the storage * * @param string $key * Id key of the element * @param mixed $value * The value to store */ public function add(MessageInterface $msg) { $this->storage->add($msg); }