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


PHP Dir::emptyDir方法代码示例

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


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

示例1: execute

 public function execute()
 {
     if (Settings::get(Settings::DEBUG, false)) {
         if (isset($_GET['__clearcache'])) {
             //Clear cache
             Dir::emptyDir(CACHEDIR, true);
         }
         if (isset($_GET['__clearview'])) {
             //Clear cache
             Dir::emptyDir(Dir::concat(CACHEDIR, 'view'), true);
         }
         if (isset($_GET['__clearjs'])) {
             //Clear cache
             Dir::emptyDir(Dir::concat(CACHEDIR, 'js'), true);
         }
         if (isset($_GET['__clearcss'])) {
             //Clear cache
             Dir::emptyDir(Dir::concat(CACHEDIR, 'css'), true);
         }
     }
     try {
         if (!String::isAlphaNum($this->controller)) {
             header("HTTP/1.0 404 Invalid url");
             throw new HttpNotFoundException(T('Invalid controller: %s', $this->controller));
         }
         if (!String::isAlphaNum($this->action)) {
             header("HTTP/1.1 404 Invalid url");
             throw new HttpNotFoundException(T('Invalid action: %s', $this->action));
         }
         $ctrlClass = ucfirst($this->controller) . 'Controller';
         $appViewFile = 'application';
         $viewFile = $this->getViewFile();
         if (!class_exists($ctrlClass)) {
             $ctrlFile = Dir::normalize(BASEDIR) . 'controller/' . $ctrlClass . '.php';
             if (!File::exists($ctrlFile)) {
                 header("HTTP/1.1 404 Controller not found");
                 throw new HttpNotFoundException(T('Controller not found: %s', $ctrlFile));
             }
             require_once $ctrlFile;
         }
         if (!class_exists($ctrlClass)) {
             header("HTTP/1.1 404 Controller not Found");
             throw new HttpNotFoundException(T('Controller not found: %s', $ctrlClass));
         }
         $ctrl = new $ctrlClass();
         $this->controllerInstance = $ctrl;
         if (!method_exists($ctrl, $this->action)) {
             header("HTTP/1.1 404 Action not Found");
             throw new HttpNotFoundException(T('Action not found: %s::%s', $ctrlClass, $this->action));
         }
         $action = $this->action;
         if (!$ctrl->getSkipView()) {
             try {
                 $view = new View($viewFile);
             } catch (Exception $e) {
                 //Ignore for now
             }
         }
         try {
             $data = $ctrl->{$action}();
         } catch (ValidationException $e) {
             //Do nothing...
         } catch (Interrupt $e) {
             //Do nothing...
         } catch (ErrorException $e) {
             MessageHandler::instance()->addError($e->getMessage());
         }
         if (!$data) {
             $data = $ctrl->getData();
         }
         if (!$ctrl->getSkipView()) {
             if ($view) {
                 $this->body = $view->render($data);
             } else {
                 if (!Request::isAjax()) {
                     header("HTTP/1.1 500 View not Found");
                     throw new Exception(T('View not found: %s', $viewFile));
                 }
             }
         }
     } catch (HttpNotFoundException $e) {
         trigger_error(sprintf("Path not found %s", self::getPath()), E_USER_ERROR);
         if (!Request::isAjax()) {
             Url::redirect('error', 'notfound');
         }
         Pimple::end();
     } catch (Exception $e) {
         header("HTTP/1.1 500 Internal error");
         if (Request::isAjax()) {
             $this->body = json_encode(array('msg' => $e->getMessage(), 'trace' => $e->getTraceAsString()));
         } else {
             if (Settings::get(Settings::DEBUG, false)) {
                 $body = $e->__toString();
                 if (!stristr($body, '<')) {
                     $body = '<pre>' . $body . '</pre>';
                 }
                 $this->body = $body;
             } else {
                 trigger_error(sprintf("Unexpected exception thrown in %s:\n\t%s", self::getPath(), $e->__toString()), E_USER_ERROR);
                 Url::redirect('error', 'internal');
//.........这里部分代码省略.........
开发者ID:hofmeister,项目名称:Pimple,代码行数:101,代码来源:Pimple.php


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