/**
  * Performs the publishing operations required to set the version identified by $updateStruct->versionNo and
  * $updateStruct->id as the published one.
  *
  * @param int $contentId
  * @param int $versionNo
  * @param \eZ\Publish\SPI\Persistence\Content\MetadataUpdateStruct $metaDataUpdateStruct
  *
  * @return \eZ\Publish\SPI\Persistence\Content The published Content
  */
 public function publish($contentId, $versionNo, MetadataUpdateStruct $metaDataUpdateStruct)
 {
     // Change Content currentVersionNo to the published version
     $this->backend->update('Content', $contentId, array('_currentVersionNo' => $versionNo));
     // Update ContentInfo published flag and change the currentVersionNo to the published version
     $contentInfoUpdateData = array("currentVersionNo" => $versionNo, "isPublished" => true);
     // Update ContentInfo with set properties in $metaDataUpdateStruct
     foreach ($metaDataUpdateStruct as $propertyName => $propertyValue) {
         if (isset($propertyValue)) {
             if ($propertyName === "alwaysAvailable") {
                 $contentInfoUpdateData["alwaysAvailable"] = $propertyValue;
             } else {
                 if ($propertyName === "mainLanguageId") {
                     $contentInfoUpdateData["mainLanguageCode"] = $this->handler->contentLanguageHandler()->load($propertyValue)->languageCode;
                 } else {
                     $contentInfoUpdateData[$propertyName] = $propertyValue;
                 }
             }
         }
     }
     $this->backend->update('Content\\ContentInfo', $contentId, $contentInfoUpdateData, true);
     // Update VersionInfo with modified timestamp and published status
     $this->backend->updateByMatch('Content\\VersionInfo', array('_contentId' => $contentId, 'versionNo' => $versionNo), array("modificationDate" => $metaDataUpdateStruct->modificationDate, "status" => VersionInfo::STATUS_PUBLISHED));
     return $this->load($contentId, $versionNo);
 }
 /**
  * @see eZ\Publish\SPI\Persistence\Content\Location\Handler
  */
 public function setSectionForSubtree($locationId, $sectionId)
 {
     $location = $this->load($locationId);
     $aContentIds = array($location->contentId => true);
     $children = $this->backend->find('Content\\Location', array('pathString' => "{$location->pathString}%"));
     foreach ($children as $child) {
         $aContentIds[$child->contentId] = true;
     }
     $this->backend->updateByMatch('Content\\ContentInfo', array('id' => array_keys($aContentIds)), array('sectionId' => $sectionId), true);
 }
 /**
  * Update content objects
  *
  * Updates content objects, depending on the changed field definitions.
  *
  * A content type has a state which tells if its content objects yet have
  * been adapted.
  *
  * Flags the content type as updated.
  *
  * @param mixed $contentTypeId
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If type with $contentTypeId and Type::STATUS_DRAFT is not found
  *
  * @return void
  */
 public function publish($contentTypeId)
 {
     $draftType = $this->load($contentTypeId, Type::STATUS_DRAFT);
     try {
         $publishedType = $this->load($contentTypeId);
     } catch (NotFound $e) {
         // No published version of type, jump to last section where draft is promoted to defined
         goto updateType;
     }
     // @todo update content based on new type data change (field/scheme changes from $publishedType to $draftType)
     $this->backend->deleteByMatch('Content\\Type', array('id' => $contentTypeId, 'status' => Type::STATUS_DEFINED));
     $this->backend->deleteByMatch('Content\\Type\\FieldDefinition', array('_typeId' => $contentTypeId, '_status' => Type::STATUS_DEFINED));
     updateType:
     $this->backend->updateByMatch('Content\\Type', array('id' => $contentTypeId, 'status' => Type::STATUS_DRAFT), array('status' => Type::STATUS_DEFINED));
     $this->backend->updateByMatch('Content\\Type\\FieldDefinition', array('_typeId' => $contentTypeId, '_status' => Type::STATUS_DRAFT), array('_status' => Type::STATUS_DEFINED));
 }