Get the retention period fields.

@param   string  $prefix The name of the main field, and prefix for the subfields.
@return  \stdClass
330367
protected function get_retention_period_fields(string $prefix = '') : \stdClass {
        $prefix = "{$prefix}retentionperiod";
        $data = (object) [
            'fields' => [],
            'types' => [],
        ];

        $number = $this->_form->createElement('text', "{$prefix}number", null, ['size' => 8]);
        $data->types["{$prefix}number"] = PARAM_INT;

        $unitoptions = [
            'Y' => get_string('years'),
            'M' => strtolower(get_string('months')),
            'D' => strtolower(get_string('days'))
        ];
        $unit = $this->_form->createElement('select', "{$prefix}unit", '', $unitoptions);

        $data->fields[] = $this->_form->createElement(
                'group',
                $prefix,
                get_string('retentionperiod', 'tool_dataprivacy'),
                [
                    'number' => $number,
                    'unit' => $unit,
                ],
                null,
                false
            );

        return $data;
    }
712378
public function deletePrefix($prefix)
    {
        if ($this->startWith($prefix) === true) {
            return substr($this->str, strlen($prefix));
        }

        return $this->str;
    }
702058
public function getApiContext($prefix = false)
	{
		if(empty($this->apiContext))
		{
			return $this->apiContext;
		}

		// Note: Laravel will convert view periods into directory slashes.
		//       So we can easily interchange . with /
		$apiContextExplode = explode('/', $this->apiContext);

		// Remove 2nd segment if it exists, assuming it is an identifier.
		unset($apiContextExplode[1]);

		// Transform back into a string.
		$genericApiContext = implode('/', $apiContextExplode);

		if($prefix)
		{	
			return $genericApiContext . '/';
		}

		return $this->apiContext;	
	}
619535
public function getConsts($prefix)
    {
        if (isset(self::$consts[$prefix])) {
            return self::$consts[$prefix];
        }

        // 1. Get all class constants
        $class = new \ReflectionClass($this);
        $consts = $class->getConstants();

        // 2. Use exiting constant configs
        $property = lcfirst(str_replace('_', '', ucwords($prefix, '_'))) . 'Table';
        if (isset($this->$property)) {
            $data = $this->$property;
        } else {
            $data = [];
        }

        // 3. Generate id and name
        $prefix .= '_';
        $length = strlen($prefix);
        foreach ($consts as $name => $id) {
            if (stripos($name, $prefix) !== 0) {
                continue;
            }
            if (in_array($name, $this->constExcludes)) {
                continue;
            }
            $data[$id]['id'] = $id;
            $data[$id]['name'] = strtolower(strtr(substr($name, $length), ['_' => '-']));
        }

        self::$consts[$prefix] = $data;

        return $data;
    }
772920
public function find_by_prefix($prefix) {
        $this->ensure_path_exists();
        $prefix = preg_replace('#(\*|\?|\[)#', '[$1]', $prefix);
        $files = glob($this->glob_keys_pattern($prefix), GLOB_MARK | GLOB_NOSORT);
        $return = array();
        if ($files === false) {
            return $return;
        }
        foreach ($files as $file) {
            // Trim off ".cache" from the end.
            $return[] = substr(basename($file), 0, -6);
        }
        return $return;
    }
207582
protected function course_students_query_filter($prefix = false) {
        global $DB;

        if ($prefix) {
            $prefix = $prefix . '.';
        }

        // Check the amount of student logs in the 4 previous weeks.
        list($studentssql, $studentsparams) = $DB->get_in_or_equal($this->get_students(), SQL_PARAMS_NAMED);
        $filterselect = $prefix . 'courseid = :courseid AND ' . $prefix . 'userid ' . $studentssql;
        $filterparams = array('courseid' => $this->course->id) + $studentsparams;

        return array($filterselect, $filterparams);
    }
