Example #1
0
 /**
  * Sets the set of allowable sub-resources.
  * @param  array                               $subResources
  * @throws \BedRest\Resource\Mapping\Exception
  */
 public function setSubResources(array $subResources)
 {
     foreach ($subResources as $name => $mapping) {
         if (!is_string($name) || !is_array($mapping)) {
             throw Exception::invalidSubResources($this->className);
         }
         if (!isset($mapping['fieldName'])) {
             throw Exception::invalidSubResources($this->className);
         }
         if (!isset($mapping['service'])) {
             $mapping['service'] = null;
         }
         $this->subResources[$name] = $mapping;
     }
 }