/** * Returns a list of actions on the given resource. * * @history * 2014.04.15: * (AT) Initial implementation * * @version 2014.04.15 * @author (AT) Alberto Trevino, Brigham Young Univ. <*****@*****.**> * * @param string $resource_id * Resource name * @throws \Cougar\Exceptions\NotFoundException * @return \Cougar\RestService\Models\Action[] * List of actions on resource */ public function getResourceActions($resource_id) { // Make sure the resource exists if (!array_key_exists($resource_id, $this->resources)) { throw new NotFoundException("Resource not found"); } $resource = $this->resources[$resource_id]; // Get a copy of the actions $actions = Arrays::cloneObjectArray($resource->actions); // Set the view to list Arrays::setModelView($actions, "list"); // Return the actions return $actions; }
/** * @covers \Cougar\Util\Arrays::setModelView * @expectedException \Cougar\Exceptions\Exception */ public function testSetModelViewBadObjects() { $object1 = new stdClass(); $object2 = new stdClass(); $objects = array($object1, $object2); Arrays::setModelView($objects, "new_view"); }