Creates a dummy path element in order to be able to execute code after restore

@return restore_path_element[]
499342
public function define_course_plugin_structure() {
        global $DB;

        // Since this method is executed before the restore we can do some pre-checks here.
        // In case of merging backup into existing course find the current number of sections.
        $target = $this->step->get_task()->get_target();
        if (($target == backup::TARGET_CURRENT_ADDING || $target == backup::TARGET_EXISTING_ADDING) &&
                $this->is_pre_33_backup()) {
            $maxsection = $DB->get_field_sql(
                'SELECT max(section) FROM {course_sections} WHERE course = ?',
                [$this->step->get_task()->get_courseid()]);
            $this->originalnumsections = (int)$maxsection;
        }

        // Dummy path element is needed in order for after_restore_course() to be called.
        return [new restore_path_element('dummy_course', $this->get_pathfor('/dummycourse'))];
    }
823495
protected function get_restore_content_dir() {
        $backupfile = null;
        $shortname = null;

        if (!empty($this->options['backupfile'])) {
            $backupfile = $this->options['backupfile'];
        } else if (!empty($this->options['templatecourse']) || is_numeric($this->options['templatecourse'])) {
            $shortname = $this->options['templatecourse'];
        }

        $errors = array();
        $dir = tool_uploadcourse_helper::get_restore_content_dir($backupfile, $shortname, $errors);
        if (!empty($errors)) {
            foreach ($errors as $key => $message) {
                $this->error($key, $message);
            }
            return false;
        } else if ($dir === false) {
            // We want to return null when nothing was wrong, but nothing was found.
            $dir = null;
        }

        if (empty($dir) && !empty($this->importoptions['restoredir'])) {
            $dir = $this->importoptions['restoredir'];
        }

        return $dir;
    }
197520
public function getOriginalPaths()
    {
        if (null === $this->originalReferrerPaths) {
            $this->originalReferrerPaths = [];
            if (self::INITIALIZED_FROM_COLLECTION === $this->initialized) {
                $uow = $this->dm->getUnitOfWork();
                foreach ($this->collection as $referrer) {
                    $this->originalReferrerPaths[] = $uow->getDocumentId($referrer);
                }
            } else {
                $properties = $this->getReferrerProperties();
                foreach ($properties as $property) {
                    $this->originalReferrerPaths[] = $property->getPath();
                }
            }
        }

        return $this->originalReferrerPaths;
    }
229439
public function getElements() {

        $elements = array();
        foreach ($this->modules as $module) {
            if (!$this->trusted && !$module->safe) continue;
            foreach ($module->info as $name => $v) {
                if (isset($elements[$name])) continue;
                $elements[$name] = $this->getElement($name);
            }
        }

        // remove dud elements, this happens when an element that
        // appeared to be safe actually wasn't
        foreach ($elements as $n => $v) {
            if ($v === false) unset($elements[$n]);
        }

        return $elements;

    }
