当前位置: 首页>>代码示例>>PHP>>正文


PHP App::response方法代码示例

本文整理汇总了PHP中App::response方法的典型用法代码示例。如果您正苦于以下问题:PHP App::response方法的具体用法?PHP App::response怎么用?PHP App::response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App的用法示例。


在下文中一共展示了App::response方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: error

 /**
  * Handler an error
  *
  * @param int    $no      The error number
  * @param string $str     The error message
  * @param string $file    The file that throwed the error
  * @param int    $line    The line in the file where the error was throwed
  * @param array  $context All the variables in the error context
  */
 public function error($no, $str, $file, $line, $context)
 {
     if (!(error_reporting() & $no)) {
         // This error code is not in error_reporting
         return;
     }
     switch ($no) {
         case E_NOTICE:
         case E_USER_NOTICE:
             $level = "info";
             $icon = 'info-circle';
             $title = "PHP Notice";
             App::logger()->notice($str);
             break;
         case E_STRICT:
             $level = "info";
             $icon = 'info-circle';
             $title = "PHP Strict";
             App::logger()->notice($str);
             break;
         case E_DEPRECATED:
         case E_USER_DEPRECATED:
             $level = "info";
             $icon = 'info-circle';
             $title = "PHP Deprecated";
             App::logger()->notice($str);
             break;
         case E_USER_WARNING:
         case E_WARNING:
             $level = "warning";
             $icon = "exclamation-triangle";
             $title = "PHP Warning";
             App::logger()->warning($str);
             break;
         default:
             $level = "danger";
             $icon = "exclamation-circle";
             $title = "PHP Error";
             App::logger()->error($str);
             break;
     }
     $param = array('level' => $level, 'icon' => $icon, 'title' => $title, 'message' => $str, 'trace' => array(array('file' => $file, 'line' => $line)));
     if (!App::response()->getContentType() === "json") {
         App::response()->setBody($param);
         throw new AppStopException();
     } else {
         echo View::make(Theme::getSelected()->getView('error.tpl'), $param);
     }
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:58,代码来源:ErrorHandler.php

示例2: run

 public function run()
 {
     $uploader = new Uploader();
     if (Yii::app()->request->isPostRequest) {
         //普通上传
         $uploader->initSimple('album')->uploadSimple('simple_file');
         $error = $uploader->getError();
         if (!$error) {
             $data = array('file_name' => $uploader->file_name, 'file_path' => $uploader->file_path, 'file_path_full' => Helper::getFullUrl($uploader->file_path), 'thumb_path' => $uploader->thumb_path, 'thumb_path_full' => Helper::getFullUrl($uploader->thumb_path), 'file_ext' => $uploader->file_ext);
             App::response(200, 'success', $data);
         } else {
             App::response(101, $error);
         }
     }
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:15,代码来源:UploadSimpleAction.php

示例3: redirectAction

 protected function redirectAction()
 {
     $shortURI = App::request()->getQueryVar('url');
     $shortURIId = App::alphaid()->toId($shortURI);
     /** @var $urlRecord UrlModel */
     $urlRecord = UrlModel::findOneByPk($shortURIId);
     if (false !== $urlRecord && !empty($urlRecord->longurl)) {
         // TODO cache
         // TODO statictics (hits/lastuse)
         App::response()->redirectAndExit($urlRecord->longurl, 301);
         // SEO friendly redirect
     } else {
         // redirect failed
         App::response()->sendNotFoundAndExit();
     }
 }
开发者ID:stefangruncharov,项目名称:url-shortening-service,代码行数:16,代码来源:RedirectorController.php

示例4: run

 public function run()
 {
     $uploader = new Uploader();
     if (Yii::app()->request->isPostRequest) {
         //开始剪切
         $image = $_POST['file'];
         $uploader->initSimple('avatar');
         $cut_image = $uploader->imageCut($image, array('cut_w' => 100, 'cut_h' => 100, 'pos_x' => $_POST['x'], 'pos_y' => $_POST['y']));
         $error = $uploader->getError();
         if (!$error) {
             $data = array('cut_avatar' => $cut_image);
             App::response(200, '裁剪成功', $data);
         } else {
             App::response(101, $error);
         }
     }
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:17,代码来源:AvatarCutAction.php

示例5: run

 public function run()
 {
     $uploader = new Uploader();
     if (Yii::app()->request->isPostRequest) {
         //断点上传
         $uploader->initResumable('album')->uploadResumable('file');
         $error = $uploader->getError();
         if (!$error) {
             $data = array('file_name' => $uploader->file_name, 'file_path' => $uploader->file_path, 'file_path_full' => Helper::getFullUrl($uploader->file_path), 'file_ext' => $uploader->file_ext);
             App::response(200, 'success', $data);
         } else {
             App::response(101, $error);
         }
     } else {
         //校验已上传的片段
         $uploader->checkExistChunks();
     }
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:18,代码来源:UploadResumableAction.php

示例6: parseRequestUrl

 public function parseRequestUrl($url)
 {
     // remove leading and trailing slashes
     $url = trim($url, '/');
     $rule = $this->getMatchedRule($url);
     if (!is_array($rule) || is_array($rule) && count($rule) < 2) {
         App::response()->sendNotFoundAndExit();
     }
     $rule[] = array();
     // sizeof($rule) must be not less than 3
     list($controller, $action, $parameters) = $rule;
     $controller = App::camelize($controller, true) . 'Controller';
     $action = App::camelize($action, false) . 'Action';
     // insert parsed parameters into query variables
     foreach ($parameters as $key => $value) {
         App::request()->addQueryVar($key, $value);
     }
     return array('controller' => $controller, 'action' => $action, 'parameters' => $parameters);
 }
开发者ID:stefangruncharov,项目名称:url-shortening-service,代码行数:19,代码来源:AppRouter.php

示例7: run

 public function run()
 {
     $this->init();
     if (empty($this->_actionMethod)) {
         trigger_error('Action not defined in class ' . get_class($this) . '::run()', E_USER_ERROR);
         App::response()->sendNotFoundAndExit();
     }
     if (!method_exists($this, $this->_actionMethod)) {
         trigger_error('Action method "' . $this->_actionMethod . '" not exit in class ' . get_class($this) . '::run()', E_USER_ERROR);
         App::response()->sendNotFoundAndExit();
     }
     $this->{$this->_actionMethod}();
     if ($this->_doRender) {
         // if action method called render()
         return $this->view->render();
         // return rendered content
     } else {
         return $this->view->getData();
         // return all variables
     }
 }
开发者ID:stefangruncharov,项目名称:url-shortening-service,代码行数:21,代码来源:AppController.php

示例8: updateHawk

 /**
  * Update Hawk
  */
 public function updateHawk()
 {
     try {
         $api = new HawkApi();
         $nextVersions = $api->getCoreAvailableUpdates();
         if (empty($nextVersions)) {
             throw new \Exception("No newer version is available for Hawk");
         }
         // Update incrementally all newer versions
         foreach ($nextVersions as $version) {
             // Download the update archive
             $archive = $api->getCoreUpdateArchive($version['version']);
             // Extract the downloaded file
             $zip = new \ZipArchive();
             if ($zip->open($archive) !== true) {
                 throw new \Exception('Impossible to open the zip archive');
             }
             $zip->extractTo(TMP_DIR);
             // Put all modified or added files in the right folder
             $folder = TMP_DIR . 'update-v' . $version['version'] . '/';
             App::fs()->copy($folder . 'to-update/*', ROOT_DIR);
             // Delete the files to delete
             $toDeleteFiles = explode(PHP_EOL, file_get_contents($folder . 'to-delete.txt'));
             foreach ($toDeleteFiles as $file) {
                 if (is_file(ROOT_DIR . $file)) {
                     unlink(ROOT_DIR . $file);
                 }
             }
             // Remove temporary files and folders
             App::fs()->remove($folder);
             App::fs()->remove($archive);
         }
         // Execute the update method if exist
         $updater = new HawkUpdater();
         $methods = get_class_methods($updater);
         foreach ($nextVersions as $version) {
             $method = 'v' . str_replace('.', '_', $version['version']);
             if (method_exists($updater, $method)) {
                 $updater->{$method}();
             }
         }
         App::cache()->clear('views');
         App::cache()->clear('lang');
         App::cache()->clear(Autoload::CACHE_FILE);
         App::cache()->clear(Lang::ORIGIN_CACHE_FILE);
         $response = array('status' => true);
     } catch (\Exception $e) {
         $response = array('status' => false, 'message' => DEBUG_MODE ? $e->getMessage() : Lang::get('admin.update-hawk-error'));
     }
     App::response()->setContentType('json');
     return $response;
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:55,代码来源:AdminController.php

示例9: function

    /*** Execute action just after routing ***/
    Event::on('after-routing', function ($event) {
        $route = $event->getData('route');
        if (!App::conf()->has('db') && App::request()->getUri() == App::router()->getUri('index')) {
            // The application is not installed yet
            App::logger()->notice('Hawk is not installed yet, redirect to install process page');
            App::response()->redirectToAction('install');
            return;
        }
    });
    /*** Compute the routage ***/
    App::router()->route();
} catch (HTTPException $err) {
    App::response()->setStatus($err->getStatusCode());
    $response = array('message' => $err->getMessage(), 'details' => $err->getDetails());
    if (App::request()->getWantedType() === 'json') {
        App::response()->setContentType('json');
        App::response()->setBody($response);
    } else {
        App::response()->setBody($response['message']);
    }
} catch (AppStopException $e) {
}
// Finish the script
App::logger()->debug('end of script');
$event = new Event('process-end', array('output' => App::response()->getBody(), 'execTime' => microtime(true) - SCRIPT_START_TIME));
$event->trigger();
App::response()->setBody($event->getData('output'));
/*** Return the response to the client ***/
App::response()->end();
开发者ID:elvyrra,项目名称:hawk,代码行数:30,代码来源:index.php

示例10: download

 /**
  * Download a remote theme
  */
 public function download()
 {
     App::response()->setContentType('json');
     try {
         $api = new HawkApi();
         $file = $api->downloadTheme($this->theme);
         $zip = new \ZipArchive();
         if ($zip->open($file) !== true) {
             throw new \Exception('Impossible to open the zip archive');
         }
         $zip->extractTo(THEMES_DIR);
         $theme = Theme::get($this->theme);
         if (!$theme) {
             throw new \Exception('An error occured while downloading the theme');
         }
         unlink($file);
         return $theme;
     } catch (\Exception $e) {
         App::response()->setStatus(500);
         return array('message' => $e->getMessage());
     }
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:25,代码来源:ThemeController.php

示例11: _s

<?php

App::response()->setStatusCode(404);
?>
<div class="content box padding">
    <h1><?php 
echo _s('Page does not exist');
?>
</h1>
    <p><?php 
echo _s('Sorry, but the page you were trying to view does not exist');
?>
</p>
</div>
开发者ID:professor93,项目名称:mobicms,代码行数:14,代码来源:index.php

示例12: __call

 /**
  * Call a method of the controller
  *
  * @param string $method    The method to call
  * @param array  $arguments The arguments of the method call
  *
  * @return mixed The result of the method call
  */
 public function __call($method, $arguments)
 {
     $this->controller->executingMethod = $method;
     /*** Load widgets before calling the controller method ***/
     $class = $this->controller->getClassname();
     $eventBasename = $this->controller->_plugin . '.' . $class . '.' . $method . '.';
     $event = new Event($eventBasename . Controller::BEFORE_ACTION, array('controller' => $this->controller));
     $event->trigger();
     /*** Call the controller method ***/
     $result = call_user_func_array(array($this->controller, $method), $arguments);
     if (App::response()->getContentType() == 'html' && is_string($result)) {
         // Create a phpQuery object to be modified by event listeners (widgets)
         $result = \phpQuery::newDocument($result);
     }
     /*** Load the widgets after calling the controller method ***/
     $event = new Event($eventBasename . Controller::AFTER_ACTION, array('controller' => $this->controller, 'result' => $result));
     $event->trigger();
     // Return the result of the action
     $result = $event->getData('result');
     if ($result instanceof \phpQuery || $result instanceof \phpQueryObject) {
         return $result->htmlOuter();
     } else {
         return $result;
     }
     $this->controller->executingMethod = null;
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:34,代码来源:Controller.php

示例13: returnJson

 /**
  * 向浏览器返回json数据
  *
  * @param array $notice
  */
 public function returnJson($notice)
 {
     $this->app->response()->setJson($notice);
     exit;
 }
开发者ID:chaoyanjie,项目名称:MonkeyPHP,代码行数:10,代码来源:Controller.php

示例14: onFatalError

 public static function onFatalError()
 {
     $error = error_get_last();
     if (E_ERROR == $error['type']) {
         // PHP Fatal Error
         $msg = 'FATAL ERROR : ' . date("Y-m-d H:i:s (T)") . " \"{$error['message']}\" in file {$error['file']} at line {$error['line']}";
         echo include_once static::basePath() . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'error' . DIRECTORY_SEPARATOR . '500.phtml';
         echo $msg;
         App::response()->sendContent();
     }
 }
开发者ID:stefangruncharov,项目名称:url-shortening-service,代码行数:11,代码来源:App.php

示例15: init

 /**
  * setup the things that every app has
  *
  * it is up to the mainLoop() of the different types of app
  * to setup the rest (user, page, and theme)
  */
 public static function init()
 {
     self::$browsers = new Browser_Manager();
     self::$users = new User_Manager();
     self::$routes = new Routing_Manager();
     self::$pages = new Page_Manager();
     self::$themes = new Theme_Manager();
     self::$debug = new Debug_Manager();
     // disable debugging if we are unit testing
     if (defined('UNIT_TEST') && UNIT_TEST) {
         self::$debug->setEnabled(false);
     }
     // with the general environment loaded, we can now load
     // the modules that are app-specific
     self::$request = new App_Request();
     self::$response = new App_Response();
     self::$conditions = new App_Conditions();
 }
开发者ID:stuartherbert,项目名称:mf,代码行数:24,代码来源:App.classes.php


注:本文中的App::response方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。