348635
protected function computeCredentialsName($prefix = null) {
		if (!$prefix) {
			$paths = $this->get('paths');
			if ($paths && isset($paths['default'])) {
				$prefix = $paths['default'];
			}
		}
		preg_match('/([http:\/\/|https:\/\/|ssh:\/\/])*(\w@)*([\w\.\-_]{1,}+)/', $prefix, $prefix);
		if (count($prefix)) return end($prefix);
		return basename($this->repository->getDir());
    }
856398
public function find_by_prefix($prefix) {
        $return = [];
        foreach ($this->find_all() as $key) {
            if (strpos($key, $prefix) === 0) {
                $return[] = $key;
            }
        }
        return $return;
    }
782446
private function prefix($prefix)
    {
        if ($prefix) {
            $prefixLastChar = substr($prefix, -1);

            if ($prefixLastChar != '.' && $prefixLastChar != ':') {
                $prefix .= '.';
            }
        }

        return $prefix;
    }
615516
public function getNextTag($prefix = null)
    {
        $existingTags = $this->listPrefixedTags($prefix);

        $lastTag = array_pop($existingTags);

        if (0 >= preg_match('/^[0-9]+\.[0-9]+\.[0-9]+$/', $lastTag, $matches)) {
            throw new \RuntimeException(sprintf("Unable to parse latest tag, expected pattern X.X.X, found: %s", $lastTag), 22);
        }

        list ($major, $minor, $release) = explode('.', $lastTag, 3);

        return sprintf('%s.%s.%s', $major, $minor, (((int) $release) + 1));
    }
736894
public function getTaxonomyWithPrefix( $prefix )
	{
		if ( ! $prefix ) return false;

		foreach ( $this->importedSchemas as $taxonomy )
		{
			if ( $taxonomy->getPrefix() == $prefix )
			{
				return $taxonomy;
			}
		}

		return false;
	}
857
private function extractPrefixKeyValueData($prefix)
    {
        $result = null;
        
        // If it has key-value data, as evidenced by the raw prefix string
        // being a JSON object (not JSON array), use it.
        if (substr($prefix, 0, 1) === '{') {
            if ($this->isJsonString($prefix)) {
                $result = Json::decode($prefix);
            }
        }
        
        return $result;
    }
1285617
public function getPrefix(string $prefix, string $className): string
    {
        // the  prefix of annotation is exist
        if (! empty($prefix)) {
            return $prefix;
        }

        // the prefix of annotation is empty
        $reg = '/^.*\\\(\w+)' . $this->suffix . '$/';
        $prefix = '';

        if ($result = preg_match($reg, $className, $match)) {
            $prefix = lcfirst($match[1]);
        }

        return $prefix;
    }
445819
public function getFullUrl($prefix = TRUE)
    {
        if ($this->_fullUrl === FALSE) $this->fillPath();
		
        if ($prefix) {
			if (
				(!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ||
				(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || 
				(!empty($_SERVER['HTTP_HTTPS']) && $_SERVER['HTTP_HTTPS'] !== 'off') || 
				(!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443)
			)		
				$schema = 'https:/';
				else $schema = 'http:/';
			return $schema.$this->_fullUrl;
		}
        return $this->_fullUrl;
    }
795813
public function getGMT($prefix = self::GMT)
    {
        //argument must be a string
        Argument::i()->test(1, 'string');

        list($hour, $minute, $sign) = $this->getUtcParts($this->offset);
        return $prefix.$sign.$hour.$minute;
    }
256462
private function getRoamedCompletions(string $prefix): \Generator
    {
        foreach ($this->index->getChildDefinitionsForFqn('') as $fqn => $def) {
            if (!$def->roamed || !nameStartsWith($fqn, $prefix)) {
                continue;
            }
            $completionItem = CompletionItemFactory::fromDefinition($def);
            // Second-guessing the user here - do not trust roaming to work. If the same symbol is
            // inserted in the current namespace, the code will stop working.
            $completionItem->insertText =  '\\' . $fqn;
            yield $fqn => $completionItem;
        }
    }
897106
public static function getAll($prefix = '')
		{

			// Make backend load all
			$backend = static::getBackend();
			$backend->loadAll($prefix);

			// Now return requested translations
			return $backend->translations($prefix);

		}