本文整理汇总了PHP中entity_selector::run方法的典型用法代码示例。如果您正苦于以下问题:PHP entity_selector::run方法的具体用法?PHP entity_selector::run怎么用?PHP entity_selector::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entity_selector
的用法示例。
在下文中一共展示了entity_selector::run方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete_site
function delete_site($site_id, $do_it = false, $types = array(), $limit_dels = -1)
{
static $all_types = array();
if (empty($all_types)) {
$es = new entity_selector();
$es->add_type(id_of('type'));
$all_types = $es->run_one();
}
$out = array();
$site = new entity($site_id);
if ($site->get_value('type') == id_of('site')) {
$out[] = '<h2>Started deletion process for ' . $site->get_value('name') . ' (id: ' . $site_id . ')</h2>';
} else {
trigger_error('id given not the id of a site');
return false;
}
/* $es = new entity_selector();
$es->add_type(id_of('type'));
$es->add_right_relationship($site_id, relationship_id_of('site_to_type'));
$types = $es->run_one(); */
$es = new entity_selector($site_id);
$es->set_sharing('owns');
$es->set_num($limit_dels);
/* foreach($types as $type_id=>$type)
{
$es->add_type($type_id);
} */
if (!empty($types)) {
foreach ($types as $type_id) {
if (!empty($all_types[$type_id])) {
$types_to_delete[$type_id] = $all_types[$type_id];
}
}
} else {
$types_to_delete = $all_types;
}
foreach ($types_to_delete as $type_id => $type) {
$out[] = '<h3>Entered ' . $type->get_value('name') . '</h3>';
$entities = $es->run_one($type_id);
$pendings = $es->run_one($type_id, 'Pending');
$deleteds = $es->run($type_id, 'Deleted');
if (!empty($pendings)) {
$entities += $pendings;
}
if (!empty($deleteds)) {
$entities += $deleteds;
}
foreach ($entities as $entity_id => $entity) {
if ($do_it) {
delete_entity($entity_id);
$out[] = 'Deleted ' . $entity->get_value('name') . ' (id: ' . $entity_id . ')';
} else {
$out[] = 'Would have deleted ' . $entity->get_value('name') . ' (id: ' . $entity_id . ')';
}
}
}
if ($do_it && empty($types) && $limit_dels == -1) {
delete_entity($site_id);
$out[] = '<h3>Deleted Site: ' . $site->get_value('name') . '</h3>';
} else {
$out[] = '<h3>Would have deleted site: ' . $site->get_value('name') . '</h3>';
}
// should probably delete .htaccess file here
$htaccess = '/' . trim_slashes(WEB_PATH) . $site->get_value('base_url') . '.htaccess';
if (file_exists($htaccess)) {
if ($do_it && empty($types) && $limit_dels == -1) {
unlink($htaccess);
$out[] = '<h3>Deleted ' . $htaccess . '</h3>';
} else {
$out[] = '<h3>Would have deleted ' . $htaccess . '</h3>';
}
}
return $out;
}