/** * Finds and instanciates a controller that matches the current request. * If no controller can be found, an instance of NotFoundControllerInterface is returned. * * @param \F3\FLOW3\MVC\RequestInterface $request The request to dispatch * @return \F3\FLOW3\MVC\Controller\ControllerInterface * @author Bastian Waidelich <*****@*****.**> */ protected function resolveController(\F3\FLOW3\MVC\RequestInterface $request) { $exception = NULL; $packageKey = $request->getControllerPackageKey(); if (!$this->packageManager->isPackageAvailable($packageKey)) { $exception = new \F3\FLOW3\MVC\Controller\Exception\InvalidPackageException($request, 'package "' . $packageKey . '" does not exist'); } elseif (!$this->packageManager->isPackageActive($packageKey)) { $exception = new \F3\FLOW3\MVC\Controller\Exception\InactivePackageException($request, 'package "' . $packageKey . '" is not active'); } else { $controllerObjectName = $request->getControllerObjectName(); if ($controllerObjectName === '') { $exception = new \F3\FLOW3\MVC\Controller\Exception\InvalidControllerException($request, 'no controller could be resolved which would match your request'); } } if ($exception !== NULL) { $controller = $this->objectManager->getObject($this->settings['mvc']['notFoundController']); if (!$controller instanceof \F3\FLOW3\MVC\Controller\NotFoundControllerInterface) { throw new \F3\FLOW3\MVC\Exception\InvalidControllerException('The NotFoundController must implement "\\F3\\FLOW3\\MVC\\Controller\\NotFoundControllerInterface", ' . (is_object($controller) ? get_class($controller) : gettype($controller)) . ' given.', 1246714416); } $controller->setException($exception); } else { $controller = $this->objectManager->getObject($controllerObjectName); if (!$controller instanceof \F3\FLOW3\MVC\Controller\ControllerInterface) { throw new \F3\FLOW3\MVC\Exception\InvalidControllerException('Invalid controller "' . $request->getControllerObjectName() . '". The controller must be a valid request handling controller, ' . (is_object($controller) ? get_class($controller) : gettype($controller)) . ' given.', 1202921619); } } return $controller; }
/** * Generate a repository for a model given a package key and model name * * @param string $packageKey The package key * @param string $modelName The name of the domain model class * @return void * @author Christopher Hlubek <*****@*****.**> */ public function generateRepositoryAction($packageKey, $modelName) { if (!$this->packageManager->isPackageKeyValid($packageKey)) { return 'Package key "' . $packageKey . '" is not valid. Only UpperCamelCase with alphanumeric characters and underscore, please!' . PHP_EOL; } if (!$this->packageManager->isPackageAvailable($packageKey)) { return 'Package "' . $packageKey . '" is not available.' . PHP_EOL; } $generatedFiles = $this->generatorService->generateRepository($packageKey, $modelName); return implode(PHP_EOL, $generatedFiles) . PHP_EOL; }