/** * @see ChangeOp::apply() * - a new claim with $snak as mainsnak gets added when $claimGuid is empty and $snak is set * - the claim's mainsnak gets set to $snak when $claimGuid and $snak are set */ public function apply(EntityDocument $entity, Summary $summary = null) { if (!$entity instanceof StatementListHolder) { throw new InvalidArgumentException('$entity must be a StatementListHolder'); } $statements = $entity->getStatements(); if (empty($this->statementGuid)) { $this->addStatement($statements, $entity->getId(), $summary); } else { $this->setStatement($statements, $summary); } $entity->setStatements($statements); }
/** * @see ChangeOp::apply() */ public function apply(EntityDocument $entity, Summary $summary = null) { if (!$entity instanceof StatementListHolder) { throw new InvalidArgumentException('$entity must be a StatementListHolder'); } $statements = $entity->getStatements(); $statement = $statements->getFirstStatementWithGuid($this->statementGuid); if ($statement === null) { throw new ChangeOpException("Entity does not have a statement with GUID {$this->statementGuid}"); } $qualifiers = $statement->getQualifiers(); $this->removeQualifier($qualifiers, $summary); $statement->setQualifiers($qualifiers); $entity->setStatements($statements); }
/** * @see ChangeOp::apply * * @param EntityDocument $entity * @param Summary|null $summary * * @throws InvalidArgumentException * @throws ChangeOpException */ public function apply(EntityDocument $entity, Summary $summary = null) { if (!$entity instanceof StatementListHolder) { throw new InvalidArgumentException('$entity must be a StatementListHolder'); } $statements = $entity->getStatements(); $statement = $statements->getFirstStatementWithGuid($this->guid); if ($statement === null) { throw new ChangeOpException("Entity does not have statement with GUID {$this->guid}"); } $statements->removeStatementsWithGuid($this->guid); $entity->setStatements($statements); $removedSnak = $statement->getMainSnak(); $this->updateSummary($summary, 'remove', '', $this->getSummaryArgs($removedSnak)); }
/** * @see ChangeOp::apply() */ public function apply(EntityDocument $entity, Summary $summary = null) { if (!$entity instanceof StatementListHolder) { throw new InvalidArgumentException('$entity must be a StatementListHolder'); } $statements = $entity->getStatements(); $statement = $statements->getFirstStatementWithGuid($this->statementGuid); if ($statement === null) { throw new ChangeOpException("Entity does not have claim with GUID {$this->statementGuid}"); } $references = $statement->getReferences(); $this->removeReference($references, $summary); if ($summary !== null) { $summary->addAutoSummaryArgs($this->getSnakSummaryArgs($statement->getMainSnak())); } $statement->setReferences($references); $entity->setStatements($statements); }