61406
function _createElements()
    {
        $this->_separator = $this->_elements = array();
        $separator =  '';
        $locale    =& $this->_locale[$this->_options['language']];
        $backslash =  false;
        for ($i = 0, $length = strlen($this->_options['format']); $i < $length; $i++) {
            $sign = $this->_options['format']{$i};
            if ($backslash) {
                $backslash  = false;
                $separator .= $sign;
            } else {
                $loadSelect = true;
                switch ($sign) {
                    case 'D':
                        // Sunday is 0 like with 'w' in date()
                        $options = $locale['weekdays_short'];
                        break;
                    case 'l':
                        $options = $locale['weekdays_long'];
                        break;
                    case 'd':
                        $options = $this->_createOptionList(1, 31);
                        break;
                    case 'M':
                        $options = $locale['months_short'];
                        array_unshift($options , '');
                        unset($options[0]);
                        break;
                    case 'm':
                        $options = $this->_createOptionList(1, 12);
                        break;
                    case 'F':
                        $options = $locale['months_long'];
                        array_unshift($options , '');
                        unset($options[0]);
                        break;
                    case 'Y':
                        $options = $this->_createOptionList(
                            $this->_options['minYear'],
                            $this->_options['maxYear'],
                            $this->_options['minYear'] > $this->_options['maxYear']? -1: 1
                        );
                        break;
                    case 'y':
                        $options = $this->_createOptionList(
                            $this->_options['minYear'],
                            $this->_options['maxYear'],
                            $this->_options['minYear'] > $this->_options['maxYear']? -1: 1
                        );
                        array_walk($options, function(&$v, $k) {
                            $v = substr($v, -2);
                        });
                        break;
                    case 'h':
                        $options = $this->_createOptionList(1, 12);
                        break;
                    case 'g':
                        $options = $this->_createOptionList(1, 12);
                        array_walk($options, function(&$v, $k) {
                            $v = intval($v);
                        });
                        break;
                    case 'H':
                        $options = $this->_createOptionList(0, 23);
                        break;
                    case 'i':
                        $options = $this->_createOptionList(0, 59, $this->_options['optionIncrement']['i']);
                        break;
                    case 's':
                        $options = $this->_createOptionList(0, 59, $this->_options['optionIncrement']['s']);
                        break;
                    case 'a':
                        $options = array('am' => 'am', 'pm' => 'pm');
                        break;
                    case 'A':
                        $options = array('AM' => 'AM', 'PM' => 'PM');
                        break;
                    case 'W':
                        $options = $this->_createOptionList(1, 53);
                        break;
                    case '\\':
                        $backslash  = true;
                        $loadSelect = false;
                        break;
                    default:
                        $separator .= (' ' == $sign? '&nbsp;': $sign);
                        $loadSelect = false;
                }

                if ($loadSelect) {
                    if (0 < count($this->_elements)) {
                        $this->_separator[] = $separator;
                    } else {
                        $this->_wrap[0] = $separator;
                    }
                    $separator = '';
                    // Should we add an empty option to the top of the select?
                    if (!is_array($this->_options['addEmptyOption']) && $this->_options['addEmptyOption'] ||
                        is_array($this->_options['addEmptyOption']) && !empty($this->_options['addEmptyOption'][$sign])) {

                        // Using '+' array operator to preserve the keys
                        if (is_array($this->_options['emptyOptionText']) && !empty($this->_options['emptyOptionText'][$sign])) {
                            $options = array($this->_options['emptyOptionValue'] => $this->_options['emptyOptionText'][$sign]) + $options;
                        } else {
                            $options = array($this->_options['emptyOptionValue'] => $this->_options['emptyOptionText']) + $options;
                        }
                    }
                    $this->_elements[] = new HTML_QuickForm_select($sign, null, $options, $this->getAttributes());
                }
            }
        }
        $this->_wrap[1] = $separator . ($backslash? '\\': '');
    }
860236
public function getElements()
    {
        // Get dependencies
        $toolbox = $this->container->toolbox;
        $json = $this->container->json;

        if (isset($this->elementOptions)) {
            return $this->elementOptions;
        }

        // Get all JSON files in directory
        $jsonPath = ROOT_DIR . "structure/definitions/elements/";
        $elements = [];

        foreach ($toolbox->getDirectoryFiles($jsonPath) as $key => $file) {
            if (null === $definition = $json->getJson($jsonPath . $file['filename'], 'element')) {
                throw new Exception('Element JSON definition error: ' . print_r($json->getErrorMessages(), true));
            } else {
                $definition->filename = $file['filename'];
                $elements[] = $definition;
            }
        }

        return $this->elementOptions = $elements;
    }
380774
public function getAutoCreatedChildNodes()
    {
        $this->initialize();
        if (!isset($this->fullConfiguration['childNodes'])) {
            return [];
        }

        $autoCreatedChildNodes = [];
        foreach ($this->fullConfiguration['childNodes'] as $childNodeName => $childNodeConfiguration) {
            if (isset($childNodeConfiguration['type'])) {
                $autoCreatedChildNodes[Utility::renderValidNodeName($childNodeName)] = $this->nodeTypeManager->getNodeType($childNodeConfiguration['type']);
            }
        }

        return $autoCreatedChildNodes;
    }
63440
public function restoreMode() {
		if ( $this->originalMode === null ) {
			throw new TreeBuilderError( "original insertion mode is not set" );
		}
		$mode = $this->mode = $this->originalMode;
		$this->originalMode = null;
		$this->handler = $this->dispatchTable[$mode];
		return $this->handler;
	}
