/** * Delete stored object attribute */ function deleteStoredObjectAttribute($contentObjectAttribute, $version = null) { $db = eZDB::instance(); $paexID = $contentObjectAttribute->attribute("contentobject_id"); $res = $db->arrayQuery("SELECT COUNT(*) AS version_count FROM ezcontentobject_version WHERE contentobject_id = {$paexID}"); $versionCount = $res[0]['version_count']; if ($version == null || $versionCount <= 1) { eZPaEx::removePaex($paexID); } }
/** * Unit test for eZPaEx::removePaex() **/ public function testRemovePaex() { $user = self::createUser(__FUNCTION__); $paex = eZPaEx::create($user->attribute('id')); $paex->store(); $id = $paex->attribute('contentobject_id'); unset($paex); // fetch again to be sure it is stored $this->assertType('eZPaEx', eZPaEx::fetch($id), "eZPaEx::fetch() should have returned an object"); // remove, and check if fetch fails as expected eZPaEx::removePaex($id); $this->assertEquals(null, eZPaEx::fetch($id), "eZPaEx::fetch() should have returned null as the object should no longer exist"); }