Legacy Controllers
Legacy controllers are based on PrestaShop’s custom framework and go a long way back. All front controllers and all Admin controllers that haven’t been migrated to Symfony yet are based on this.
Execution flow
Legacy controllers work best when a Controller performs a single action, for example, render a page. The process has been divided in several methods, which simplifies customization via method override.
%%{ init: { 'flowchart': { 'curve': 'stepAfter' } } }%%
graph TB
A(("Controller::run()")) --> B("init()
Initializes the controller")
B:::importantStep --> C{"checkAccess()
Check if the controller
is available for the
current user/visitor"}
C:::decision -- false --> D("initCursedPage()
Assigns Smarty variables when access is forbidden")
D --> E("smartyOutputContent()
Displays the page content")
E:::importantStep
C -- true --> G("setMedia()
Sets controller's CSS and JS files")
G:::notAlwaysRun --> H("postProcess()
Used to process user input")
H:::importantStep --> I{"has redirect_after"}
I:::decision -- true --> J("redirect()
If there is no error, redirects after the process to the #quot;redirect_after#quot;")
I -- false --> K("initHeader()
Assigns Smarty variables
for the page header")
J --> K
K:::notAlwaysRun --> L{"viewAccess()
Checks if the current user/visitor
has valid view permissions"}
L:::decision -- false --> M("Add access denied error message
Added to errors property")
L -- true --> N("initContent()
Assigns Smarty variables
for the main content of the page")
M --> O("initFooter()
Assigns Smarty variables for the page footer")
N:::importantStep --> O
O:::notAlwaysRun --> P{"is ajax"}
P:::decision -- false --> Q("display()
Displays page content")
P -- true --> R("displayAjax{action}()
Displays page content
for ajax requests")
Q:::importantStep
R:::importantStep
subgraph Legend
direction LR
S:::notAlwaysRun
S("Not always Run")
T:::importantStep
T("Important step")
end
classDef notAlwaysRun fill:#fff0c4;
classDef importantStep fill:#c7e6ce;
classDef decision fill:#e2d0e5;
classDef default fill:#FFFFFF;
style Legend fill:#FFFFFF,stroke:#CCCCCC,stroke-width:1px;