977005
public function build() {

        // Conditionally create the temp table (can exist from prechecks) and delete old stuff
        $this->add_step(new restore_create_and_clean_temp_stuff('create_and_clean_temp_stuff'));

        // Now make sure the user that is running the restore can actually access the course
        // before executing any other step (potentially performing permission checks)
        $this->add_step(new restore_fix_restorer_access_step('fix_restorer_access'));

        // If we haven't preloaded information, load all the included inforef records to temp_ids table
        $this->add_step(new restore_load_included_inforef_records('load_inforef_records'));

        // Load all the needed files to temp_ids table
        $this->add_step(new restore_load_included_files('load_file_records', 'files.xml'));

        // If we haven't preloaded information, load all the needed roles to temp_ids_table
        $this->add_step(new restore_load_and_map_roles('load_and_map_roles'));

        // If we haven't preloaded information and are restoring user info, load all the needed users to temp_ids table
        $this->add_step(new restore_load_included_users('load_user_records'));

        // If we haven't preloaded information and are restoring user info, process all those needed users
        // marking for create/map them as needed. Any problem here will cause exception as far as prechecks have
        // performed the same process so, it's not possible to have errors here
        $this->add_step(new restore_process_included_users('process_user_records'));

        // Unconditionally, create all the needed users calculated in the previous step
        $this->add_step(new restore_create_included_users('create_users'));

        // Unconditionally, load create all the needed groups and groupings
        $this->add_step(new restore_groups_structure_step('create_groups_and_groupings', 'groups.xml'));

        // Unconditionally, load create all the needed scales
        $this->add_step(new restore_scales_structure_step('create_scales', 'scales.xml'));

        // Unconditionally, load create all the needed outcomes
        $this->add_step(new restore_outcomes_structure_step('create_scales', 'outcomes.xml'));

        // If we haven't preloaded information, load all the needed categories and questions (reduced) to temp_ids_table
        $this->add_step(new restore_load_categories_and_questions('load_categories_and_questions'));

        // If we haven't preloaded information, process all the loaded categories and questions
        // marking them for creation/mapping as needed. Any problem here will cause exception
        // because this same process has been executed and reported by restore prechecks, so
        // it is not possible to have errors here.
        $this->add_step(new restore_process_categories_and_questions('process_categories_and_questions'));

        // Unconditionally, create and map all the categories and questions
        $this->add_step(new restore_create_categories_and_questions('create_categories_and_questions', 'questions.xml'));

        // At the end, mark it as built
        $this->built = true;
    }
183815
function recreateDOMTree()
    {
        $aliasList = $this->aliasList();
        $doc = new DOMDocument( '1.0', 'utf-8' );
        $imageNode = $doc->createElement( "ezimage" );
        $doc->appendChild( $imageNode );

        $originalNode = $doc->createElement( "original" );
        $imageNode->appendChild( $originalNode );

        $imageManager = eZImageManager::factory();

        $aliasName = 'original';

        $originalData = $this->originalAttributeData();
        $this->createOriginalAttributeXMLData( $originalNode, $originalData );

        $imageNode->setAttribute( 'serial_number', $this->imageSerialNumber() );
        $imageNode->setAttribute( 'is_valid', $aliasList[$aliasName]['is_valid'] );
        $imageNode->setAttribute( 'filename', $aliasList[$aliasName]['filename'] );
        $imageNode->setAttribute( 'suffix', $aliasList[$aliasName]['suffix'] );
        $imageNode->setAttribute( 'basename', $aliasList[$aliasName]['basename'] );
        $imageNode->setAttribute( 'dirpath', $aliasList[$aliasName]['dirpath'] );
        $imageNode->setAttribute( 'url', $aliasList[$aliasName]['url'] );
        $imageNode->setAttribute( 'original_filename', $aliasList[$aliasName]['original_filename'] );
        $imageNode->setAttribute( 'mime_type', $aliasList[$aliasName]['mime_type'] );
        $imageNode->setAttribute( 'width', $aliasList[$aliasName]['width'] );
        $imageNode->setAttribute( 'height', $aliasList[$aliasName]['height'] );
        $imageNode->setAttribute( 'alternative_text', $aliasList[$aliasName]['alternative_text'] );
        $imageNode->setAttribute( 'alias_key', $imageManager->createImageAliasKey( $imageManager->alias( $aliasName ) ) );
        $imageNode->setAttribute( 'timestamp', $aliasList[$aliasName]['timestamp'] );

        $filename = $aliasList[$aliasName]['url'];
        if ( $filename )
        {
            $imageFile = eZClusterFileHandler::instance( $filename );

            $fetchedFilePath = $imageFile->fetchUnique();

            //(Cluster) Get mime data of real file, and fetch info by image analizer.
            $mimeDataTemp = eZMimeType::findByFileContents( $fetchedFilePath );
            $imageManager->analyzeImage( $mimeDataTemp );

            //(Cluster) Get mime data of a file which does not really exist on file system. We need this to build correct imageInformationNode.
            $mimeData = eZMimeType::findByURL( $filename );
            if ( isset( $mimeDataTemp['info'] ) )
                $mimeData['info'] = $mimeDataTemp['info'];

            $this->createImageInformationNode( $imageNode, $mimeData );
            $imageFile->fileDeleteLocal( $fetchedFilePath );
        }

        foreach ( $aliasList as $aliasName => $alias )
        {
            if ( $aliasName == 'original' )
                continue;
            $this->addImageAliasToXML( $doc, $alias );
        }

        $this->setDOMTree( $doc );
    }
