New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Controllers (part ...) #576
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
2eb810f
Add abstract base class Action_Controller.
norv 52c0728
Derive all admin controllers from Action_Controller.
norv 5c95d4b
Make two dozen user/mod controllers extend Action_Controller.
norv ac269a7
Update more user controllers to extend the base class.
norv b6aa853
Refactor to action controller subclasses. Tweak modcenter.
norv dda2464
Rework createList() callbacks in moderation center controller:
norv 8384a69
Tweaks for list_ callbacks, add methods visibility.
norv a024408
Fix inclusion with TESTDIR.
norv a3e36cf
Move Action_Controller to core files loaded by default.. SSI too.
norv 3c43d17
Another batch of user controllers, updated to inherit Action_Controller.
norv ae92594
ProfileHistory controller. Make it a class; main methods visibility,
norv 4e795f9
ProfileInfo, into a class. (wrapping methods only)
norv 0fd1ffa
Extend ProfileInfo controller from Action_Controller and add missing
norv ca07460
action_activateaccount() was supposed to be in ProfileAccount..
norv c7aee79
ProfileSubscriptions controller, make into a class, extend Action_Con…
norv cef6e3d
Rework ProfileOptions controller as a class, initial pass.
norv 60a2643
Rework the list_ callbacks for ProfileOptions controller:
norv 805f16c
Rework Xml requests: XmlPreview controller handles previews.
norv 9288b92
Xml controllers extend Action_Controller. Methods visibility.
norv 2771278
Batch of method visibilities updates. (mostly public for actions hand…
norv 4c8b519
Attachment controller extends Action_Controller (looks it was missed.)
norv 22d4727
Tweak dispatcher.
norv cd823bc
Oops, list_ () callbacks are public.
norv d2fc184
Topic controller.
norv 8b5d1f1
MoveTopic controller.
norv 4de7c7b
MoveTopic controller. The last query gone. Clean-up useless $db.
norv 0f9acb5
Fix Xml controllers.
norv d2b0a8b
Themes controller inherits Action_Controller.
norv 8965a2f
Adapt mod blocks functions, as helper methods in the controller. Naming.
norv 9b0ac97
Moderator blocks code redesigned.
norv 8357325
Make moderatorNotice() function also in moderation subs,
norv 992c56c
Adapt list_ callbacks as controller methods, and respective subs func…
norv fb83016
Adapt a couple more createList() callbacks in profile.
norv e2ee56f
Adapt list_ callbacks in AdminDebug and ManageAddonSettings controllers.
norv File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/** | ||
* @name ElkArte Forum | ||
* @copyright ElkArte Forum contributors | ||
* @license BSD http://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* @version 1.0 Alpha | ||
*/ | ||
|
||
if (!defined('ELKARTE')) | ||
die('No access...'); | ||
|
||
/** | ||
* Abstract base class for controllers. | ||
* Requires a default action handler, action_index(). | ||
* Defines an empty implementation for pre_dispatch() | ||
* method. | ||
*/ | ||
abstract class Action_Controller | ||
{ | ||
/** | ||
* Default action handler. This will be called | ||
* by the dispatcher in many cases. It may set up a menu, | ||
* sub-dispatch at its turn to the method matching ?sa= parameter | ||
* or simply forward the request to a known default method. | ||
*/ | ||
abstract public function action_index(); | ||
|
||
/** | ||
* Called before any other action method in this class. | ||
* Allows for initializations, such as default values or | ||
* loading templates or language files. | ||
*/ | ||
public function pre_dispatch() | ||
{ | ||
// By default, do nothing. | ||
// Sub-classes may implement their prerequisite loading, | ||
// such as load the template, load the language(s) file(s) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question of the day: Is this class designed to do something in the future? The current implemantation would be more of an interface instead of an abstract class...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few thoughts:
With an interface all are forced to write something (be it something empty), with a base abstract class, we can add an empty implementation in the base class, and who cares and needs to override it, will; the rest will just inherit it with no change needed.
That said, I don't feel there is any issue at all to add an interface. Or, an extra-interface 😸 I'm just tempted to keep the object oriented model to its simplest; simplest which does the job with no burden.
An abstract base class is an interface conceptually, after all; but, it also allows defaults.
We could give up pre_dispatch(), or implement it in all controllers; or we can add an extra-interface (Action_Controller implements Controller). I'm just curious the other way around, why it'd be a "actual" interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late response...
I can see the benefits of an abstract parent class now .. the current scaffolding design reminds me of an interface (primarily because the functions are emtpy ) but a parent class (abstract or not) has definitely some benefits, at least it allows to easily extend all childs functionality at once ..