PHP Class Graphite_ResourceList

To print a nicely formatted list of names, linking to the URIs. print $list->sort( "foaf:name" )->prettyLink()->join( ", ")."."; * Note about Graphite methods which can take a list of resources These methods work in a pretty cool way. To make life easier for you they can take a list of resources in any of the following ways. $resource->get() is used as an example, it applies to many other methods. $resource->get( $uri_string ) Such as "http://xmlns.com/foaf/0.1/name". $resource->get( $short_uri_string ) using any namespace defined with $graph->ns() or just built in. eg. "foaf:name". $resource->get( $resource ) An instance of Graphite_resource. $resource->get( $thing, $thing, $thing, ... ) $resource->get( array( $thing, $thing, $thing, ... ) ) Where each thing is any of $uri_string, $short_uri_string or $resource. $resource->get( $resourcelist ) An instance of Graphite_resourceList. This should make it quick and easy to write readable code!
Inheritance: extends ArrayIterator
显示文件 Open project: cgutteridge/graphite

Public Methods

Method Description
__construct ( Graphite $g, $a = [] )
all ( ) Call $resource->all(.
allOfType ( $uri ) Create a new resource list containing all resources in the current list of the given type.
allString ( ) Call $resource->allString(.
append ( $x ) Create a new resource list with the given resource or list of resources appended on the end of the current resource list.
distinct ( )
dump ( ) Returns a string containing a dump of all the resources in the list. Options is an optional array, same parameters as $options on a dump() of an individual resource. dumpText() does the same thing but with ASCII indents rather than HTML markup.
dumpText ( ) As dump() but for preformatted plain text, rather than HTML output.
duplicate ( ) Return a copy of this list.
except ( ) Create a new resource list with containing only the resources which are in $resourcelist but not in the list being passed in. Only returns one instance of each resource no matter how many duplicates were in either list.
filter ( $fn ) Filter a list of resources by calling a function on them and creating a new list of rseources for which the function returned true.
get ( ) Call $resource->get(.
getLiteral ( ) Call $resource->getLiteral(.
getString ( )
intersection ( ) Create a new resource list with containing only the resources which are in both lists. Only returns one instance of each resource no matter how many duplicates were in either list.
join ( $str ) Returns a string of all the items in the resource list, joined with the given string.
label ( ) Call $resource->label() on every item in this list and return a resourcelist of the results.
link ( ) Calls link() on each item in the resource list and returns it as an array. The array is an object which you can call join() on, so you can use:
load ( ) Call $resource->load() on every item in this list and return the total triples from these resources. Careful, this could cause a large number of requests at one go!
map ( $fn ) Map a list of resources to a function which must return a resource or null
prettyLink ( ) Calls prettyLink() on each item in the resource list and returns it as an array. The array is an object which you can call join() on, so you can use:
shuffle ( $fn ) Return a resource list with the same items but in a random order.
sort ( ) Return a copy of this resource list sorted by the given property or properties. If a resource has multiple values for a property then one will be used, as with $resource->get().
uasort ( $cmp )
union ( ) Create a new resource list with the given resource or list of resources merged with the current list. Functionally the same as calling $resourcelist->append( .

Method Details

__construct() public method

public __construct ( Graphite $g, $a = [] )
$g Graphite

all() public method

..) on every item in this list and return a resourcelist of all the results. Duplicate resources are eliminated. $new_resourcelist = $resourcelist->all( $property ); $new_resourcelist = $resourcelist->all( *resource list* );
public all ( )

allOfType() public method

$resource_list = $resource->allOfType( $type_uri );
public allOfType ( $uri )

allString() public method

..) on every item in this list and return a resourcelist of all the results. As with all(), duplicate resources and eliminated. $resource_list = $resource->allString( $property ); $resource_list = $resource->allString( *resource list* );
public allString ( )

append() public method

$new_resourcelist = $resourcelist->append( $resource ); $new_resourcelist = $resourcelist->append( *resource list* );
public append ( $x )

distinct() public method

public distinct ( )

dump() public method

$dump = $resourcelist->dump( [$options] );
public dump ( )

dumpText() public method

$dump = $resourcelist->dumpText( [$options] );
public dumpText ( )

duplicate() public method

$new_resourcelist = $resourcelist->duplicate();
public duplicate ( )

except() public method

$new_resourcelist = $resourcelist->except( $resource ); $new_resourcelist = $resourcelist->except( *resource list* );
public except ( )

filter() public method

$resource_list = $resource->map( function( $r ) { return $bool; } );
public filter ( $fn )

get() public method

..) on every item in this list and return a resourcelist of the results. $new_resourcelist = $resourcelist->get( $property ); $new_resourcelist = $resourcelist->get( *resource list* );
public get ( )

getLiteral() public method

..) on every item in this list and return a resourcelist of the results. $string = $resource->getLiteral( $property ); $string = $resource->getLiteral( *resource list* );
public getLiteral ( )

getString() public method

See also: getLiteral
Deprecation: getString deprecated in favour of getLiteral
public getString ( )

intersection() public method

$new_resourcelist = $resourcelist->intersection( $resource ); $new_resourcelist = $resourcelist->intersection( *resource list* );
public intersection ( )

join() public method

$str = $resourcelist->join( $joinstr );
public join ( $str )

label() public method

$new_resourcelist = $resourcelist->label();
public label ( )

load() public method

$n = $resourcelist->load();
public load ( )

map() public method

$resource_list = $resource->map( function( $r ) { return $new_r; } );
public map ( $fn )

shuffle() public method

$resource_list = $resource->shuffle();
public shuffle ( $fn )

sort() public method

$new_resourcelist = $resourcelist->sort( $property ); $new_resourcelist = $resourcelist->sort( *resource list* );
public sort ( )

uasort() public method

public uasort ( $cmp )

union() public method

.. )->distinct() $new_resourcelist = $resourcelist->union( $resource ); $new_resourcelist = $resourcelist->union( *resource list* );
public union ( )