Tutorial to migrate simple Legacy ModuleAdminControllers to Symfony
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 136
- Forks
- 555
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 4
Description
It's such a simple task to make a good looking, and well functioning module configuration form and/or a list of entities by just extending the Legacy ModuleAdminController. Below is a simple example on a module and it's admin-controller, that both list some table and creates a simple configuration form (that automatically gets the configuration values on load and saves them on submit). Easy peasy, and we love it.
// mymodule/mymodule.php
class mymodule extends Module {
public function __construct() {
// ...
$this->tabs = [
[
'class_name' => 'AdminMyModuleConfigController',
'parent_class_name' => 'AdminCatalog',
'name' => 'My Module settings',
'visible' => true,
],
];
}
}
// mymodule/controllers/admin/AdminMyModuleConfigController.php
class AdminMyModuleConfigController extends ModuleAdminController
{
public function __construct()
{
parent::__construct();
$this->bootstrap = true;
$this->table = $this->module->name.'_mylist';
$this->identifier = 'id';
$this->_defaultOrderBy = 'id';
$this->_defaultOrderWay = 'DESC';
$this->list_no_link = true;
$this->actions = [];
$this->actions_available = [];
$this->lang = false;
$this->list_simple_header = true;
$this->fields_list = [
'message' => [
'title' => $this->l('Messages'),
]
];
$this->fields_options = [
'options' =>
[
'title' => $this->l('My simple options'),
'fields' => [
$this->module->name.'_api_key' => [
'title' => $this->l('My API KEY'),
'type' => 'text',
],
'submit' => [
'title' => $this->l('Save'),
'name' => 'submitOptions'
]
]
]
];
}
}
I know that there does not exist such a simple way to do modern controllers, and that there are reasons to this (generating html-code directly in php etc). However: I hope that you will consider to:
- make it (almost) as easy to do very common things like the example above in new symfony module admin controllers. Off course, I think most of us would like an even more flexible system than the
HelperOptions,HelperFormandHelperList, and can handle a little bit more complexity in favour of getting a more flexible system. - that a tutorial on how to best/fastest migrate such simple legacy admin controllers into symfony.
I realise that this feature request is both relevant to the documentation and the code - let me know if you want me to move it.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the legacy example in mymodule/mymodule.php and mymodule/controllers/admin/AdminMyModuleConfigController.php, including its ModuleAdminController, HelperOptions, HelperForm, and HelperList references. Define whether the deliverable is a migration tutorial, a modern controller feature, or both. Done means the agreed scope is documented with a complete path for migrating the simple listing and configuration form.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100