Deleting content items

@param null $contentId content id
162963
public function actionRemoveContentElements($contentId = null)
    {
        $query = CmsContentElement::find();
        if ($contentId) {
            $query->andWhere(['content_id' => $contentId]);
        }

        if (!$count = $query->count()) {
            $this->stdout("Content elements not found!\n", Console::BOLD);
            return;
        }

        $this->stdout("1. Found elements: {$count}!\n", Console::BOLD);

        foreach ($query->orderBy([
            'content_id' => SORT_ASC,
            'id' => SORT_ASC
        ])->each(10) as $cmsContentElement) {
            $this->stdout("\t{$cmsContentElement->id}: {$cmsContentElement->name}");

            if ($cmsContentElement->delete()) {
                $this->stdout(" - deleted\n", Console::FG_GREEN);
            } else {
                $this->stdout(" - NOT deleted\n", Console::FG_RED);
            }
        }
    }
139235
def delete_content_item(access_token, content_item_id):
	'''
	
	'''

	headers = {'Authorization': 'Bearer ' + str(access_token)}
	content_item_url =\
		construct_content_item_url(enrichment_url, content_item_id)

	request = requests.delete(content_item_url, headers=headers)
	return {'status': request.status_code, 'message': request.text}
552090
public function deleteTranslationFromContent($contentId, $languageCode)
    {
        try {
            return $this->innerGateway->deleteTranslationFromContent($contentId, $languageCode);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
148931
private function deleteTranslationFromContentObject($contentId, $languageId)
    {
        $query = $this->connection->createQueryBuilder();
        $query->update('ezcontentobject')
            // parameter for bitwise operation has to be placed verbatim (w/o binding) for this to work cross-DBMS
            ->set('language_mask', 'language_mask & ~ ' . $languageId)
            ->set('modified', ':now')
            ->where('id = :contentId')
            ->andWhere(
            // make sure removed translation is not the last one (incl. alwaysAvailable)
                $query->expr()->andX(
                    'language_mask & ~ ' . $languageId . ' <> 0',
                    'language_mask & ~ ' . $languageId . ' <> 1'
                )
            )
            ->setParameter(':now', time())
            ->setParameter(':contentId', $contentId)
        ;

        $rowCount = $query->execute();

        // no rows updated means that most likely somehow it was the last remaining translation
        if ($rowCount === 0) {
            throw new BadStateException(
                '$languageCode',
                'Specified translation is the only one Content Object Version has'
            );
        }
    }
306104
public function deleteAction($contentId)
    {
        $repository = $this->get('open_orchestra_model.repository.content');
        $content = $repository->findOneByContentId($contentId);
        $this->denyAccessUnlessGranted(ContributionActionInterface::DELETE, $content);

        if (!$this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::DELETE, $content)) {
            throw new ContentNotDeletableException();
        }

        $repository->softDeleteContent($contentId);
        $this->dispatchEvent(ContentEvents::CONTENT_DELETE, new ContentDeleteEvent($contentId, $content->getSiteId()));

        return array();
    }
831973
public function contentVersion($contentId, $versionNo)
    {
        if ($this->allCleared === true || $this->isSwitchedOff()) {
            return;
        }

        // todo Once we can require 2.2.2+, simplify to just invalidate "content-{$contentId}-version-{$versionNo}"
        $this->cache->deleteItem("ez-content-version-info-${contentId}-${versionNo}");
        $this->cache->invalidateTags(["content-${contentId}-version-list", "content-{$contentId}-version-{$versionNo}"]);
    }
1304156
public function delete($id=null)
    {
      if ($id) {
        $url = URIResource::Make($this->path, array($id));
      } else {
        $url = URIResource::Make($this->path, array($this->id));
      }

      $this->client->delete($url);
    }
909111
public static function purgeByParentAndContentObjectID( $parentNodeID, $contentObjectID )
    {
        eZDB::instance()->query(
            "DELETE FROM eznode_assignment WHERE parent_node=" . (int)$parentNodeID ." AND contentobject_id=" . (int)$contentObjectID
        );
    }
153427
static function purgeForObject( $contentObjectID )
    {
        if ( !is_numeric( $contentObjectID ) )
            return false;
        $db = eZDB::instance();
        $db->begin();
        $db->query( "DELETE FROM ezcontentobject_trash WHERE contentobject_id='$contentObjectID'" );
        $db->commit();
    }
934799
public function deleteNames($contentId, $versionNo = null)
    {
        $query = $this->dbHandler->createDeleteQuery();
        $query->deleteFrom('ezcontentobject_name')
            ->where(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('contentobject_id'),
                    $query->bindValue($contentId, null, \PDO::PARAM_INT)
                )
            );

        if (isset($versionNo)) {
            $query->where(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('content_version'),
                    $query->bindValue($versionNo, null, \PDO::PARAM_INT)
                )
            );
        }

        $query->prepare()->execute();
    }
552466
public function purgeForContent($contentId, $locationIds = [])
    {
        if ($this->isSwitchedOff() || !method_exists($this->purgeClient, 'purgeForContent')) {
            return;
        }

        $this->purgeClient->purgeForContent($contentId, $locationIds);
    }
273710
public function deleteTranslationFromContent($contentId, $languageCode)
    {
        $language = $this->languageHandler->loadByLanguageCode($languageCode);

        $this->connection->beginTransaction();
        try {
            $this->deleteTranslationFromContentVersions($contentId, $language->id);
            $this->deleteTranslationFromContentNames($contentId, $languageCode);
            $this->deleteTranslationFromContentObject($contentId, $language->id);

            $this->connection->commit();
        } catch (DBALException $e) {
            $this->connection->rollBack();
            throw $e;
        }
    }
1304354
public function stateAssign($contentId)
    {
        if ($this->allCleared === true || $this->isSwitchedOff()) {
            return;
        }

        $this->cache->invalidateTags(['content-' . $contentId]);
    }
546453
static function removeByObjectId( $contentobjectID, $contentobjectAttributeId = null )
    {
        $cond = array( 'contentobject_id' => $contentobjectID );
        if ( $contentobjectAttributeId !== null )
        {
            $cond['contentobject_attribute_id'] = $contentobjectAttributeId;
        }
        eZPersistentObject::removeObject( self::definition(), $cond );
    }
1366545
static function removeRecentByNodeID( $nodeID )
    {
        $db = eZDB::instance();
        $nodeID =(int) $nodeID;
        $db->query( "DELETE FROM ezcontentbrowserecent WHERE node_id=$nodeID" );
    }
1082587
public function contentId($id = null)
    {
        if ($id === null) {
            return $this->_contentId;
        }
        $this->_contentId = $id;
    }
277594
public function assignSectionToContent($sectionId, $contentId)
    {
        try {
            return $this->innerGateway->assignSectionToContent($sectionId, $contentId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }