| Línea 197... |
Línea 197... |
| 197 |
* Creates a new category and inserts it to the database
|
197 |
* Creates a new category and inserts it to the database
|
| 198 |
*
|
198 |
*
|
| 199 |
* @param string $name name of the category, null to generate automatically
|
199 |
* @param string $name name of the category, null to generate automatically
|
| 200 |
* @return int id of the new category
|
200 |
* @return int id of the new category
|
| 201 |
*/
|
201 |
*/
|
| 202 |
public function create_category(string $name = null): int {
|
202 |
public function create_category(?string $name = null): int {
|
| 203 |
global $DB;
|
203 |
global $DB;
|
| 204 |
$params = ['component' => $this->get_component(), 'area' => $this->get_area(), 'itemid' => $this->get_itemid()];
|
204 |
$params = ['component' => $this->get_component(), 'area' => $this->get_area(), 'itemid' => $this->get_itemid()];
|
| Línea 205... |
Línea 205... |
| 205 |
|
205 |
|
| 206 |
if (empty($name)) {
|
206 |
if (empty($name)) {
|
| Línea 519... |
Línea 519... |
| 519 |
* @param \restore_structure_step $step The restore step instance.
|
519 |
* @param \restore_structure_step $step The restore step instance.
|
| 520 |
* @param int $newid The new ID for the custom field data after restore.
|
520 |
* @param int $newid The new ID for the custom field data after restore.
|
| 521 |
* @param int $oldid The original ID of the custom field data before backup.
|
521 |
* @param int $oldid The original ID of the custom field data before backup.
|
| 522 |
*/
|
522 |
*/
|
| 523 |
public function restore_define_structure(\restore_structure_step $step, int $newid, int $oldid): void {
|
523 |
public function restore_define_structure(\restore_structure_step $step, int $newid, int $oldid): void {
|
| 524 |
$datacontrollers = $this->get_instance_data($newid);
|
- |
|
| Línea -... |
Línea 524... |
| - |
|
524 |
|
| - |
|
525 |
// Retrieve the 'instanceid' of the new custom field data.
|
| - |
|
526 |
$instanceid = (new data($newid))->get('instanceid');
|
| - |
|
527 |
|
| 525 |
|
528 |
$datacontrollers = $this->get_instance_data($instanceid);
|
| 526 |
foreach ($datacontrollers as $controller) {
|
529 |
foreach ($datacontrollers as $controller) {
|
| 527 |
$controller->restore_define_structure($step, $newid, $oldid);
|
530 |
$controller->restore_define_structure($step, $newid, $oldid);
|
| 528 |
}
|
531 |
}
|