Handle a static asset by outputting the file contents and size to the browser.
If the asset does not exist, throw a 404 and exit.

This method has been deprecated in favor of asset symlinking.

@deprecated
@param array $params
513681
public function handleAsset($params) {
        $response = $this->getResponse();
        $path = null;

        try {
            $module = $this->getModule($params['module']);
            $path = implode('/', [$module->getPath(), 'web', $params['asset'], $params['path']]);

            $this->emit('mvc.preAsset', [$this, &$path, $response]);

            if (file_exists($path)) {
                $response
                    ->body(file_get_contents($path))
                    ->cache()
                    ->contentType(pathinfo($path, PATHINFO_EXTENSION))
                    ->contentLength(filesize($path))
                    ->lastModified(filemtime($path));
            } else {
                $response->statusCode(404);
            }
        } catch (Exception $e) {
            $response->statusCode(404);
        }

        $this->emit('mvc.postAsset', [$this, $path, $response]);

        $response->respond();
        exit();
    }
897350
public static function asset($filename, $params = array())
    {
        if ($plugin = self::get('app.running_plugin')) {
            return self::pluginAsset($plugin, $filename, $params);
        }
        return self::appAsset($filename, $params);
    }
1043870
protected function runConsole(array $params): void
    {
        $kernel = $this->app->make(KernelContract::class);

        $status = $kernel->handle(
            $input = new ArgvInput(array_values($params)),
            new ConsoleOutput()
        );

        $kernel->terminate($input, $status);

        exit($status);
    }
246769
public function index(array $params)
    {
        try {
            $directoryListing = $this->directoryListing($params);

            $count = count($directoryListing);

            /**
             * Remove Last 2 arrays
             */
            $output = array_slice(
                $directoryListing,
                0,
                $count - 2
            );

            /**
             * Paginate or Error if nothing found
             */
            if (is_array($directoryListing) && $count > '0') {
                $paginator = new Paginator(new ArrayAdapter($output));

                $paginator->setDefaultItemCountPerPage($count);
            } else {
                throw new \Exception(
                    $directoryListing . ' ' . $this->translate->translate(
                        'was not found',
                        'mp3'
                    )
                );
            }

            $path = (array_key_exists(
                'dir',
                $params
            ))
                ? $params['dir']
                : null;

            return [
                'paginator'     => $paginator,
                'path'          => $path,
                'totalLength'   => $directoryListing['totalLength'],
                'totalFileSize' => $directoryListing['totalFileSize'],
                'search'        => (is_file($this->getSearchFile()))
            ];
        } catch (\Exception $e) {
            throw $e;
        }
    }
1267884
public function execute($params = array())
    {
        $this->mergeParams($params);

        $reconnect = $this->db->getOption('reconnect');
        $reconnectRetries = $this->db->getOption('reconnect_retries', 3);
        $reconnectDelayMS = $this->db->getOption('reconnect_delay_ms', 1000);

        while (true) {
            $e = null;
            $errorCode = null;
            $errorInfo = null;
            $result = null;

            $isReconnectError = false;
            try {
                $this->prepare();
                foreach ($this->positionParams as $index => $value) {
                    $this->statement->bindValue($index + 1, $value);
                }

                $result = $this->statement->execute($this->params?:null);
            } catch (\Exception $e) {
            }

            if ($result === false || !$e) {
                $errorCode = $this->statement->errorCode();
                $errorInfo = $this->statement->errorInfo();
            }

            $isReconnectError = Util::checkReconnectError($errorCode, $errorInfo, $e);

            // reconnect
            if ($reconnect && $isReconnectError && $reconnectRetries > 0) {
                $reconnectRetries--;
                $this->statement = null;
                $this->db->close();
                $reconnectDelayMS && usleep($reconnectDelayMS * 1000);
                continue;
            }

            break;
        }

        if ($e) {
            $this->db->logError(sprintf('Statement exception error #%s: %s', $e->getCode(), $e->getMessage()));
            throw $e;
        }

        if ($result === false) {
            $this->db->logError(sprintf('Statement execute error #%s: %s', $errorInfo[0], $errorInfo[2]));
            return false;
        }

        return $this->statement->rowCount();
    }
120036
private function parseStandardRoute($params) {
		
		// set module, action and page nr by parameters
		foreach ($params as $pos => $value) {
			
			switch ($pos) {
				
				case 0:

					// module name, nothing to do here
					break;
					
				case 1:
					
					$this->action = urldecode($value);
					break;
					
				default:
					
					$param = urldecode($value);
					
					// flag to not send back log (useful for AJAX)
					if ('noLog' == $param) {
						$this->sendLog = FALSE;
						// ordering
					} else if ('order-' == substr($param, 0, 6)) {
						$nr = intval(substr($param, 6));
						if ($nr) $this->order = $nr;
						// pagination
					} else if ('page-' == substr($param, 0, 5)) {
						$nr = intval(substr($param, 5));
						$this->setPage($nr);
					} else {
						if (''!=$param and !is_null($param)) {
							$this->vars[] = $param;
						}
					}
					break;
					
			}
				
		}
		
	}
