1<?php 2// This file is part of Moodle - http://moodle.org/ 3// 4// Moodle is free software: you can redistribute it and/or modify 5// it under the terms of the GNU General Public License as published by 6// the Free Software Foundation, either version 3 of the License, or 7// (at your option) any later version. 8// 9// Moodle is distributed in the hope that it will be useful, 10// but WITHOUT ANY WARRANTY; without even the implied warranty of 11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12// GNU General Public License for more details. 13// 14// You should have received a copy of the GNU General Public License 15// along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16/** 17 * Contains the service_factory, a locator for services for course content items. 18 * 19 * Services encapsulate the business logic, and any data manipulation code, and are what clients should interact with. 20 * 21 * @package core_course 22 * @copyright 2020 Adrian Greeve <adrian@moodle.com> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25namespace core_course\local\factory; 26 27defined('MOODLE_INTERNAL') || die(); 28 29use core_course\local\repository\caching_content_item_readonly_repository; 30use core_course\local\repository\content_item_readonly_repository; 31use core_course\local\service\content_item_service; 32 33/** 34 * Class service_factory, providing functions for location of service objects for course content items. 35 * 36 * This class is responsible for providing service objects to clients only. 37 * 38 * @copyright 2020 Adrian Greeve <adrian@moodle.com> 39 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 40 */ 41class content_item_service_factory { 42 43 /** 44 * Returns a basic service object providing operations for course content items. 45 * 46 * @return content_item_service 47 */ 48 public static function get_content_item_service(): content_item_service { 49 return new content_item_service( 50 new caching_content_item_readonly_repository( 51 \cache::make('core', 'user_course_content_items'), 52 new content_item_readonly_repository() 53 ) 54 ); 55 } 56} 57