From ff849bd72cdba8128d1d1854fe52d999a500ca05 Mon Sep 17 00:00:00 2001 From: coderkun Date: Wed, 14 May 2014 18:30:25 +0200 Subject: [PATCH] restructure application classes --- agents/toplevel/BinaryAgent.inc | 2 +- agents/toplevel/HtmlAgent.inc | 2 +- app/{ => agents}/QuesttypeAgent.inc | 23 ++++++++++++++++--- app/{ => agents}/ToplevelAgent.inc | 2 +- app/{ => controllers}/QuesttypeController.inc | 8 +++---- app/{ => models}/QuesttypeModel.inc | 2 +- app/{ => views}/QuesttypeView.inc | 2 +- controllers/QuestsController.inc | 6 ++--- .../bossfight/BossfightQuesttypeAgent.inc | 2 +- .../BossfightQuesttypeController.inc | 2 +- .../bossfight/BossfightQuesttypeModel.inc | 2 +- .../choiceinput/ChoiceinputQuesttypeAgent.inc | 2 +- .../ChoiceinputQuesttypeController.inc | 2 +- .../choiceinput/ChoiceinputQuesttypeModel.inc | 2 +- .../crossword/CrosswordQuesttypeAgent.inc | 2 +- .../CrosswordQuesttypeController.inc | 2 +- .../crossword/CrosswordQuesttypeModel.inc | 2 +- .../dragndrop/DragndropQuesttypeAgent.inc | 2 +- .../DragndropQuesttypeController.inc | 2 +- .../dragndrop/DragndropQuesttypeModel.inc | 2 +- .../MultiplechoiceQuesttypeAgent.inc | 2 +- .../MultiplechoiceQuesttypeController.inc | 2 +- .../MultiplechoiceQuesttypeModel.inc | 2 +- questtypes/submit/SubmitQuesttypeAgent.inc | 2 +- .../submit/SubmitQuesttypeController.inc | 2 +- questtypes/submit/SubmitQuesttypeModel.inc | 2 +- .../textinput/TextinputQuesttypeAgent.inc | 2 +- .../TextinputQuesttypeController.inc | 2 +- .../textinput/TextinputQuesttypeModel.inc | 2 +- 29 files changed, 53 insertions(+), 36 deletions(-) rename app/{ => agents}/QuesttypeAgent.inc (91%) rename app/{ => agents}/ToplevelAgent.inc (96%) rename app/{ => controllers}/QuesttypeController.inc (97%) rename app/{ => models}/QuesttypeModel.inc (99%) rename app/{ => views}/QuesttypeView.inc (98%) diff --git a/agents/toplevel/BinaryAgent.inc b/agents/toplevel/BinaryAgent.inc index f2d6d33e..225828e3 100644 --- a/agents/toplevel/BinaryAgent.inc +++ b/agents/toplevel/BinaryAgent.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class BinaryAgent extends \hhu\z\ToplevelAgent + class BinaryAgent extends \hhu\z\agents\ToplevelAgent { diff --git a/agents/toplevel/HtmlAgent.inc b/agents/toplevel/HtmlAgent.inc index bedcf848..86b65f3f 100644 --- a/agents/toplevel/HtmlAgent.inc +++ b/agents/toplevel/HtmlAgent.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class HtmlAgent extends \hhu\z\ToplevelAgent + class HtmlAgent extends \hhu\z\agents\ToplevelAgent { diff --git a/app/QuesttypeAgent.inc b/app/agents/QuesttypeAgent.inc similarity index 91% rename from app/QuesttypeAgent.inc rename to app/agents/QuesttypeAgent.inc index 23c4d1b2..6b9d0545 100644 --- a/app/QuesttypeAgent.inc +++ b/app/agents/QuesttypeAgent.inc @@ -9,7 +9,7 @@ * @link https://bitbucket.org/coderkun/the-legend-of-z */ - namespace hhu\z; + namespace hhu\z\agents; /** @@ -107,6 +107,23 @@ } + /** + * Determine the classname for the given Agent name. + * + * @static + * @param string $agentName Agent name to get classname of + * @param string $agentType Agent type of given Agent name + * @return string Classname for the Agent name + */ + /*private static function getClassName($agentName, $agentType) + { + $className = ClassLoader::concatClassNames($agentName, 'agent'); + + + return \nre\configs\AppConfig::$app['namespace']."agents\\$agentType\\$className"; + }*/ + + /** * Load the class of a QuesttypeAgent. * @@ -256,10 +273,10 @@ // Load Controller - \hhu\z\QuesttypeController::load($controllerName); + \hhu\z\controllers\QuesttypeController::load($controllerName); // Construct Controller - $this->controller = QuesttypeController::factory($controllerName, $toplevelAgentName, $action, $this); + $this->controller = \hhu\z\controllers\QuesttypeController::factory($controllerName, $toplevelAgentName, $action, $this); } } diff --git a/app/ToplevelAgent.inc b/app/agents/ToplevelAgent.inc similarity index 96% rename from app/ToplevelAgent.inc rename to app/agents/ToplevelAgent.inc index 97aea57b..dc2810d0 100644 --- a/app/ToplevelAgent.inc +++ b/app/agents/ToplevelAgent.inc @@ -9,7 +9,7 @@ * @link https://bitbucket.org/coderkun/the-legend-of-z */ - namespace hhu\z; + namespace hhu\z\agents; /** diff --git a/app/QuesttypeController.inc b/app/controllers/QuesttypeController.inc similarity index 97% rename from app/QuesttypeController.inc rename to app/controllers/QuesttypeController.inc index fadfded0..15b79ebb 100644 --- a/app/QuesttypeController.inc +++ b/app/controllers/QuesttypeController.inc @@ -9,7 +9,7 @@ * @link https://bitbucket.org/coderkun/the-legend-of-z */ - namespace hhu\z; + namespace hhu\z\controllers; /** @@ -273,11 +273,11 @@ $model = \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripNamespace(get_class($this)))); // Load class - QuesttypeModel::load($model); + \hhu\z\models\QuesttypeModel::load($model); // Construct Model $modelName = ucfirst(strtolower($model)); - $this->$modelName = QuesttypeModel::factory($model); + $this->$modelName = \hhu\z\models\QuesttypeModel::factory($model); } @@ -300,7 +300,7 @@ // Load view - $this->view = QuesttypeView::loadAndFactory($layoutName, $controllerName, $action); + $this->view = \hhu\z\views\QuesttypeView::loadAndFactory($layoutName, $controllerName, $action); } } diff --git a/app/QuesttypeModel.inc b/app/models/QuesttypeModel.inc similarity index 99% rename from app/QuesttypeModel.inc rename to app/models/QuesttypeModel.inc index d30699fb..828ae401 100644 --- a/app/QuesttypeModel.inc +++ b/app/models/QuesttypeModel.inc @@ -9,7 +9,7 @@ * @link https://bitbucket.org/coderkun/the-legend-of-z */ - namespace hhu\z; + namespace hhu\z\models; /** diff --git a/app/QuesttypeView.inc b/app/views/QuesttypeView.inc similarity index 98% rename from app/QuesttypeView.inc rename to app/views/QuesttypeView.inc index 8e77ee00..30101486 100644 --- a/app/QuesttypeView.inc +++ b/app/views/QuesttypeView.inc @@ -9,7 +9,7 @@ * @link https://bitbucket.org/coderkun/the-legend-of-z */ - namespace hhu\z; + namespace hhu\z\views; /** diff --git a/controllers/QuestsController.inc b/controllers/QuestsController.inc index ea18fe87..2d7fda45 100644 --- a/controllers/QuestsController.inc +++ b/controllers/QuestsController.inc @@ -43,7 +43,7 @@ * @var array */ public $seminaryPermissions = array( - 'index' => array('admin', 'moderator', 'user'), + 'index' => array('admin', 'moderator'), 'quest' => array('admin', 'moderator', 'user'), 'submissions' => array('admin', 'moderator'), 'submission' => array('admin', 'moderator'), @@ -813,11 +813,11 @@ private function loadQuesttypeAgent($questtypeClassname, $request, $response) { // Load Agent - \hhu\z\QuesttypeAgent::load($questtypeClassname); + \hhu\z\agents\QuesttypeAgent::load($questtypeClassname); // Construct and return Agent - return \hhu\z\QuesttypeAgent::factory($questtypeClassname, $request, $response); + return \hhu\z\agents\QuesttypeAgent::factory($questtypeClassname, $request, $response); } diff --git a/questtypes/bossfight/BossfightQuesttypeAgent.inc b/questtypes/bossfight/BossfightQuesttypeAgent.inc index 6d99ec44..23ce95db 100644 --- a/questtypes/bossfight/BossfightQuesttypeAgent.inc +++ b/questtypes/bossfight/BossfightQuesttypeAgent.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class BossfightQuesttypeAgent extends \hhu\z\QuesttypeAgent + class BossfightQuesttypeAgent extends \hhu\z\agents\QuesttypeAgent { } diff --git a/questtypes/bossfight/BossfightQuesttypeController.inc b/questtypes/bossfight/BossfightQuesttypeController.inc index 9495c073..4b19f5ed 100644 --- a/questtypes/bossfight/BossfightQuesttypeController.inc +++ b/questtypes/bossfight/BossfightQuesttypeController.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class BossfightQuesttypeController extends \hhu\z\QuesttypeController + class BossfightQuesttypeController extends \hhu\z\controllers\QuesttypeController { /** * Required models diff --git a/questtypes/bossfight/BossfightQuesttypeModel.inc b/questtypes/bossfight/BossfightQuesttypeModel.inc index a05927f0..07d6ed5f 100644 --- a/questtypes/bossfight/BossfightQuesttypeModel.inc +++ b/questtypes/bossfight/BossfightQuesttypeModel.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class BossfightQuesttypeModel extends \hhu\z\QuesttypeModel + class BossfightQuesttypeModel extends \hhu\z\models\QuesttypeModel { diff --git a/questtypes/choiceinput/ChoiceinputQuesttypeAgent.inc b/questtypes/choiceinput/ChoiceinputQuesttypeAgent.inc index b418f01e..835cb87c 100644 --- a/questtypes/choiceinput/ChoiceinputQuesttypeAgent.inc +++ b/questtypes/choiceinput/ChoiceinputQuesttypeAgent.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class ChoiceinputQuesttypeAgent extends \hhu\z\QuesttypeAgent + class ChoiceinputQuesttypeAgent extends \hhu\z\agents\QuesttypeAgent { } diff --git a/questtypes/choiceinput/ChoiceinputQuesttypeController.inc b/questtypes/choiceinput/ChoiceinputQuesttypeController.inc index a7edf905..e48cb6eb 100644 --- a/questtypes/choiceinput/ChoiceinputQuesttypeController.inc +++ b/questtypes/choiceinput/ChoiceinputQuesttypeController.inc @@ -18,7 +18,7 @@ * * @author Oliver Hanraths */ - class ChoiceinputQuesttypeController extends \hhu\z\QuesttypeController + class ChoiceinputQuesttypeController extends \hhu\z\controllers\QuesttypeController { diff --git a/questtypes/choiceinput/ChoiceinputQuesttypeModel.inc b/questtypes/choiceinput/ChoiceinputQuesttypeModel.inc index e908600f..d35b3baf 100644 --- a/questtypes/choiceinput/ChoiceinputQuesttypeModel.inc +++ b/questtypes/choiceinput/ChoiceinputQuesttypeModel.inc @@ -18,7 +18,7 @@ * * @author Oliver Hanraths */ - class ChoiceinputQuesttypeModel extends \hhu\z\QuesttypeModel + class ChoiceinputQuesttypeModel extends \hhu\z\models\QuesttypeModel { diff --git a/questtypes/crossword/CrosswordQuesttypeAgent.inc b/questtypes/crossword/CrosswordQuesttypeAgent.inc index 9b137fe9..5cf26841 100644 --- a/questtypes/crossword/CrosswordQuesttypeAgent.inc +++ b/questtypes/crossword/CrosswordQuesttypeAgent.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class CrosswordQuesttypeAgent extends \hhu\z\QuesttypeAgent + class CrosswordQuesttypeAgent extends \hhu\z\agents\QuesttypeAgent { } diff --git a/questtypes/crossword/CrosswordQuesttypeController.inc b/questtypes/crossword/CrosswordQuesttypeController.inc index e5510786..0345169e 100644 --- a/questtypes/crossword/CrosswordQuesttypeController.inc +++ b/questtypes/crossword/CrosswordQuesttypeController.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class CrosswordQuesttypeController extends \hhu\z\QuesttypeController + class CrosswordQuesttypeController extends \hhu\z\controllers\QuesttypeController { diff --git a/questtypes/crossword/CrosswordQuesttypeModel.inc b/questtypes/crossword/CrosswordQuesttypeModel.inc index 78a42821..23da2daa 100644 --- a/questtypes/crossword/CrosswordQuesttypeModel.inc +++ b/questtypes/crossword/CrosswordQuesttypeModel.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class CrosswordQuesttypeModel extends \hhu\z\QuesttypeModel + class CrosswordQuesttypeModel extends \hhu\z\models\QuesttypeModel { diff --git a/questtypes/dragndrop/DragndropQuesttypeAgent.inc b/questtypes/dragndrop/DragndropQuesttypeAgent.inc index c7d0abdf..d85d94cf 100644 --- a/questtypes/dragndrop/DragndropQuesttypeAgent.inc +++ b/questtypes/dragndrop/DragndropQuesttypeAgent.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class DragndropQuesttypeAgent extends \hhu\z\QuesttypeAgent + class DragndropQuesttypeAgent extends \hhu\z\agents\QuesttypeAgent { } diff --git a/questtypes/dragndrop/DragndropQuesttypeController.inc b/questtypes/dragndrop/DragndropQuesttypeController.inc index 4f359faa..dfb7ce57 100644 --- a/questtypes/dragndrop/DragndropQuesttypeController.inc +++ b/questtypes/dragndrop/DragndropQuesttypeController.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class DragndropQuesttypeController extends \hhu\z\QuesttypeController + class DragndropQuesttypeController extends \hhu\z\controllers\QuesttypeController { /** * Required models diff --git a/questtypes/dragndrop/DragndropQuesttypeModel.inc b/questtypes/dragndrop/DragndropQuesttypeModel.inc index 2aadb335..7783f889 100644 --- a/questtypes/dragndrop/DragndropQuesttypeModel.inc +++ b/questtypes/dragndrop/DragndropQuesttypeModel.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class DragndropQuesttypeModel extends \hhu\z\QuesttypeModel + class DragndropQuesttypeModel extends \hhu\z\models\QuesttypeModel { diff --git a/questtypes/multiplechoice/MultiplechoiceQuesttypeAgent.inc b/questtypes/multiplechoice/MultiplechoiceQuesttypeAgent.inc index 2789c5f6..da7d2619 100644 --- a/questtypes/multiplechoice/MultiplechoiceQuesttypeAgent.inc +++ b/questtypes/multiplechoice/MultiplechoiceQuesttypeAgent.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class MultiplechoiceQuesttypeAgent extends \hhu\z\QuesttypeAgent + class MultiplechoiceQuesttypeAgent extends \hhu\z\agents\QuesttypeAgent { } diff --git a/questtypes/multiplechoice/MultiplechoiceQuesttypeController.inc b/questtypes/multiplechoice/MultiplechoiceQuesttypeController.inc index 09dbfe41..a6f4a9bc 100644 --- a/questtypes/multiplechoice/MultiplechoiceQuesttypeController.inc +++ b/questtypes/multiplechoice/MultiplechoiceQuesttypeController.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class MultiplechoiceQuesttypeController extends \hhu\z\QuesttypeController + class MultiplechoiceQuesttypeController extends \hhu\z\controllers\QuesttypeController { diff --git a/questtypes/multiplechoice/MultiplechoiceQuesttypeModel.inc b/questtypes/multiplechoice/MultiplechoiceQuesttypeModel.inc index 6c4931b7..be8c704b 100644 --- a/questtypes/multiplechoice/MultiplechoiceQuesttypeModel.inc +++ b/questtypes/multiplechoice/MultiplechoiceQuesttypeModel.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class MultiplechoiceQuesttypeModel extends \hhu\z\QuesttypeModel + class MultiplechoiceQuesttypeModel extends \hhu\z\models\QuesttypeModel { diff --git a/questtypes/submit/SubmitQuesttypeAgent.inc b/questtypes/submit/SubmitQuesttypeAgent.inc index 68ca9ae5..499da0f4 100644 --- a/questtypes/submit/SubmitQuesttypeAgent.inc +++ b/questtypes/submit/SubmitQuesttypeAgent.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class SubmitQuesttypeAgent extends \hhu\z\QuesttypeAgent + class SubmitQuesttypeAgent extends \hhu\z\agents\QuesttypeAgent { } diff --git a/questtypes/submit/SubmitQuesttypeController.inc b/questtypes/submit/SubmitQuesttypeController.inc index d8d33186..91b41b00 100644 --- a/questtypes/submit/SubmitQuesttypeController.inc +++ b/questtypes/submit/SubmitQuesttypeController.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class SubmitQuesttypeController extends \hhu\z\QuesttypeController + class SubmitQuesttypeController extends \hhu\z\controllers\QuesttypeController { /** * Required models diff --git a/questtypes/submit/SubmitQuesttypeModel.inc b/questtypes/submit/SubmitQuesttypeModel.inc index 5d821655..9b5e9b47 100644 --- a/questtypes/submit/SubmitQuesttypeModel.inc +++ b/questtypes/submit/SubmitQuesttypeModel.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class SubmitQuesttypeModel extends \hhu\z\QuesttypeModel + class SubmitQuesttypeModel extends \hhu\z\models\QuesttypeModel { /** * Required models diff --git a/questtypes/textinput/TextinputQuesttypeAgent.inc b/questtypes/textinput/TextinputQuesttypeAgent.inc index 8144c148..8261ffd9 100644 --- a/questtypes/textinput/TextinputQuesttypeAgent.inc +++ b/questtypes/textinput/TextinputQuesttypeAgent.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class TextinputQuesttypeAgent extends \hhu\z\QuesttypeAgent + class TextinputQuesttypeAgent extends \hhu\z\agents\QuesttypeAgent { } diff --git a/questtypes/textinput/TextinputQuesttypeController.inc b/questtypes/textinput/TextinputQuesttypeController.inc index 9d2940a3..6db90ffb 100644 --- a/questtypes/textinput/TextinputQuesttypeController.inc +++ b/questtypes/textinput/TextinputQuesttypeController.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class TextinputQuesttypeController extends \hhu\z\QuesttypeController + class TextinputQuesttypeController extends \hhu\z\controllers\QuesttypeController { diff --git a/questtypes/textinput/TextinputQuesttypeModel.inc b/questtypes/textinput/TextinputQuesttypeModel.inc index 3d00d038..bcb93427 100644 --- a/questtypes/textinput/TextinputQuesttypeModel.inc +++ b/questtypes/textinput/TextinputQuesttypeModel.inc @@ -17,7 +17,7 @@ * * @author Oliver Hanraths */ - class TextinputQuesttypeModel extends \hhu\z\QuesttypeModel + class TextinputQuesttypeModel extends \hhu\z\models\QuesttypeModel {