本文整理汇总了PHP中ElggEntity::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggEntity::delete方法的具体用法?PHP ElggEntity::delete怎么用?PHP ElggEntity::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggEntity
的用法示例。
在下文中一共展示了ElggEntity::delete方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testElggEntityDisableAndEnable
public function testElggEntityDisableAndEnable()
{
global $CONFIG;
// add annotations and metadata to check if they're disabled.
$annotation_id = create_annotation($this->entity->guid, 'test_annotation_' . rand(), 'test_value_' . rand());
$metadata_id = create_metadata($this->entity->guid, 'test_metadata_' . rand(), 'test_value_' . rand());
$this->assertTrue($this->entity->disable());
// ensure disabled by comparing directly with database
$entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$this->entity->guid}'");
$this->assertIdentical($entity->enabled, 'no');
$annotation = get_data_row("SELECT * FROM {$CONFIG->dbprefix}annotations WHERE id = '{$annotation_id}'");
$this->assertIdentical($annotation->enabled, 'no');
$metadata = get_data_row("SELECT * FROM {$CONFIG->dbprefix}metadata WHERE id = '{$metadata_id}'");
$this->assertIdentical($metadata->enabled, 'no');
// re-enable for deletion to work
$this->assertTrue($this->entity->enable());
// check enabled
// check annotations and metadata enabled.
$entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$this->entity->guid}'");
$this->assertIdentical($entity->enabled, 'yes');
$annotation = get_data_row("SELECT * FROM {$CONFIG->dbprefix}annotations WHERE id = '{$annotation_id}'");
$this->assertIdentical($annotation->enabled, 'yes');
$metadata = get_data_row("SELECT * FROM {$CONFIG->dbprefix}metadata WHERE id = '{$metadata_id}'");
$this->assertIdentical($metadata->enabled, 'yes');
$this->assertTrue($this->entity->delete());
$this->entity = null;
}
示例2: testPreventRelationshipOnEntityDelete
public function testPreventRelationshipOnEntityDelete()
{
$this->assertTrue(add_entity_relationship($this->entity1->guid, 'test_relationship', $this->entity2->guid));
$this->assertTrue(add_entity_relationship($this->entity2->guid, 'test_relationship', $this->entity1->guid));
$guid = $this->entity1->guid;
elgg_register_event_handler('delete', 'relationship', 'Elgg\\Values::getFalse');
$this->assertTrue($this->entity1->delete());
elgg_unregister_event_handler('delete', 'relationship', 'Elgg\\Values::getFalse');
// relationships should still be gone as there is no entity
// despite the fact we have a handler trying to prevent it
$this->assertFalse(check_entity_relationship($guid, 'test_relationship', $this->entity2->guid));
$this->assertFalse(check_entity_relationship($this->entity2->guid, 'test_relationship', $guid));
}
示例3: delete
/**
* User specific override of the entity delete method.
*
* @return bool
*/
public function delete()
{
// Delete owned data
clear_annotations_by_owner($this->guid);
clear_metadata_by_owner($this->guid);
// Delete entity
return parent::delete();
}
示例4: delete
/**
* User specific override of the entity delete method.
*
* @return bool
*/
public function delete()
{
global $USERNAME_TO_GUID_MAP_CACHE;
// clear cache
if (isset($USERNAME_TO_GUID_MAP_CACHE[$this->username])) {
unset($USERNAME_TO_GUID_MAP_CACHE[$this->username]);
}
clear_user_files($this);
// Delete entity
return parent::delete();
}
示例5: delete
/**
* Delete the site.
*
* @note You cannot delete the current site.
*
* @return bool
* @throws SecurityException
*/
public function delete()
{
global $CONFIG;
if ($CONFIG->site->getGUID() == $this->guid) {
throw new SecurityException('SecurityException:deletedisablecurrentsite');
}
return parent::delete();
}
示例6: tearDown
/**
* Called after each test method.
*/
public function tearDown()
{
$this->entity->delete();
remove_subtype('object', 'elgg_annotation_test');
_elgg_services()->hooks = $this->original_hooks;
}
示例7: delete
/**
* User specific override of the entity delete method.
*
* @return bool
*/
public function delete()
{
global $USERNAME_TO_GUID_MAP_CACHE, $CODE_TO_GUID_MAP_CACHE;
// clear cache
if (isset($USERNAME_TO_GUID_MAP_CACHE[$this->username])) {
unset($USERNAME_TO_GUID_MAP_CACHE[$this->username]);
}
if (isset($CODE_TO_GUID_MAP_CACHE[$this->code])) {
unset($CODE_TO_GUID_MAP_CACHE[$this->code]);
}
// Delete owned data
clear_annotations_by_owner($this->guid);
clear_metadata_by_owner($this->guid);
clear_user_files($this);
// Delete entity
return parent::delete();
}
示例8: delete
/**
* Delete the site.
*
* @note You cannot delete the current site.
*
* @return bool
* @throws SecurityException
*/
public function delete()
{
global $CONFIG;
if ($CONFIG->site->getGUID() == $this->guid) {
throw new \SecurityException('You cannot delete the current site');
}
return parent::delete();
}