Пример #1
0
 /**
  * Updates the specified source description.
  *
  * @param Gedcomx|SourceDescription $description
  * @param StateTransitionOption $option,...
  *
  * @return SourceDescriptionState
  */
 public function update($description, StateTransitionOption $option = null)
 {
     $entity = null;
     if ($description instanceof SourceDescription) {
         $entity = new Gedcomx();
         $entity->setSourceDescriptions(array($description));
     } else {
         $entity = $description;
     }
     /** @var EntityEnclosingRequest $request */
     $request = $this->createAuthenticatedGedcomxRequest('POST', $this->getSelfUri(), [], null, $entity->toJson());
     return $this->stateFactory->createState('SourceDescriptionState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken);
 }
 /**
  * Moves the current source description to the specified collection.
  *
  * @param CollectionState $collection
  * @param StateTransitionOption $options,...
  * @return FamilySearchSourceDescriptionState|null
  */
 public function moveToCollection(CollectionState $collection, StateTransitionOption $options = null)
 {
     $link = $collection->getLink(Rel::SOURCE_DESCRIPTIONS);
     if ($link == null || $link->getHref() == null) {
         return null;
     }
     /** @var SourceDescription $me */
     $me = $this->getSourceDescription();
     if ($me == null || $me->getId() == null) {
         return null;
     }
     /** @var Gedcomx $gx */
     $gx = new Gedcomx();
     $sd = new SourceDescription();
     $sd->setId($me->getId());
     $gx->setSourceDescriptions(array($sd));
     $request = $this->createAuthenticatedRequest('POST', $link->getHref(), FamilySearchRequest::getMediaTypes(), null, $gx->toJson());
     return $this->stateFactory->createState('SourceDescriptionState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken);
 }