Пример #1
0
 protected function prepare_items()
 {
     $items = $this->get_items();
     $extra_qv = array('p2p:per_page' => -1, 'p2p:context' => 'admin_column');
     $connected = $this->ctype->get_connected($items, $extra_qv, 'abstract');
     $this->connected = scb_list_group_by($connected->items, '_p2p_get_other_id');
 }
Пример #2
0
/**
 * Given a list of objects and another list of connected items,
 * distribute each connected item to it's respective counterpart.
 *
 * @param array List of objects
 * @param array List of connected objects
 * @param string Name of connected array property
 */
function p2p_distribute_connected($items, $connected, $prop_name)
{
    $indexed_list = array();
    foreach ($items as $item) {
        $item->{$prop_name} = array();
        $indexed_list[$item->ID] = $item;
    }
    $groups = scb_list_group_by($connected, '_p2p_get_other_id');
    foreach ($groups as $outer_item_id => $connected_items) {
        $indexed_list[$outer_item_id]->{$prop_name} = $connected_items;
    }
}
Пример #3
0
/** @internal */
function p2p_list_cluster($items, $callback)
{
    return scb_list_group_by($items, $callback);
}