public function addResource(ResourceInterface $resource, array $options=[]) {
		if ($resource->getResource()->isEmpty()) {
			throw new InputException('does not make sense to add empty resources to a collection');
		}
		
		$options = array_merge(self::$defaults, $options);
		
		$this->validator->claimUsedResourceIdentifier($resource);
		
		$this->resources[] = $resource;
		
		if ($options['includeContainedResources'] && $resource instanceof RecursiveResourceContainerInterface) {
			$this->addIncludedResourceObject(...$resource->getNestedContainedResourceObjects());
		}
	}
public function addResource(ResourceInterface $resource, array $options=[]) {
		if ($resource->getResource()->isEmpty()) {
			throw new InputException('does not make sense to add empty resources to a collection');
		}
		
		$options = array_merge(self::$defaults, $options);
		
		$this->validator->claimUsedResourceIdentifier($resource);
		
		$this->resources[] = $resource;
		
		if ($options['includeContainedResources'] && $resource instanceof RecursiveResourceContainerInterface) {
			$this->addIncludedResourceObject(...$resource->getNestedContainedResourceObjects());
		}
	}
public function addResource ( ResourceInterface $ resource , array $ options = [ ] ) { if ( $ resource -> getResource ( ) -> isEmpty ( ) ) { throw new InputException ( 'does not make sense to add empty resources to a collection' ) ; } $ options = array_merge ( self :: $ defaults , $ options ) ; $ this -> validator -> claimUsedResourceIdentifier ( $ resource ) ; $ this -> resources [ ] = $ resource ; if ( $ options [ 'includeContainedResources' ] && $ resource instanceof RecursiveResourceContainerInterface ) { $ this -> addIncludedResourceObject ( ... $ resource -> getNestedContainedResourceObjects ( ) ) ; } }
add a resource to the collection

adds included resources if found inside the resource's relationships, unless $options['includeContainedResources'] is set to false

@param ResourceInterface $resource
@param array             $options  optional {@see CollectionDocument::$defaults}

@throws InputException if the resource is empty
add a resource to the collection