/**
  * Creates an array of SPI location create structs from given array of API location create structs.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
  *
  * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $locationCreateStruct
  * @param \eZ\Publish\API\Repository\Values\Content\Location $parentLocation
  * @param mixed $mainLocation
  * @param mixed $contentId
  * @param mixed $contentVersionNo
  *
  * @return \eZ\Publish\SPI\Persistence\Content\Location\CreateStruct
  */
 public function buildSPILocationCreateStruct($locationCreateStruct, APILocation $parentLocation, $mainLocation, $contentId, $contentVersionNo)
 {
     if ($locationCreateStruct->priority !== null && !is_int($locationCreateStruct->priority)) {
         throw new InvalidArgumentValue('priority', $locationCreateStruct->priority, 'LocationCreateStruct');
     }
     if (!is_bool($locationCreateStruct->hidden)) {
         throw new InvalidArgumentValue('hidden', $locationCreateStruct->hidden, 'LocationCreateStruct');
     }
     if ($locationCreateStruct->remoteId !== null && (!is_string($locationCreateStruct->remoteId) || empty($locationCreateStruct->remoteId))) {
         throw new InvalidArgumentValue('remoteId', $locationCreateStruct->remoteId, 'LocationCreateStruct');
     }
     if ($locationCreateStruct->sortField !== null && !$this->isValidLocationSortField($locationCreateStruct->sortField)) {
         throw new InvalidArgumentValue('sortField', $locationCreateStruct->sortField, 'LocationCreateStruct');
     }
     if ($locationCreateStruct->sortOrder !== null && !$this->isValidLocationSortOrder($locationCreateStruct->sortOrder)) {
         throw new InvalidArgumentValue('sortOrder', $locationCreateStruct->sortOrder, 'LocationCreateStruct');
     }
     $remoteId = $locationCreateStruct->remoteId;
     if (null === $remoteId) {
         $remoteId = $this->getUniqueHash($locationCreateStruct);
     } else {
         try {
             $this->locationHandler->loadByRemoteId($remoteId);
             throw new InvalidArgumentException('$locationCreateStructs', "Another Location with remoteId '{$remoteId}' exists");
         } catch (NotFoundException $e) {
             // Do nothing
         }
     }
     return new SPILocationCreateStruct(array('priority' => $locationCreateStruct->priority, 'hidden' => $locationCreateStruct->hidden, 'invisible' => $locationCreateStruct->hidden === true || $parentLocation->invisible, 'remoteId' => $remoteId, 'contentId' => $contentId, 'contentVersion' => $contentVersionNo, 'pathIdentificationString' => null, 'mainLocationId' => $mainLocation, 'sortField' => $locationCreateStruct->sortField !== null ? $locationCreateStruct->sortField : Location::SORT_FIELD_NAME, 'sortOrder' => $locationCreateStruct->sortOrder !== null ? $locationCreateStruct->sortOrder : Location::SORT_ORDER_ASC, 'parentId' => $locationCreateStruct->parentLocationId));
 }
 /**
  * Creates an array of SPI location create structs from given array of API location create structs
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
  *
  * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $locationCreateStruct
  * @param \eZ\Publish\API\Repository\Values\Content\Location $parentLocation
  * @param mixed $mainLocation
  * @param mixed $contentId
  * @param mixed $contentVersionNo
  *
  * @return \eZ\Publish\SPI\Persistence\Content\Location\CreateStruct
  */
 public function buildSPILocationCreateStruct($locationCreateStruct, APILocation $parentLocation, $mainLocation, $contentId, $contentVersionNo)
 {
     if ($locationCreateStruct->priority !== null && !is_int($locationCreateStruct->priority)) {
         throw new InvalidArgumentValue("priority", $locationCreateStruct->priority, "LocationCreateStruct");
     }
     if (!is_bool($locationCreateStruct->hidden)) {
         throw new InvalidArgumentValue("hidden", $locationCreateStruct->hidden, "LocationCreateStruct");
     }
     if ($locationCreateStruct->remoteId !== null && (!is_string($locationCreateStruct->remoteId) || empty($locationCreateStruct->remoteId))) {
         throw new InvalidArgumentValue("remoteId", $locationCreateStruct->remoteId, "LocationCreateStruct");
     }
     if ($locationCreateStruct->sortField !== null && !$this->isValidLocationSortField($locationCreateStruct->sortField)) {
         throw new InvalidArgumentValue("sortField", $locationCreateStruct->sortField, "LocationCreateStruct");
     }
     if ($locationCreateStruct->sortOrder !== null && !$this->isValidLocationSortOrder($locationCreateStruct->sortOrder)) {
         throw new InvalidArgumentValue("sortOrder", $locationCreateStruct->sortOrder, "LocationCreateStruct");
     }
     $remoteId = $locationCreateStruct->remoteId;
     if (null === $remoteId) {
         $remoteId = $this->getUniqueHash($locationCreateStruct);
     } else {
         try {
             $this->locationHandler->loadByRemoteId($remoteId);
             throw new InvalidArgumentException("\$locationCreateStructs", "Another Location with remoteId '{$remoteId}' exists");
         } catch (NotFoundException $e) {
             // Do nothing
         }
     }
     return new SPILocationCreateStruct(array("priority" => $locationCreateStruct->priority, "hidden" => $locationCreateStruct->hidden, "invisible" => $locationCreateStruct->hidden === true || $parentLocation->invisible, "remoteId" => $remoteId, "contentId" => $contentId, "contentVersion" => $contentVersionNo, "pathIdentificationString" => null, "mainLocationId" => $mainLocation, "sortField" => $locationCreateStruct->sortField !== null ? $locationCreateStruct->sortField : Location::SORT_FIELD_NAME, "sortOrder" => $locationCreateStruct->sortOrder !== null ? $locationCreateStruct->sortOrder : Location::SORT_ORDER_ASC, "parentId" => $locationCreateStruct->parentLocationId));
 }