/** * Adds a collection to the subcollection resource specified by this state instance. * * @param Collection $collection * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... * * @throws \Gedcomx\Rs\Client\Exception\GedcomxApplicationException * @return \Gedcomx\Rs\Client\CollectionState|null */ public function addCollection(Collection $collection, StateTransitionOption $option = null) { $link = $this->getLink(Rel::SUBCOLLECTIONS); if ($link == null || $link->getHref() == null) { throw new GedcomxApplicationException(sprintf("Collection at %s doesn't support adding subcollections.", $this->getUri())); } $entity = new Gedcomx(); $entity->setCollections(array($collection)); $request = $this->createAuthenticatedGedcomxRequest('POST', $link->getHref(), null, null, $entity->toJson()); return $this->stateFactory->createState('CollectionState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }