Detect File Path from Parameters.

@param ArrayObject $params

@return false|string
341140
private static function detectFilePath($params)
    {
        if (isset($params->path) && !empty($params->path)) {
            return $params->path;
        }
        if (isset($params->file) && !empty($params->file)) {
            return $params->path;
        }

        return false;
    }
145475
private function decodeParams($params)
    {
        if (is_string($params)) {
            $params = urldecode($params);
        } elseif (is_array($params)) {
            foreach ($params as &$currentParam) {
                $currentParam = $this->decodeParams($currentParam);
            }
        }

        return $params;
    }
455610
protected function getSignature(array $params):string {
		ksort($params);

		$signature = '';

		foreach($params as $k => $v){
			if(!in_array($k, ['format', 'callback'])){
				$signature .= $k.$v;
			}
		}

		return md5($signature.$this->options->secret);
	}
1102828
protected function _save(array $params = []) {
		$params['path'] = Inflector::underscore($this->request->action);
		$params['file'] = $this->request->args(0);

		$contents = $this->_template();
		$result = Text::insert($contents, $params);

		if (!empty($this->_library['path'])) {
			$path = $this->_library['path'] . "/views/{$params['path']}/{$params['file']}";
			$file = str_replace('//', '/', "{$path}.php");
			$directory = dirname($file);

			if (!is_dir($directory)) {
				if (!mkdir($directory, 0755, true)) {
					return false;
				}
			}
			$directory = str_replace($this->_library['path'] . '/', '', $directory);
			if (file_exists($file)) {
				$prompt = "{$file} already exists. Overwrite?";
				$choices = ['y', 'n'];
				if ($this->in($prompt, compact('choices')) !== 'y') {
					return "{$params['file']} skipped.";
				}
			}
			if (is_int(file_put_contents($file, $result))) {
				return "{$params['file']}.php created in {$directory}.";
			}
		}
		return false;
	}
119151
public static function get(string $path, array $params = null): string
    {
        self::init();
        $rule = self::$config['dynamic'];
        if (is_callable($rule['path'])) {
            $path = call_user_func_array($rule['path'], [self::$domin, $path, self::$script]);
        }
        //存在get参数
        if ($params && is_callable($rule['query'])) {
            $path .= call_user_func($rule['query'], $params); //get参数
        }
        return $path;
    }
1176349
public function getRequestTargetWithParams($params)
    {
        $target = $this->getFullPath();

        if ($params) {
            $target .= '?' . http_build_query($params);
        }

        return $target;
    }
603064
public static function fromSuccess(array $params)
    {
        $matchResult = new self();
        $matchResult->type = 'success';
        $matchResult->params = $params;
        return $matchResult;
    }
968731
public function getHrefWithDoAppend(array $params): string
    {
        $href = [];
        $href[] = static::makeParam('p', $this->p);
        $href[] = $this->parseParameter('do', $this->do == '_default' ? '' : $this->do, $params);

        foreach ($params as $key => $value) {
            $href[] = static::makeParam($key, $value);
        }

        return '?' . implode('&', $href);
    }
89122
public function serializeParams($params) {
		$serialized = '';
		foreach ($params as $key => $val) {
			$serialized .= $key;
			if (is_bool($val) === true) {
				$serialized .= '=' . $val ? $this->options['param-true'] : $this->options['param-false'];
			} else if ($val != '') {
				$serialized .= '=' . $val;
			}
			$serialized .= $this->options['param-delimiter'];
		}
		return $serialized;
	}
585471
public static function doesntContainParams(...$params): bool
    {
        if (is_array($params[0])) {
            $params = $params[0];
        }

        $targetCount = count($params);
        $params = array_flip($params);

        foreach (static::getAllParameters() as $name => $value) {
            if (array_key_exists($name, $params)) {
                unset($params[$name]);
            }
        }

        return count($params) == $targetCount;
    }
1262510
public function getCachePath($path, array $params = [])
    {
        $sourcePath = $this->getSourcePath($path);

        if ($this->sourcePathPrefix) {
            $sourcePath = substr($sourcePath, strlen($this->sourcePathPrefix) + 1);
        }

        $params = $this->getAllParams($params);
        unset($params['s'], $params['p']);
        ksort($params);

        $md5 = md5($sourcePath.'?'.http_build_query($params));

        $cachedPath = $this->groupCacheInFolders ? $sourcePath.'/'.$md5 : $md5;

        if ($this->cachePathPrefix) {
            $cachedPath = $this->cachePathPrefix.'/'.$cachedPath;
        }
        
        if ($this->cacheWithFileExtensions) {
            $ext = (isset($params['fm']) ? $params['fm'] : pathinfo($path)['extension']);
            $ext = ($ext === 'pjpg') ? 'jpg' : $ext;
            $cachedPath .= '.'.$ext;
        }

        return $cachedPath;
    }
423957
public function path(array $params = array())
    {
        $this->build();
        
        $path = [];
        if ($this->_modules)
            $path = $this->_modules;
        $path[] = $this->_controller;
        $path[] = isset($params['action']) ? $params['action'] : $this->_action;
        
        $format = isset($params['format']) ? '.' . $params['format'] : '';
        
        return implode('/', $path) . $format;
    }
1027899
protected function _params2string($params)
    {
        if (!count($params)) {
            return '';
        }
        $paramsPart = array();
        foreach ($params as $name => $value) {
            if (!$value && ('0' !== $value)) {
                continue;
            }
            $paramsPart[] = str_replace(array('{name}', '{value}'), array($name, urlencode($value)), $this->paramsPairStructure);
        }
        if (!count($paramsPart)) {
            return '';
        }
        return '/' . implode($this->paramsSeparator, $paramsPart);
    }
180141
public static function makeUrl(array $params): string
    {
        $href = [];

        foreach ($params as $key => $value) {
            $href[] = static::makeParam($key, (string)$value);
        }

        return '?' . implode('&', $href);
    }
1204919
protected function readApiName($params = []) {
        /** @var $api */
        /** @var $apiGroup */
        /** @var $operations */
        extract($params);
        $exists = [];
        $apiName = $this->applyFilter('Name', $this->parseApiName($api), compact('api', 'apiGroup'));
        if (isset($operations[$apiName])) {
            $exists[] = "Exists ... $apiName [{$api['name']}]";
            $apiName = $this->applyFilter('Slug', $this->sluggify($api['name']), compact('api', 'apiGroup'));
            $exists[] = " Named it to - ";
            $exists[] = $apiName;
        }
        $apiName = $this->applyFilter('FinalName', $apiName, compact('api', 'apiGroup'));
        if (!empty($exists) && end($exists) !== $apiName) {
            $exists[] = ", but again renamed by filter to - $apiName.";
        }
        if (isset($operations[$apiName])) {
            do {
                if (!empty($exists)) {
                    $exists[] = " ! still";
                }
                $exists[] = " duplicate ! renaming to _{$apiName} [{$api['name']}].";
                $apiName = '_' . $apiName;
            } while (isset($operations[$apiName]));
        }
        if (!empty($exists)) {
//            var_dump(implode("", $exists));
        }
        return $apiName;
    }
361205
private function createSubfolder($path, array $params)
    {
        // Ensure the path ends in "/" and the body is empty.
        $params['Key'] = rtrim($params['Key'], '/') . '/';
        $params['Body'] = '';

        // Fail if this pseudo directory key already exists
        if ($this->getClient()->doesObjectExist(
            $params['Bucket'],
            $params['Key'])
        ) {
            return $this->triggerError("Subfolder already exists: {$path}");
        }

        return $this->boolCall(function () use ($params, $path) {
            $this->getClient()->putObject($params);
            $this->clearCacheKey($path);
            return true;
        });
    }
132000
public static function assetURL(array $params)
    {
        if (isset($params['asset']) && is_object($params['asset'])) {
            $asset = $params['asset'];
            $params['asset'] = $params['asset']->getId();
        }

        if (!isset($params['action'])) {
            $params['action'] = 'view';
        }

        if (isset($params['height']) && !isset($params['width'])) {
            $params['width'] = 0;
        }

        $url = route('asset', $params);

        if (isset($asset)) {
            $url .= '?'.$asset->getLastModified()->getTimestamp();
        }

        return $url;
    }