예제 #1
0
 /**
  * Returns true if the specified version is valid (can be added) to the collection. Otherwise, it MUST throw
  * an exception.
  *
  * @param DeltaInterface $version
  *
  * @return bool
  *
  * @throws CollectionException
  */
 public function validate(DeltaInterface $version)
 {
     if (!$version->isMigrated()) {
         throw new CollectionException('Invalid version specified: this collection only accepts deltas that are migrated.');
     }
     return parent::validate($version);
 }
예제 #2
0
 /**
  * @inheritdoc
  */
 public final function update(DeltaInterface $version)
 {
     if ($version->isMigrated()) {
         $result = $this->save($version);
     } else {
         $result = $this->delete($version);
     }
     return $result;
 }
예제 #3
0
 /**
  * Returns true if the operation is forced, or if the direction is the opposite to the state of the migration.
  *
  * @param DeltaInterface $version
  * @param OptionsInterface $options
  *
  * @return bool
  */
 protected function shouldMigrate(DeltaInterface $version, OptionsInterface $options)
 {
     return $options->isForced() || $options->getDirection()->isUp() ^ $version->isMigrated();
     // direction is opposite to state
 }