mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-49519 Google API: use autoload everywhere
Update core (repository & portfolio) to use autoload facilities, getting rid of not-needed-anymore requires. Clarify a bit the readme_moodle information and expected use.
This commit is contained in:
parent
2b90ce658b
commit
c790542885
@ -23,9 +23,8 @@
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
require_once($CFG->libdir . '/google/src/Google/IO/Curl.php');
|
||||
require_once($CFG->libdir . '/google/src/Google/IO/Exception.php');
|
||||
|
||||
/**
|
||||
* Class moodle_google_curlio.
|
||||
|
@ -24,11 +24,9 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir . '/weblib.php');
|
||||
|
||||
// Update the include_path so that the library can use require_once in its own files.
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . $CFG->libdir . '/google');
|
||||
require_once($CFG->libdir . '/google/src/Google/Client.php');
|
||||
// All Google API classes support autoload with this.
|
||||
require_once($CFG->libdir . '/google/autoload.php');
|
||||
// To be able to use our custom IO class.
|
||||
require_once($CFG->libdir . '/google/curlio.php');
|
||||
|
||||
/**
|
||||
|
@ -1,9 +1,9 @@
|
||||
Google APIs Client Library for PHP
|
||||
==================================
|
||||
|
||||
Only the source, README and autoloader files have been kept in this directory:
|
||||
Only the source, LICENSE, README and autoloader files have been kept in this directory:
|
||||
|
||||
- Copy /src/Google to /src/Google
|
||||
- Copy /src/Google to /src/Google
|
||||
- Copy /LICENSE to LICENSE
|
||||
- Copy /README.md to README.md
|
||||
- Copy /autoload.php to autoload.php
|
||||
@ -16,6 +16,17 @@ Here are the files that we have added.
|
||||
that should be used throughout Moodle. It also takes care of including the
|
||||
required files and updating the include_path.
|
||||
|
||||
Every use of the Google PHP API should always start by requiring this file.
|
||||
Apart from the wrapping of Google_Client above... it's also responsible for
|
||||
enabling the autoload of all the API classes.
|
||||
|
||||
So, basically, every use of the Google Client API should be something like:
|
||||
|
||||
require_once($CFG->libdir . '/google/lib.php');
|
||||
$client = get_google_client();
|
||||
|
||||
And, from there, use the Client API normally. Everything will be autoloaded.
|
||||
|
||||
/curlio.php
|
||||
|
||||
An override of the default Google_IO_Curl class to use our Curl class
|
||||
@ -23,6 +34,8 @@ Here are the files that we have added.
|
||||
Curl class should be checked to ensure that its functionalities are covered
|
||||
in this file.
|
||||
|
||||
This should not ever be used directly. The wrapper above uses it automatically.
|
||||
|
||||
|
||||
Information
|
||||
-----------
|
||||
|
@ -22,7 +22,6 @@
|
||||
*/
|
||||
require_once($CFG->libdir.'/portfolio/plugin.php');
|
||||
require_once($CFG->libdir . '/google/lib.php');
|
||||
require_once($CFG->libdir . '/google/src/Google/Service/Drive.php');
|
||||
|
||||
class portfolio_plugin_googledocs extends portfolio_plugin_push_base {
|
||||
/**
|
||||
|
@ -27,7 +27,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot . '/repository/lib.php');
|
||||
require_once($CFG->libdir . '/google/lib.php');
|
||||
require_once($CFG->libdir . '/google/src/Google/Service/Drive.php');
|
||||
|
||||
/**
|
||||
* Google Docs Plugin
|
||||
|
Loading…
x
Reference in New Issue
Block a user