1193958
public function build(array $params = null) 
    {
        if(null !== $params) {
            $this->setParams($params);
        }
        
        $this->adapter = $this->getDoctrinePaginatorAdapter();
		$this->setCurrentPageNumber($this->getParam('page', 1));
		$this->setDefaultItemCountPerPage($this->getParam('limit', 30));
    }
784603
private function resize(array $params)
    {
        $width = (isset($params['width']) && is_numeric($params['width'])) ? $params['width'] : null;
        $height = (isset($params['height']) && is_numeric($params['height'])) ? $params['height'] : null;

        if (!is_null($width) && !is_null($height)) {
            $this->image->resize(new Box($width, $height));
        } elseif (!is_null($width)) {
            $height = $this->image->getSize()->getHeight() / ($this->image->getSize()->getWidth() / $width);

            $this->image->resize(new Box($width, $height));
        } elseif (!is_null($height)) {
            $width = $this->image->getSize()->getWidth() / ($this->image->getSize()->getHeight() / $height);

            $this->image->resize(new Box($width, $height));
        } else {
            throw new Exception('Wrong resize width or height');
        }
    }
1119276
public function handleAction($action, $params, $raw = false)
    {
        $this->setupTemplate($this->className, $action);
        $output = parent::handleAction($action, $params, true);

        // No output and no template set:
        if (empty($output) && empty($this->template)) {
            throw new \Exception('No output or template for ' . $this->className . '.' . $action);
        }

        // No output, but we do have a legacy view to render:
        if (empty($output) && !empty($this->view)) {
            $output = $this->view->render();
        }

        // Has output, handle legacy style layout for it:
        if (!empty($output) && $this->response->hasLayout()) {
            $this->template->output = $output;
        }
        
        if (!empty($output) && !$this->response->hasLayout()) {
            return $output;
        }

        $this->template->set('title', $this->title);
        $this->template->set('subtitle', $this->subtitle);
        $this->template->set('breadcrumb', $this->breadcrumb);

        $this->response->setContent($this->template->render());
        return $this->response;
    }
675026
protected function setOutputColorVisibility(array $params)
    {
        if ($this->hasParameter($params, '-nc') || $this->hasParameter($params, '--no-color')) {
            $this->hideColors = true;
        }
    }
937092
public function post($params = array(), $options = array())
	{
		// If its an array (instead of a query string) then format it correctly
		if (is_array($params))
		{
            if($this->format == "json"){
                $params = json_encode($params);
            }else{
                if(!empty($_FILES)){
                    foreach($_FILES as $fileField => $fileVal){
                        $params[$fileField] = curl_file_create($fileVal['tmp_name'], $fileVal['type'], $fileVal['name']);
                    }
                }else{
					$params = http_build_query($params, NULL, '&');
				}
            }
		}

		// Add in the specific options provided
		$this->options($options);

		$this->http_method('post');

		$this->option(CURLOPT_POST, TRUE);
		$this->option(CURLOPT_POSTFIELDS, $params);
	}
198072
public function asset_find_file($params) {
        if (!isset($params['file'])) {
            throw new \UnexpectedValueException("The file parameter is required.");
        }
        if (!isset($params['type'])) {
            throw new \UnexpectedValueException("The type parameter is required.");
        }
        $folder = isset($params['folder']) ? $params['folder'] : '';
        return Asset::find_file($params['file'], $params['file'], $folder);
    }
1370113
protected function dumpAssets($files, $targetFilename = null, $useRequireJs = false)
    {
        $content = '';
        foreach ($files as $file) {
            $content .= file_get_contents($file) . "\n";
        }
        if ($useRequireJs) {
            $content = "define('debugbar', ['jquery'], function($){\r\n" . $content . "\r\n return PhpDebugBar; \r\n});";
        }
        if ($targetFilename !== null) {
            file_put_contents($targetFilename, $content);
        } else {
            echo $content;
        }
    }
1229430
public function execute (array $params)
    {
        try {
            $this->_validateParameters($params);
            
            // モデル用ディレクトリの初期化
            $this->_initModelDirectory();

            // モデルクラスファイルを生成する
            $this->_generateModelClassFile();

            // ModelFactoryクラスを更新する
            $this->_updateModelFactory();

            $this->log('generated '.$this->model_name.'Model!', 'success');
        
        } catch (\Exception $e) {
            $this->errorLog($e->getMessage());
        }
    }
34414
public static function __callstatic($name, $params)
    {
        $matches = static::isFigletCall($name);

        if (null === $matches) {
            throw new Exception("Unknown figlet function name $name");
        }

        $fontName = $matches[2];

        // target string is expected to be:
        $targetString = $params[0][0];

        return static::render($targetString, $fontName);
    }
1235131
public function render($filename, array $params = array())
    {
        $this->properties = $params;

        $file = $this->scriptPath.DIRECTORY_SEPARATOR.$filename;
        if (!file_exists($file)) {
            $this->logger->error('Could not find template '.$file);

            return '';
        }
        ob_start();
        include $file;

        return ob_get_clean();
    }
1176611
public function prepareParms($params)
    {
        if (is_array($params)) {
            foreach ($params as $key => $value) {
                array_push($this->setParams, $value);
            }
        } else {
            array_push($this->setParams, $params);
        }
    }