Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | List of all members
mod_forum\local\builders\exported_posts Class Reference

Exported post builder class. More...

Public Member Functions

 __construct (renderer_base $renderer, legacy_data_mapper_factory $legacydatamapperfactory, exporter_factory $exporterfactory, vault_factory $vaultfactory, rating_manager $ratingmanager)
 Constructor. More...
 
 build (stdClass $user, array $forums, array $discussions, array $posts)
 Build the exported posts for a given set of forums, discussions, and posts. More...
 

Detailed Description

Exported post builder class.

This class is an implementation of the builder pattern (loosely). It is responsible for taking a set of related forums, discussions, and posts and generate the exported version of the posts.

It encapsulates the complexity involved with exporting posts. All of the relevant additional resources will be loaded by this class in order to ensure the exporting process can happen.

See this doc for more information on the builder pattern: https://designpatternsphp.readthedocs.io/en/latest/Creational/Builder/README.html

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

mod_forum\local\builders\exported_posts::__construct ( renderer_base  $renderer,
legacy_data_mapper_factory  $legacydatamapperfactory,
exporter_factory  $exporterfactory,
vault_factory  $vaultfactory,
rating_manager  $ratingmanager 
)

Constructor.

Parameters
renderer_base$rendererCore renderer
legacy_data_mapper_factory$legacydatamapperfactoryLegacy data mapper factory
exporter_factory$exporterfactoryExporter factory
vault_factory$vaultfactoryVault factory
rating_manager$ratingmanagerRating manager

Member Function Documentation

◆ build()

mod_forum\local\builders\exported_posts::build ( stdClass  $user,
array  $forums,
array  $discussions,
array  $posts 
)

Build the exported posts for a given set of forums, discussions, and posts.

This will typically be used for a list of posts in the same discussion/forum however it does support exporting any arbitrary list of posts as long as the caller also provides a unique list of all discussions for the list of posts and all forums for the list of discussions.

Increasing the number of different forums being processed will increase the processing time due to processing multiple contexts (for things like capabilities, files, etc). The code attempts to load the additional resources as efficiently as possible but there is no way around some of the additional overhead.

Note: Some posts will be removed as part of the build process according to capabilities. A one-to-one mapping should not be expected.

Parameters
stdClass$userThe user to export the posts for.
forum_entity[]$forumsA list of all forums that each of the $discussions belong to
discussion_entity[]$discussionsA list of all discussions that each of the $posts belong to
post_entity[]$postsThe list of posts to export.
Return values
stdClass[]List of exported posts in the same order as the $posts array.

The documentation for this class was generated from the following file: