Skip to content
Snippets Groups Projects
Select Git revision
  • 0febe9a9a08986251087c22153afa3d58e98b9fb
  • master default protected
  • hsh_v4.5
  • hsh_v4-4
  • hsh_v4.4
  • hsh_v4.3
  • hsh_v4.1.x
  • hsh_v4.2
  • hsh_v4.1
  • hsh_v3.11
  • hsh_3.10
  • v3.11-r2-hsh
  • v3.11-r2
  • v3.11-r1
  • v3.10-r1
  • v3.9-r1
  • v3.8-r2
  • v3.8-r1
  • v3.7-r1
19 results

backup_lifecycle_workflow.php

Blame
  • backup_lifecycle_workflow.php 5.74 KiB
    <?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/>.
    
    /**
     * Class to backup a workflow.
     * @package    tool_lifecycle
     * @copyright  2017 Tobias Reischmann WWU
     * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
     */
    namespace tool_lifecycle\local\backup;
    
    use tool_lifecycle\local\entity\step_subplugin;
    use tool_lifecycle\local\entity\trigger_subplugin;
    use tool_lifecycle\local\entity\workflow;
    use tool_lifecycle\local\manager\workflow_manager;
    use tool_lifecycle\local\manager\step_manager;
    use tool_lifecycle\local\manager\trigger_manager;
    use tool_lifecycle\local\manager\settings_manager;
    use tool_lifecycle\settings_type;
    
    defined('MOODLE_INTERNAL') || die();
    
    /**
     * Class to backup a workflow.
     * @package    tool_lifecycle
     * @copyright  2017 Tobias Reischmann WWU
     * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
     */
    class backup_lifecycle_workflow {
    
        /** @var $workflow workflow */
        private $workflow;
        /** @var $steps step_subplugin[] */
        private $steps;
        /** @var $trigger trigger_subplugin[] */
        private $trigger;
        /** @var $writer \XMLWriter */
        private $writer;
        /** @var $tempfilename string */
        private $tempfilename;
    
        /**
         * backup_lifecycle_workflow constructor.
         * @param int $workflowid Id of the workflow a backup should be created for.
         * @throws \dml_exception
         */
        public function __construct($workflowid) {
            $this->workflow = workflow_manager::get_workflow($workflowid);
            $this->steps = step_manager::get_step_instances($workflowid);
            $this->trigger = trigger_manager::get_triggers_for_workflow($workflowid);
        }
    
        /**
         * Executes the backup process. It write the workflow with all steps and triggers to a xml file.
         * Afterwards send_temp_file should be called, which sends the file to the client.
         * @throws \moodle_exception
         */