Converts the parambag instance of the native extension format

@param \Danzabar\Config\Data\ParamBag $paramBag
@return Mixed
@author Dan Cox
4416
public function toNative(ParamBag $paramBag)
	{
		// We can assume the extension exists, since it has already been used
		$ext = $this->extensionMap->get($this->extension);
		$native = $ext->load($paramBag->all())->toNative();

		return $native;
	}
657903
public static function factory($sEngine, $aParams = array())
	{
		$sEngine = ucfirst(strtolower($sEngine));
		Core::require_file('ruxon/packages/Session/src/Drivers/Session'.$sEngine.'Driver.class.php');
		$sEngineClass = 'Session'.$sEngine.'Driver';

		return new $sEngineClass($aParams);
	}
1041031
public function convertToJpeg()
    {

        $fileType = 'png';
        $target = sprintf(
            '%s/%s.%s',
            $this->getTarget(),
            $this->getName(),
            $fileType
        );
        $image = $this->createImageFrom($this->getFilePath());
        imagepng($image, $target, 10);
        imagedestroy($image);
        $this->setCovertVars([
            'ext' => $fileType,
            'filepath' => $target
        ]);
        return $this;
    }
536898
public function transform($mixed, array $params = array())
    {
        $facade = $this->newFacade();

        foreach ($mixed as $log) {
            $facade->addLog($this->getContext()->transform('log', $log));
        }

        return $facade;
    }
352942
private function expand($params)
    {
        unset($params['driver']);
        if (isset($params['file'])) {
            if ($params['file'] != '') {
                return $params['file'];
            }
        }

        $equated = [];
        foreach ($params as $key => $value) {
            if ($value == '') {
                continue;
            } else {
                $equated[] = "$key=$value";
            }
        }

        return implode(';', $equated);
    }
223605
private static String convert(String pkg) {

    pkg = pkg.trim();
    if (pkg.endsWith("*")) {
      pkg = pkg.substring(0, pkg.length() - 1);
    }
    if (pkg.endsWith(".query")) {
      // always work with entity bean packages so trim
      pkg = pkg.substring(0, pkg.length() - 6);
    }
    pkg = pkg.replace('.', '/');
    return pkg.endsWith("/") ? pkg : pkg + "/";
  }
1205836
private function _convertOptions(array $options = [])
    {
        $converted = [];
        if (!empty($options)) {
            foreach ($options as $name => $value) {
                if (is_array($value)) {
                    if (!empty($value['AND'])) {
                        $converted[$name] = implode(self::PMP_AND, $value['AND']);
                    } else if (!empty($value['OR'])) {
                        $converted[$name] = implode(self::PMP_OR, $value['OR']);
                    } else {
                        $converted[$name] = ''; // bad params
                    }
                } elseif (is_bool($value)) {
                    $converted[$name] = $value ? 'true' : 'false';
                } else {
                    $converted[$name] = $value;
                }
            }
        }
        return $converted;
    }
204239
protected function formatParameters(array $params)
    {
        $formatted = [];

        foreach ($params as $name => $value) {
            if (!in_array($name, ['member_count', 'room_limit', 'path', 'version_type'], true)) {
                continue;
            }

            if ('version_type' === $name && !in_array($value, ['develop', 'trial', 'release'], true)) {
                throw new InvalidArgumentException('Invalid value of attribute "version_type".');
            }

            $formatted[] = [
                'name' => $name,
                'value' => strval($value),
            ];
        }

        return $formatted;
    }
220610
public function transform($mixed, array $params = array())
    {
        $facade = $this->newFacade();

        $facade->id = $mixed->getId();
        $facade->name = $mixed->getName();
        $facade->mimeType = $mixed->getMimeType();

        $mediaFolder = $mixed->getMediaFolder();
        $facade->title = $this->multiLanguageChoiceManager->choose($mixed->getTitles());
        $facade->original = $this->generateMediaUrl($mixed->getFilesystemName());
        $facade->thumbnail = $this->generateMediaUrl($mixed->getThumbnail());
        $facade->mediaType = $mixed->getMediaType();
        $facade->updatedAt = $mixed->getUpdatedAt();

        if ($this->hasGroup(MediaAdminGroupContext::MEDIA_ALTERNATIVES)) {
            $alternatives = $mixed->getAlternatives();
            foreach ($alternatives as $format => $alternativeName) {
                $facade->addAlternative($format, $this->generateMediaUrl($alternativeName));
            }
        }

        foreach ($mixed->getMediaInformations() as $name => $value) {
            $facade->addMediaInformation($name, $value);
        }

        foreach ($mixed->getKeywords() as $keyword) {
            $facade->addKeyword($keyword);
        }

        $facade->isEditable = false;

        if ($this->authorizationChecker->isGranted(ContributionActionInterface::EDIT, $mediaFolder)) {
            $facade->isEditable = true;
        }

        $facade->addRight(
            'can_edit',
            $this->authorizationChecker->isGranted(ContributionActionInterface::EDIT, $mixed)
        );
        $facade->addRight(
            'can_delete',
            $this->authorizationChecker->isGranted(ContributionActionInterface::DELETE, $mixed) &&
            $this->businessRulesManager->isGranted(BusinessActionInterface::DELETE, $mixed)
        );

        return $facade;
    }
