当前位置: 首页>>代码示例>>PHP>>正文


PHP entity_selector::run方法代码示例

本文整理汇总了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;
}
开发者ID:hunter2814,项目名称:reason_package,代码行数:74,代码来源:minimize.php


注:本文中的entity_selector::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。