/** * init() parses the resources array, determining the resource type from url * parameters set in the Request->resources array. * This method "delegates" requests to nested controllers. If an additional controller * is on the route, we stop processing and instantiate the next controller. * */ public function init() { $resourcesIterator = new SimpleIterator($this->resources); $resourcesData = $this->request->getResourceData(); $renderFlag = true; while ($resourcesIterator->hasNext()) { $resourceValue = $resourcesIterator->next(); if (!empty($resourcesData['CONTROLLERS'][$resourceValue])) { $renderFlag = false; $truncatedResources = $resourcesIterator->truncateFromIndex($resourcesIterator->getIndex()); $controller = new $resourcesData['CONTROLLERS'][$resourceValue]->className($truncatedResources); $controller->init(); return; } if (is_numeric($resourceValue)) { $this->request->setRequestedIds($resourceValue, $this->controllerName); continue; } if (is_string($resourceValue)) { //call setRequestedTag and then figure out what to do (method, fetch by value etc.) $this->request->setRequestedTag($resourceValue); } } if ($renderFlag) { $this->callMethod(); } }