Permalink
Browse files

Pass request object to dm instead of recreating it

  • Loading branch information...
flack committed Jan 7, 2019
1 parent 35fb3d8 commit 7dde9aeb77bb5139b3551acf653fbc909c23292c
Showing with 300 additions and 214 deletions.
  1. +4 −2 lib/midcom/admin/folder/handler/delete.php
  2. +3 −2 lib/midcom/admin/folder/handler/edit.php
  3. +4 −2 lib/midcom/admin/folder/handler/metadata.php
  4. +1 −1 lib/midcom/admin/folder/handler/move.php
  5. +3 −2 lib/midcom/baseclasses/components/handler/configuration.php
  6. +1 −1 lib/midcom/baseclasses/components/handler/configuration/recreate.php
  7. +3 −3 lib/midcom/helper/imagepopup/handler/list.php
  8. +3 −2 lib/midgard/admin/asgard/handler/component/configuration.php
  9. +2 −2 lib/midgard/admin/asgard/handler/object/attachments.php
  10. +4 −4 lib/midgard/admin/asgard/handler/object/manage.php
  11. +3 −2 lib/midgard/admin/asgard/handler/object/metadata.php
  12. +1 −1 lib/midgard/admin/asgard/handler/object/permissions.php
  13. +1 −1 lib/midgard/admin/asgard/handler/preferences.php
  14. +3 −2 lib/midgard/admin/asgard/handler/shell.php
  15. +3 −2 lib/midgard/admin/user/handler/group/create.php
  16. +3 −2 lib/midgard/admin/user/handler/group/edit.php
  17. +5 −4 lib/midgard/admin/user/handler/user/account.php
  18. +3 −2 lib/midgard/admin/user/handler/user/create.php
  19. +3 −2 lib/midgard/admin/user/handler/user/edit.php
  20. +5 −4 lib/net/nehmer/blog/handler/admin.php
  21. +3 −2 lib/net/nehmer/blog/handler/create.php
  22. +1 −1 lib/net/nehmer/comments/handler/view.php
  23. +5 −4 lib/net/nehmer/static/handler/admin.php
  24. +3 −2 lib/net/nehmer/static/handler/create.php
  25. +7 −6 lib/net/nemein/redirector/handler/tinyurl.php
  26. +4 −4 lib/net/nemein/rss/handler/admin.php
  27. +1 −1 lib/net/nemein/wiki/handler/create.php
  28. +4 −2 lib/net/nemein/wiki/handler/delete.php
  29. +2 −2 lib/net/nemein/wiki/handler/edit.php
  30. +4 −4 lib/org/openpsa/calendar/handler/event/admin.php
  31. +1 −1 lib/org/openpsa/calendar/handler/event/create.php
  32. +3 −2 lib/org/openpsa/calendar/handler/event/view.php
  33. +3 −2 lib/org/openpsa/calendar/handler/filters.php
  34. +3 −2 lib/org/openpsa/calendar/handler/resource.php
  35. +3 −2 lib/org/openpsa/contacts/handler/group/create.php
  36. +3 −2 lib/org/openpsa/contacts/handler/group/edit.php
  37. +5 −4 lib/org/openpsa/contacts/handler/person/admin.php
  38. +3 −2 lib/org/openpsa/contacts/handler/person/create.php
  39. +5 −4 lib/org/openpsa/directmarketing/handler/campaign/admin.php
  40. +3 −2 lib/org/openpsa/directmarketing/handler/campaign/create.php
  41. +7 −6 lib/org/openpsa/directmarketing/handler/message/admin.php
  42. +3 −2 lib/org/openpsa/directmarketing/handler/message/create.php
  43. +3 −2 lib/org/openpsa/documents/handler/directory/create.php
  44. +3 −2 lib/org/openpsa/documents/handler/directory/edit.php
  45. +7 −7 lib/org/openpsa/documents/handler/document/admin.php
  46. +6 −6 lib/org/openpsa/expenses/handler/hours/admin.php
  47. +1 −1 lib/org/openpsa/helpers/handler/chooser.php
  48. +5 −4 lib/org/openpsa/invoices/handler/billingdata.php
  49. +7 −6 lib/org/openpsa/invoices/handler/invoice/crud.php
  50. +5 −2 lib/org/openpsa/mail/formmailer.php
  51. +3 −2 lib/org/openpsa/products/handler/group/create.php
  52. +3 −2 lib/org/openpsa/products/handler/group/edit.php
  53. +5 −4 lib/org/openpsa/products/handler/product/admin.php
  54. +3 −2 lib/org/openpsa/products/handler/product/create.php
  55. +7 −6 lib/org/openpsa/projects/handler/project/crud.php
  56. +7 −6 lib/org/openpsa/projects/handler/task/crud.php
  57. +7 −6 lib/org/openpsa/relatedto/handler/journal/entry.php
  58. +2 −2 lib/org/openpsa/reports/handler/base.php
  59. +1 −1 lib/org/openpsa/sales/handler/deliverable/add.php
  60. +5 −4 lib/org/openpsa/sales/handler/deliverable/admin.php
  61. +7 −6 lib/org/openpsa/sales/handler/edit.php
  62. +7 −6 lib/org/openpsa/sales/handler/offer.php
  63. +3 −2 lib/org/openpsa/user/handler/group/create.php
  64. +4 −2 lib/org/openpsa/user/handler/group/delete.php
  65. +3 −2 lib/org/openpsa/user/handler/group/edit.php
  66. +4 −2 lib/org/openpsa/user/handler/group/notifications.php
  67. +3 −2 lib/org/openpsa/user/handler/group/privileges.php
  68. +3 −2 lib/org/openpsa/user/handler/lostpassword.php
  69. +5 −4 lib/org/openpsa/user/handler/person/account.php
  70. +3 −2 lib/org/openpsa/user/handler/person/create.php
  71. +4 −2 lib/org/openpsa/user/handler/person/delete.php
  72. +3 −2 lib/org/openpsa/user/handler/person/edit.php
  73. +4 −2 lib/org/openpsa/user/handler/person/notifications.php
  74. +3 −2 lib/org/openpsa/user/handler/person/privileges.php
  75. +20 −3 src/midcom/datamanager/controller.php
  76. +3 −2 src/midcom/workflow/datamanager.php
  77. +3 −2 src/midcom/workflow/delete.php
  78. +2 −1 src/midcom/workflow/dialog.php
  79. +2 −1 src/midcom/workflow/viewer.php
