Beispiel #1
0
 /**
  * Returns true if the specified version is valid (can be added) to the collection. Otherwise, it MUST throw
  * an exception.
  *
  * @param VersionInterface $version
  *
  * @return bool
  *
  * @throws CollectionException
  * @throws \Baleen\Migrations\Exception\Version\Collection\AlreadyExistsException
  */
 public function validate(VersionInterface $version)
 {
     if (!$version->isMigrated()) {
         throw new CollectionException('Invalid version specified. This collection only accepts versions that are migrated.');
     }
     return parent::validate($version);
 }
 /**
  * @inheritdoc
  */
 public final function update(VersionInterface $version)
 {
     if ($version->isMigrated()) {
         $result = $this->save($version);
     } else {
         $result = $this->delete($version);
     }
     return $result;
 }
 /**
  * Returns true if the operation is forced, or if the direction is the opposite to the state of the migration.
  *
  * @param VersionInterface $version
  * @param OptionsInterface $options
  *
  * @return bool
  */
 protected function shouldMigrate(VersionInterface $version, OptionsInterface $options)
 {
     return $options->isForced() || $options->isDirectionUp() ^ $version->isMigrated();
     // direction is opposite to state
 }