1035637
function &_extensions(&$root, $path = NULL, $create = false)
    {
        if (!isset($root)) {
            $root = $this->currentCert;
        }

        switch (true) {
            case !empty($path):
            case !is_array($root):
                break;
            case isset($root['tbsCertificate']):
                $path = 'tbsCertificate/extensions';
                break;
            case isset($root['tbsCertList']):
                $path = 'tbsCertList/crlExtensions';
                break;
        }

        $extensions = &$this->_subArray($root, $path, $create);

        if (!is_array($extensions)) {
            $false = false;
            return $false;
        }

        return $extensions;
    }
504622
protected function define_structure() {

        $paths = array();
        $userinfo = $this->get_setting_value('userinfo');

        $area = new restore_path_element('grading_area', '/areas/area');
        $paths[] = $area;
        // attach local plugin stucture to $area element
        $this->add_plugin_structure('local', $area);

        $definition = new restore_path_element('grading_definition', '/areas/area/definitions/definition');
        $paths[] = $definition;
        $this->add_plugin_structure('gradingform', $definition);
        // attach local plugin stucture to $definition element
        $this->add_plugin_structure('local', $definition);


        if ($userinfo) {
            $instance = new restore_path_element('grading_instance',
                '/areas/area/definitions/definition/instances/instance');
            $paths[] = $instance;
            $this->add_plugin_structure('gradingform', $instance);
            // attach local plugin stucture to $intance element
            $this->add_plugin_structure('local', $instance);
        }

        return $paths;
    }
468953
public function items($path) {
		if($this->xpath === null)
			return array();
		$r = array();
		$nodes = $this->xpath->evaluate($path);
		foreach($nodes as $n)
			$r[] = new Node($n);
		return $r;
	}
644673
public function loadDefaultElements()
    {
        $this->getOrganizationElement();
        $this->getUserNameElement();
        $this->getSubmitButton();
        $this->getLoginLinkElement();

        return $this;
    }
1047122
public function applyOverrides(): array
    {
        $filesUpdated = [];
        $filesSame    = [];
        $errors       = [];
        foreach ($this->getOverridesIterator() as $pathToFileInOverrides) {
            $relativePathToFileInProject = $this->getRelativePathInProjectFromOverridePath($pathToFileInOverrides);
            if ($this->overrideFileHashIsCorrect($pathToFileInOverrides)) {
                if (false === is_file($pathToFileInOverrides)) {
                    throw new \RuntimeException('path ' . $pathToFileInOverrides . ' is not a file');
                }
                copy($pathToFileInOverrides, $this->pathToProjectRoot . $relativePathToFileInProject);
                $filesUpdated[] = $relativePathToFileInProject;
                continue;
            }
            if ($this->projectFileIsSameAsOverride($pathToFileInOverrides)) {
                $filesSame[] = $relativePathToFileInProject;
                continue;
            }
            $errors[$pathToFileInOverrides] = $this->getProjectFileHash($relativePathToFileInProject);
        }
        if ([] !== $errors) {
            throw new \RuntimeException('These file hashes were not up to date:' . print_r($errors, true));
        }

        return [$this->sortFiles($filesUpdated), $this->sortFiles($filesSame)];
    }
929632
private function createProcessesNodeDefinition()
    {
        $processesNode = new ArrayNodeDefinition('processes');

        $processesNode
            ->useAttributeAsKey('name')
            ->prototype('array')
                ->validate()
                    ->ifTrue(function ($value) {
                        return !empty($value['import']) && !empty($value['steps']);
                    })
                    ->thenInvalid('You can\'t use "import" and "steps" keys at the same time.')
                ->end()
                ->children()
                    ->scalarNode('import')
                        ->defaultNull()
                    ->end()

                    ->scalarNode('start')
                        ->defaultNull()
                    ->end()

                    ->arrayNode('end')
                        ->defaultValue(array())
                        ->prototype('scalar')->end()
                    ->end()
                ->end()
                ->append($this->createStepsNodeDefinition())
            ->end()
        ;

        return $processesNode;
    }
209993
public static function getEntityPaths(): array
    {
        if (self::$paths === null) {
            self::$paths = [realpath(__DIR__ . DIRECTORY_SEPARATOR . 'Entity')];
        }

        return self::$paths;
    }