@@ -6,6 +6,8 @@
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
*/
use Symfony\Component\HttpFoundation\Request;
/**
* Handle the folder deleting requests
*
@@ -16,7 +18,7 @@ class midcom_admin_folder_handler_delete extends midcom_baseclasses_components_h
/**
* Handler for folder deletion.
*/
public function _handler_delete()
public function _handler_delete(Request $request)
{
$this->_topic->require_do('midcom.admin.folder:topic_management');
@@ -28,6 +30,6 @@ public function _handler_delete()
'recursive' => true,
'success_url' => $upper_node[MIDCOM_NAV_ABSOLUTEURL]
]);
return $workflow->run();
return $workflow->run($request);
}
}
@@ -9,6 +9,7 @@
use midcom\datamanager\datamanager;
use midcom\datamanager\schemadb;
use midcom\datamanager\controller;
use Symfony\Component\HttpFoundation\Request;
/**
* Handle the folder editing requests
@@ -82,7 +83,7 @@ private function _load_controller()
*
* @param mixed $handler_id The ID of the handler.
*/
public function _handler_edit($handler_id)
public function _handler_edit(Request $request, $handler_id)
{
$this->_topic->require_do('midcom.admin.folder:topic_management');
$this->_handler_id = $handler_id;
@@ -111,7 +112,7 @@ public function _handler_edit($handler_id)
'controller' => $this->_controller,
'save_callback' => [$this, 'save_callback']
]);
return $workflow->run();
return $workflow->run($request);
}
public function save_callback()
@@ -6,6 +6,8 @@
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
*/
use Symfony\Component\HttpFoundation\Request;
/**
* Metadata editor.
*
@@ -26,7 +28,7 @@ class midcom_admin_folder_handler_metadata extends midcom_baseclasses_components
*
* @param string $guid The object GUID
*/
public function _handler_metadata($guid)
public function _handler_metadata(Request $request, $guid)
{
$this->object = midcom::get()->dbfactory->get_object_by_guid($guid);
$this->object->require_do('midgard:update');
@@ -42,7 +44,7 @@ public function _handler_metadata($guid)
'controller' => $this->object->metadata->get_datamanager()->get_controller(),
'save_callback' => [$this, 'save_callback']
]);
return $workflow->run();
return $workflow->run($request);
}
public function save_callback()
@@ -66,7 +66,7 @@ public function _handler_move(Request $request, $guid, array &$data)
midcom::get()->head->set_pagetitle(sprintf($this->_l10n->get('move %s'), $object_label));
$this->add_stylesheet(MIDCOM_STATIC_URL . '/midcom.admin.folder/folder.css');
return $this->get_workflow('viewer')->run();
return $this->get_workflow('viewer')->run($request);
}
public function show_tree(midcom_db_topic $folder = null, $tree_disabled = false)
@@ -7,6 +7,7 @@
*/
use midcom\datamanager\datamanager;
use Symfony\Component\HttpFoundation\Request;
/**
* midcom.datamanager based configuration
@@ -51,7 +52,7 @@ private function load_controller()
/**
* Generic handler for all the DM2 based configuration requests
*/
public function _handler_config()
public function _handler_config(Request $request)
{
// Require corresponding ACLs
$this->_topic->require_do('midgard:update');
@@ -65,7 +66,7 @@ public function _handler_config()
'midcom_baseclasses_components_handler_configuration_recreateok' => true,
]);
}
$response = $workflow->run();
$response = $workflow->run($request);
if ($workflow->get_state() == 'save') {
midcom::get()->uimessages->add($this->_l10n_midcom->get('component configuration'), $this->_l10n_midcom->get('configuration saved'));
@@ -48,7 +48,7 @@ public function _handler_recreate(Request $request, array &$data)
midcom::get()->head->set_pagetitle(sprintf($this->_l10n_midcom->get('recreate images for folder %s'), $data['topic']->extra));
$workflow = $this->get_workflow('viewer');
return $workflow->run();
return $workflow->run($request);
}
/**
@@ -66,7 +66,7 @@ public function _handler_list(Request $request, $handler_id, $filetype, array &$
midcom::get()->head->set_pagetitle($data['list_title']);
if ($data['list_type'] != 'unified') {
$data['form'] = $this->load_controller($data);
$data['form'] = $this->load_controller($request, $data);
} elseif ($data['query'] != '') {
$this->_run_search($data);
}
@@ -78,7 +78,7 @@ public function _handler_list(Request $request, $handler_id, $filetype, array &$
midcom::get()->style->prepend_component_styledir('midcom.helper.imagepopup');
}
private function load_controller(array $data)
private function load_controller(Request $request, array $data)
{
$dm = datamanager::from_schemadb($this->_config->get('schemadb'));
if ($data['list_type'] == 'page') {
@@ -87,7 +87,7 @@ private function load_controller(array $data)
$dm->set_storage($data['folder'], 'default');
}
$controller = $dm->get_controller();
if ($controller->process() === 'cancel') {
if ($controller->handle($request) === 'cancel') {
midcom::get()->head->add_jsonload("top.tinymce.activeEditor.windowManager.close();");
}
return $controller;
@@ -8,6 +8,7 @@
use midcom\datamanager\schemadb;
use midcom\datamanager\datamanager;
use Symfony\Component\HttpFoundation\Request;
/**
* Component configuration handler
@@ -352,7 +353,7 @@ private function _get_config_from_controller()
* @param string $component The component name
* @param string $folder The topic GUID
*/
public function _handler_edit($handler_id, array &$data, $component, $folder = null)
public function _handler_edit(Request $request, $handler_id, array &$data, $component, $folder = null)
{
$data['name'] = $component;
if (!midcom::get()->componentloader->is_installed($data['name'])) {
@@ -374,7 +375,7 @@ public function _handler_edit($handler_id, array &$data, $component, $folder = n
$this->_controller = $this->load_controller();
switch ($this->_controller->process()) {
switch ($this->_controller->handle($request)) {
case 'save':
$this->_save_configuration($data);
// *** FALL-THROUGH ***
@@ -299,7 +299,7 @@ public function _show_edit($handler_id, array &$data)
* @param string $guid The object's GUID
* @param string $filename The filename
*/
public function _handler_delete($guid, $filename)
public function _handler_delete(Request $request, $guid, $filename)
{
$this->prepare_object($guid);
$file = $this->_get_file($filename);
@@ -309,6 +309,6 @@ public function _handler_delete($guid, $filename)
'label' => $filename,
'success_url' => $this->router->generate('object_attachments', ['guid' => $this->_object->guid])
]);
return $workflow->run();
return $workflow->run($request);
}
}
@@ -154,7 +154,7 @@ public function _show_view($handler_id, array &$data)
* @param string $guid The object's GUID
* @param array &$data The local request data.
*/
public function _handler_edit($handler_id, $guid, array &$data)
public function _handler_edit(Request $request, $handler_id, $guid, array &$data)
{
$this->_load_object($guid);
@@ -166,7 +166,7 @@ public function _handler_edit($handler_id, $guid, array &$data)
$this->controller = $dm
->set_storage($this->_object, 'default')
->get_controller();
switch ($this->controller->process()) {
switch ($this->controller->handle($request)) {
case 'save':
// Reindex the object
//$indexer = midcom::get()->indexer;
@@ -230,7 +230,7 @@ public function _handler_create(Request $request, $handler_id, array $args, arra
->set_storage($this->_new_object, 'default')
->get_controller();
switch ($this->controller->process()) {
switch ($this->controller->handle($request)) {
case 'save':
// Reindex the object
//$indexer = midcom::get()->indexer;
@@ -447,7 +447,7 @@ public function _handler_copy(Request $request, $handler_id, $guid, array &$data
$reflector = new midcom_helper_reflector($this->_object);
// Process the form
switch ($this->controller->process()) {
switch ($this->controller->handle($request)) {
case 'save':
$new_object = $this->_process_copy($request, $parent, $reflector);
// Relocate to the newly created object
@@ -7,6 +7,7 @@
*/
use midcom\datamanager\datamanager;
use Symfony\Component\HttpFoundation\Request;
/**
* Metadata editor.
@@ -47,7 +48,7 @@ private function _prepare_request_data()
* @param string $guid The object's GUID
* @param array &$data The local request data.
*/
public function _handler_edit($handler_id, $guid, array &$data)
public function _handler_edit(Request $request, $handler_id, $guid, array &$data)
{
$this->_object = midcom::get()->dbfactory->get_object_by_guid($guid);
$this->_object->require_do('midgard:update');
@@ -62,7 +63,7 @@ public function _handler_edit($handler_id, $guid, array &$data)
$this->_controller = datamanager::from_schemadb(midcom::get()->config->get('metadata_schema'))
->set_storage($this->_object, 'metadata')
->get_controller();
switch ($this->_controller->process()) {
switch ($this->_controller->handle($request)) {
case 'save':
// Reindex the object
//$indexer = midcom::get()->indexer;
@@ -277,7 +277,7 @@ public function _handler_edit(Request $request, $handler_id, $guid, array &$data
// Load the datamanager controller
$this->_controller = $this->load_controller();
switch ($this->_controller->process()) {
switch ($this->_controller->handle($request)) {
case 'save':
//Fall-through
case 'cancel':
@@ -62,7 +62,7 @@ public function _handler_preferences(Request $request, array &$data, $guid = nul
$return_page = $request->query->get('return_uri', '__mfa/asgard/');
// Process the requested form
switch ($data['controller']->process()) {
switch ($data['controller']->handle($request)) {
case 'save':
midcom::get()->uimessages->add($this->_l10n->get($this->_component), $this->_l10n->get('preferences saved'));
return new midcom_response_relocate($return_page);
@@ -7,6 +7,7 @@
*/
use midcom\datamanager\datamanager;
use Symfony\Component\HttpFoundation\Request;
/**
* Shell interface
@@ -18,14 +19,14 @@ class midgard_admin_asgard_handler_shell extends midcom_baseclasses_components_h
/**
* @param array &$data The local request data.
*/
public function _handler_shell(array &$data)
public function _handler_shell(Request $request, array &$data)
{
midcom::get()->auth->require_user_do('midgard.admin.asgard:manage_objects', null, 'midgard_admin_asgard_plugin');
$controller = datamanager::from_schemadb($this->_config->get('schemadb_shell'))
->get_controller();
switch ($controller->process()) {
switch ($controller->handle($request)) {
case 'save':
$data['code'] = $controller->get_form_values()['code'];
break;
@@ -7,6 +7,7 @@
*/
use midcom\datamanager\datamanager;
use Symfony\Component\HttpFoundation\Request;
/**
* group creation class
@@ -24,13 +25,13 @@ public function _on_initialize()
/**
* @param array &$data Data passed to the show method
*/
public function _handler_create(array &$data)
public function _handler_create(Request $request, array &$data)
{
$group = new midcom_db_group;
$dm = datamanager::from_schemadb($this->_config->get('schemadb_group'));
$dm->set_storage($group);
$data['controller'] = $dm->get_controller();
switch ($data['controller']->process()) {
switch ($data['controller']->handle($request)) {
case 'save':
// Show confirmation for the group
midcom::get()->uimessages->add($this->_l10n->get('midgard.admin.user'), sprintf($this->_l10n->get('group %s saved'), $group->name));
@@ -7,6 +7,7 @@
*/
use midcom\datamanager\datamanager;
use Symfony\Component\HttpFoundation\Request;
/**
* Edit a group
@@ -50,7 +51,7 @@ private function _update_breadcrumb()
* @param string $guid The object's GUID
* @param array &$data Data passed to the show method
*/
public function _handler_edit($handler_id, $guid, array &$data)
public function _handler_edit(Request $request, $handler_id, $guid, array &$data)
{
$this->_group = new midcom_db_group($guid);
$this->_group->require_do('midgard:update');
@@ -68,7 +69,7 @@ public function _handler_edit($handler_id, $guid, array &$data)
}
}
$data['controller'] = $dm->get_controller();
switch ($data['controller']->process()) {
switch ($data['controller']->handle($request)) {
case 'save':
// Show confirmation for the group
midcom::get()->uimessages->add($this->_l10n->get('midgard.admin.user'), sprintf($this->_l10n->get('group %s saved'), $this->_group->name));
@@ -9,6 +9,7 @@
use midcom\datamanager\datamanager;
use midcom\datamanager\controller;
use midcom\datamanager\schemadb;
use Symfony\Component\HttpFoundation\Request;
/**
* @package midgard.admin.user
@@ -33,7 +34,7 @@ public function _on_initialize()
* @param string $guid The object's GUID
* @param array &$data Data passed to the show method
*/
public function _handler_edit($handler_id, $guid, array &$data)
public function _handler_edit(Request $request, $handler_id, $guid, array &$data)
{
$this->person = new midcom_db_person($guid);
$this->person->require_do('midgard:update');
@@ -47,7 +48,7 @@ public function _handler_edit($handler_id, $guid, array &$data)
]);
$data['controller'] = $dm->get_controller();
switch ($data['controller']->process()) {
switch ($data['controller']->handle($request)) {
case 'save':
$this->save_account($data['controller']);
// Show confirmation for the user
@@ -110,7 +111,7 @@ private function save_account(controller $controller)
* @param string $guid The object's GUID
* @param array &$data Data passed to the show method
*/
public function _handler_delete($handler_id, $guid, array &$data)
public function _handler_delete(Request $request, $handler_id, $guid, array &$data)
{
$this->person = new midcom_db_person($guid);
$this->person->require_do('midgard:update');
@@ -122,7 +123,7 @@ public function _handler_delete($handler_id, $guid, array &$data)
$dm = new datamanager($schemadb);
$data['controller'] = $dm->get_controller();
switch ($data['controller']->process()) {
switch ($data['controller']->handle($request)) {
case 'delete':
$this->account->delete();
// Show confirmation for the user
Oops, something went wrong.

0 comments on commit 7dde9ae

Please sign in to comment.