Added global function cloudobjects_get_object()
This commit is contained in:
23
CloudObjects/SDK/functions.php
Normal file
23
CloudObjects/SDK/functions.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use ML\IRI\IRI;
|
||||
use CloudObjects\SDK\CloudObject,
|
||||
CloudObjects\SDK\ObjectRetrieverFacade;
|
||||
|
||||
if (!function_exists('cloudobjects_get_object')) {
|
||||
/**
|
||||
* Retrieve a CloudObject by COID. Accepts a COID as an IRI object or a string.
|
||||
*/
|
||||
function cloudobjects_get_object($coid) : ?CloudObject {
|
||||
if (is_string($coid))
|
||||
$coid = new IRI($coid);
|
||||
elseif (!($coid instanceof IRI))
|
||||
throw new InvalidArgumentException('COID must be a string or an IRI object.');
|
||||
|
||||
return ObjectRetrieverFacade::getCloudObject($coid);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user