PageRenderTime 58ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/setup/includes/request/modinstallconnectorrequest.class.php

http://github.com/modxcms/revolution
PHP | 87 lines | 79 code | 0 blank | 8 comment | 2 complexity | c13d6beb0e826a095fd65e9ccc35ce9c MD5 | raw file
Possible License(s): GPL-2.0, Apache-2.0, BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /*
  3. * This file is part of MODX Revolution.
  4. *
  5. * Copyright (c) MODX, LLC. All Rights Reserved.
  6. *
  7. * For complete copyright and license information, see the COPYRIGHT and LICENSE
  8. * files found in the top-level directory of this distribution.
  9. */
  10. require_once strtr(realpath(MODX_SETUP_PATH.'includes/request/modinstallrequest.class.php'),'\\','/');
  11. /**
  12. * modInstallConnector
  13. *
  14. * @package setup
  15. */
  16. /**
  17. * Handles all connector requests to processors.
  18. *
  19. * @package setup
  20. */
  21. class modInstallConnectorRequest extends modInstallRequest {
  22. /** @var modInstall $install */
  23. public $install;
  24. /** @var modInstallJSONError $error */
  25. public $error;
  26. public $action = '';
  27. /**
  28. * Constructor for modInstallConnector object.
  29. *
  30. * @constructor
  31. * @param modInstall &$modInstall A reference to the modInstall object.
  32. */
  33. function __construct(modInstall &$modInstall) {
  34. $this->install =& $modInstall;
  35. $this->loadError();
  36. }
  37. /**
  38. * Loads error processing tool
  39. *
  40. * @param string $class
  41. * @param string $path
  42. * @param array $config
  43. * @return modInstallError
  44. */
  45. public function loadError($class = 'error.modInstallJSONError',$path = '',array $config = array()) {
  46. $className = $this->install->loadClass($class,$path);
  47. if (!empty($className)) {
  48. $this->error = new $className($this->install,$config);
  49. } else {
  50. die('Failure to load '.$class.' from '.$path);
  51. }
  52. return $this->error;
  53. }
  54. /**
  55. * Handles connector requests.
  56. *
  57. * @param string $action
  58. */
  59. public function handle($action = '') {
  60. if ($this->install->isLocked()) {
  61. $this->error->failure('MODX setup is locked!');
  62. }
  63. if (empty($this->install->action)) {
  64. $this->error->failure('No processor specified!');
  65. }
  66. $this->action = $this->install->action;
  67. if($this->action !== 'database/connection') {
  68. $this->install->loadDriver();
  69. }
  70. $f = MODX_SETUP_PATH . 'processors/' . $this->action . '.php';
  71. if (!file_exists($f)) {
  72. $this->error->failure('Could not load requested processor for action ' . $this->action . '.');
  73. }
  74. $install =& $this->install;
  75. $install->loadSettings();
  76. $error =& $this->error;
  77. if (!@include($f)) $this->error->failure('Could not load requested processor for action ' . $this->action . '.');
  78. }
  79. }