Skip to content

Commit

Permalink
Move lib.php to classes/handlers.php
Browse files Browse the repository at this point in the history
  • Loading branch information
otacke committed Jan 21, 2025
1 parent 3a1c6c7 commit 082b766
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
13 changes: 8 additions & 5 deletions lib.php → classes/handlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
* @license https://opensource.org/license/mit MIT
*/

namespace local_h5pcaretaker;
use core\context\system as context_system;

defined('MOODLE_INTERNAL') || die();

require_once(join(DIRECTORY_SEPARATOR, [__DIR__, 'vendor', 'autoload.php']));
require_once(join(DIRECTORY_SEPARATOR, [__DIR__, 'classes', 'locale_utils.php']));
require_once(join(DIRECTORY_SEPARATOR, [__DIR__, 'classes', 'render.php']));
require_once(join(DIRECTORY_SEPARATOR, [__DIR__, '..', 'vendor', 'autoload.php']));
require_once(join(DIRECTORY_SEPARATOR, [__DIR__, 'locale_utils.php']));
require_once(join(DIRECTORY_SEPARATOR, [__DIR__, 'render.php']));

use Ndlano\H5PCaretaker\H5PCaretaker;
use local_h5pcaretaker\constants;
Expand All @@ -42,7 +45,7 @@
* phpcs:ignore moodle.Commenting.FileExpectedTags.LicenseTagInvalid
* @license https://opensource.org/license/mit MIT
*/
class local_h5pcaretaker {
class handlers {

/**
* Handle API request to start the Caretaker procedure.
Expand All @@ -64,7 +67,7 @@ public static function handler_start() {
get_string_manager()->reset_caches();

// Load the H5P Caretaker client.
$distdir = join(DIRECTORY_SEPARATOR, [__DIR__, 'node_modules', 'h5p-caretaker-client', 'dist']);
$distdir = join(DIRECTORY_SEPARATOR, [__DIR__, '..', 'node_modules', 'h5p-caretaker-client', 'dist']);
$disturl = '/local/h5pcaretaker/node_modules/h5p-caretaker-client/dist';

render::render_html(
Expand Down
7 changes: 4 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
// Login is not a mandatory requirement for this page.
// phpcs:ignore moodle.Files.RequireLogin.Missing
require_once(__DIR__ . '/../../config.php');
require_once(__DIR__ . '/lib.php');
require_once(__DIR__ . '/classes/handlers.php');
use core\context\system as context_system;
use local_h5pcaretaker\handlers;
use local_h5pcaretaker\constants;

defined('MOODLE_INTERNAL') || die();
Expand All @@ -53,10 +54,10 @@
require_sesskey(); // Verify CSRF token for POST requests.

// Handle file upload.
$response = local_h5pcaretaker::handler_upload();
$response = handlers::handler_upload();
} else {
// Display upload form with CSRF protection.
$response = local_h5pcaretaker::handler_start();
$response = handlers::handler_start();
}

// This site is not supposed to have a header or footer.
Expand Down
2 changes: 0 additions & 2 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

defined('MOODLE_INTERNAL') || die;

require_once(__DIR__ . '/lib.php');

use local_h5pcaretaker\constants;

if (!$hassiteconfig) {
Expand Down

0 comments on commit 082b766

Please sign in to comment.