예제 #1
0
 /**
  * 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;
 }
예제 #2
0
 /**
  * @covers \Cougar\Util\Arrays::cloneObjectArray
  */
 public function testCloneObjectArrayMixedArray()
 {
     $object1 = new stdClass();
     $object1->value = "Object 1";
     $object2 = new stdClass();
     $object2->value = "Object 2";
     $objects = array($object1, $object2, "stuff");
     $cloned_objects = Arrays::cloneObjectArray($objects);
     $cloned_objects[0]->value = "Cloned Object 1";
     $cloned_objects[1]->value = "Cloned Object 2";
     $this->assertNotEquals($object1->value, $cloned_objects[0]->value);
     $this->assertNotEquals($object2->value, $cloned_objects[1]->value);
     $this->assertEquals("stuff", $objects[2]);
     $this->assertEquals($object1->value, $objects[0]->value);
     $this->assertEquals($object2->value, $objects[1]->value);
 }