/** * @param mixed $contentTypeId * @param int $status One of Type::STATUS_DEFINED|Type::STATUS_DRAFT|Type::STATUS_MODIFIED * * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException If type is defined and still has content * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If type is not found */ public function delete($contentTypeId, $status) { if (Type::STATUS_DEFINED === $status && $this->backend->count('Content\\ContentInfo', array('contentTypeId' => $contentTypeId))) { throw new BadStateException('$contentTypeId', "Content of Type {$contentTypeId} still exists, can not delete"); } // This will throw if none are found $this->backend->deleteByMatch('Content\\Type', array('id' => $contentTypeId, 'status' => $status)); // So will this, which means you can not delete types with no fields (fix?) $this->backend->deleteByMatch('Content\\Type\\FieldDefinition', array('_typeId' => $contentTypeId, '_status' => $status)); }
/** * Test count content with results using join and deep matching where match collides with join * * @expectedException LogicException * @covers eZ\Publish\Core\Persistence\InMemory\Backend::find * @group inMemoryBackend */ public function testCountJoinDeepMatchCollision() { $this->backend->count('Content', array("locations" => array('contentId' => 2)), array('locations' => array('type' => 'Content\\Location', 'match' => array('contentId' => 'id')))); }
/** * Number of content assignments a Section has * * @param mixed $sectionId * * @return int */ public function assignmentsCount($sectionId) { return $this->backend->count('Content\\ContentInfo', array('sectionId' => $sectionId)); }
/** * Test counting content with a wrong type. * * @param mixed $type Wrong type to count * * @expectedException eZ\Publish\Core\Base\Exceptions\InvalidArgumentValue * @dataProvider providerForWrongType * @covers eZ\Publish\Core\Persistence\InMemory\Backend::count */ public function testCountWrongType($type) { $this->backend->count($type, array()); }