932284
public function transform($mixed, array $params = array())
    {
        $facade = $this->newFacade();

        $extra = array(
            'user_ip' => '0.0.0.0',
            'user_name' => 'Unknown',
            'site_name' => '',
            'site_id' => ''
        );
        $extra = array_merge($extra, $mixed->getExtra());

        $facade->id = $mixed->getId();
        $facade->message = $mixed->getMessage();
        $context = $mixed->getContext();
        if (!empty($context)) {
            $facade->message = $this->translator->trans($mixed->getMessage(), $mixed->getContext());
        }
        $facade->channel = $mixed->getChannel();
        $facade->level = $mixed->getLevel();
        $facade->dateTime = $mixed->getDateTime();
        $facade->levelName = $mixed->getLevelName();
        $facade->userIp = $extra['user_ip'];
        $facade->userName = $extra['user_name'];
        $facade->siteName = $extra['site_name'];
        $facade->siteId = $extra['site_id'];

        return $facade;
    }
470991
protected function actionGetInRectangle($params=array())
    {
        $response = array(
            'errors' => array(),
            'data' => array(
                'count' => 0,
                'items' => array(),
            ),
        );
        $offset = isset($params['offset'])?(int)$params['offset']:0;
        if ($offset < 0) $offset = 0;
        $count = isset($params['count'])?(int)$params['count']:100;
        if ($count < 1) $count = 1;
        if ($count > 100) $count = 100;
        if (!isset($params['latitude'])) {
            $response['errors'][] = 'cmp11';
        }
        if (!isset($params['longitude'])) {
            $response['errors'][] = 'cmp12';
        }
        if (!isset($params['width'])) {
            $response['errors'][] = 'cmp13';
        }
        if (!isset($params['height'])) {
            $response['errors'][] = 'cmp14';
        }
        if (!empty($response['errors'])) {
            return $response;
        }

        $latitude = (double)$params['latitude'];
        $longitude = (double)$params['longitude'];
        if (!Helper::checkLatitude($latitude)) {
            $response['errors'][] = 'bld04';
        }
        if (!Helper::checkLongitude($longitude)) {
            $response['errors'][] = 'bld05';
        }

        $width = (int)$params['width'];
        $height = (int)$params['height'];

        if ($width < 1) {
            $response['errors'][] = 'cmp17';
            return $response;
        }
        if ($height < 1) {
            $response['errors'][] = 'cmp18';
            return $response;
        }

        if (!empty($response['errors'])) {
            return $response;
        }

        if ($width > 5000) {
            $width = 5000;
        }
        if ($height > 5000) {
            $height = 5000;
        }

        // length of meridian = 20004274 meters. https://ru.wikipedia.org/wiki/%D0%9C%D0%B5%D1%80%D0%B8%D0%B4%D0%B8%D0%B0%D0%BD
        $meterInDegree = 180/20004274;

        $minimalLatitude = $latitude;
        $maximalLatitude = round($latitude+$height*$meterInDegree,6);

        $minimalLongitude = $longitude;
        $maximalLongitude = round($longitude+$width*$meterInDegree,6);

        $filter = array(
            'fields' => array(),
            'offset' => $offset,
            'count' => $count,
        );

        $buildsFilter = array(
            'fields' => array(
                array(
                    'field' => 'latitude',
                    'compare' => '>=',
                    'value' => $minimalLatitude,
                ),
                array(
                    'field' => 'latitude',
                    'compare' => '<=',
                    'value' => $maximalLatitude,
                ),
                array(
                    'field' => 'longitude',
                    'compare' => '>=',
                    'value' => $minimalLongitude,
                ),
                array(
                    'field' => 'longitude',
                    'compare' => '<=',
                    'value' => $maximalLongitude,
                ),

            ),
        );

        $builds = $this->build->find($buildsFilter);
        $filter['fields'][] = array(
            'field' => 'build',
            'compare' => 'in',
            'value' => array_keys($builds),
        );
        $response['data']['count'] = $this->company->count($filter);
        $companies = $this->company->find($filter);
        $phonesFilter = array(
            'fields' => array(
                array(
                    'field' => 'company',
                    'compare' => 'in',
                    'value' => array_keys($companies),
                )
            ),
        );
        $phones = $this->phone->find($phonesFilter);
        $catalogFilter = array(
            'fields' => array(
                array(
                    'field' => 'company',
                    'compare' => 'in',
                    'value' => array_keys($companies),
                )
            ),
        );
        $catalog = $this->catalog->find($catalogFilter);
        $rubricIds = array();
        foreach ($catalog as $item) {
            $rubricIds[$item['rubric']] = $item['rubric'];
        }
        $rubricsFilter = array(
            'fields' => array(
                array(
                    'field' => 'id',
                    'compare' => 'in',
                    'value' => $rubricIds,
                )
            ),
        );
        $rubrics = $this->rubric->find($rubricsFilter);
        $companiesData = $this->mergeData($companies,$builds,$phones,$rubrics,$catalog);
        $response['data']['items'] = array_values($companiesData);
        return $response;
    }
