* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class WebDefaultNewsController extends BaseController implements Controller {
- /**
- * Instance of a CommandResolver class
- */
- private $resolverInstance = null;
-
/**
* Protected constructor
*
parent::__construct(__CLASS__);
// Set part description
- $this->setObjectDescription("Standart-Controller mit News-Auflistung");
+ $this->setObjectDescription("Default controller with news");
// Create unique ID number
- $this->createUniqueID();
-
- // Clean up a little
- $this->removeSystemArray();
+ $this->generateUniqueId();
}
/**
// Set the command resolver
$controllerInstance->setResolverInstance($resolverInstance);
+ // Add news filters to this controller
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_class'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_class'));
+
// Return the prepared instance
return $controllerInstance;
}
- /**
- * Setter for a command resolver instance
- *
- * @param $resolverInstance An instance of a command resolver class
- * @return void
- */
- public final function setResolverInstance (CommandResolver $resolverInstance) {
- $this->resolverInstance = $resolverInstance;
- }
-
/**
* Handles the given request and response
*
* @return void
*/
public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
+ // Run the pre filters
+ $this->executePreFilters($requestInstance, $responseInstance);
+
// Get the command instance from the resolver by sending a request instance to the resolver
- $commandInstance = $this->resolverInstance->resolvCommandByRequest($requestInstance);
+ $commandInstance = $this->getResolverInstance()->resolvCommandByRequest($requestInstance);
- // Load the news here
- $this->loadNewsByRequest($requestInstance);
+ // This request was valid! :-D
+ $requestInstance->requestIsValid();
// Execute the command
$commandInstance->execute($requestInstance, $responseInstance);
+ // Run the pre filters
+ $this->executePostFilters($requestInstance, $responseInstance);
+
// Flush the response out
$responseInstance->flushBuffer();
}
-
- /**
- * Loads news by a given request
- *
- * @param $requestInstance An instance of a request class
- * @return void
- */
- private function loadNewsByRequest (Requestable $requestInstance) {
- // Generate a new news object but not carring about which concrete we have
- $newsInstance = NewsFactory::createFactoryByRequest($requestInstance)->createNewsObject();
- }
}
// [EOF]