1080192
private static function getParamObject(array $params) {
        $obj              = new stdClass;
        $obj->paramData   = array();
        $obj->paramIsFile = array();
        foreach ($params as $key => $value) {
            if (strpos($key, '@') === 0) {
                $obj->paramData[substr($key, 1)]   = self::safeGetContents($key, $value);
                $obj->paramIsFile[substr($key, 1)] = true;
            } elseif (strpos($key, '#') === 0) {
                $obj->paramData[substr($key, 1)]   = $value;
                $obj->paramIsFile[substr($key, 1)] = true;
            } else {
                $obj->paramData[$key]   = $value;
                $obj->paramIsFile[$key] = false;
            }
        }
        return $obj;
    }
189831
public function convert() {
        global $CFG;
        require_once($CFG->dirroot . '/backup/util/helper/convert_helper.class.php');

        // Basic/initial prevention against time/memory limits
        core_php_time_limit::raise(1 * 60 * 60); // 1 hour for 1 course initially granted
        raise_memory_limit(MEMORY_EXTRA);
        $this->progress->start_progress('Backup format conversion');

        if ($this->status != backup::STATUS_REQUIRE_CONV) {
            throw new restore_controller_exception('cannot_convert_not_required_status');
        }

        $this->log('backup format conversion required', backup::LOG_INFO);

        // Run conversion to the proper format
        if (!convert_helper::to_moodle2_format($this->get_tempdir(), $this->format, $this->get_logger())) {
            // todo - unable to find the conversion path, what to do now?
            // throwing the exception as a temporary solution
            throw new restore_controller_exception('unable_to_find_conversion_path');
        }

        $this->log('backup format conversion successful', backup::LOG_INFO);

        // If no exceptions were thrown, then we are in the proper format
        $this->format = backup::FORMAT_MOODLE;

        // Load plan, apply security and set status based on interactivity
        $this->load_plan();

        // Perform all initial security checks and apply (2nd param) them to settings automatically
        restore_check::check_security($this, true);

        if ($this->interactive == backup::INTERACTIVE_YES) {
            $this->set_status(backup::STATUS_SETTING_UI);
        } else {
            $this->set_status(backup::STATUS_NEED_PRECHECK);
        }
        $this->progress->end_progress();
    }
2390
public function replaceBy($aParams = array()) 
	{
		$aOptions = array();
		$mSelected = '';

		if (isset($aParams['options'])) { $aOptions = $aParams['options']; }
		else { new \Exception('HtmlOptions: options obligatory');}

		if (isset($aParams['selected'])) { $mSelected = $aParams['selected']; }

		$sOption = '';

		foreach ($aOptions as $mOne) {

			$sOption .= '<option value="'.$mOne.'">'.$mOne.'</option>';
		}

		return $sOption;
	}
369394
public function reverseTransform(FacadeInterface $facade, array $params = array())
    {
        if (null !== $facade->contentTypeId) {
            return $this->contentTypeRepository->findOneByContentTypeIdInLastVersion($facade->contentTypeId);
        }

        return null;
    }
1225073
public function decompress($data, $params = array())
    {
        $out = array();

        if ($this->_geti($data, 32) == self::SIGNATURE) {
            $this->_geti($data, 16);

            while (strlen($data) > 0) {
                switch ($this->_geti($data, 8)) {
                case self::LVL_MESSAGE:
                    $this->_decodeMessage($data);
                    break;

                case self::LVL_ATTACHMENT:
                    $this->_decodeAttachment($data, $out);
                    break;
                }
            }
        }

        return array_reverse($out);
    }
1136158
public function translate(string $text, array $params = null)
    {
        $index = null;
        $namespace = 'Apps\Controller\\' . env_name . '\\';
        foreach (@debug_backtrace() as $caller) {
            if (isset($caller['class']) && Str::startsWith($namespace, $caller['class'])) {
                $index = Str::sub((string)$caller['class'], Str::length($namespace));
            }
        }
        return $this->get($index, $text, $params);
    }