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


PHP ModelAsController::create方法代码示例

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


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

示例1: handleRequest

 public function handleRequest(SS_HTTPRequest $request, DataModel $model)
 {
     $this->pushCurrent();
     $this->urlParams = $request->allParams();
     $this->request = $request;
     $this->response = new SS_HTTPResponse();
     $this->setDataModel($model);
     $urlsegment = $request->param('URLSegment');
     $this->extend('onBeforeInit');
     $this->init();
     $this->extend('onAfterInit');
     // First check products against URL segment
     if ($product = Product::get()->filter(array('URLSegment' => $urlsegment, 'Disabled' => 0))->first()) {
         $controller = Catalogue_Controller::create($product);
     } elseif ($category = ProductCategory::get()->filter('URLSegment', $urlsegment)->first()) {
         $controller = Catalogue_Controller::create($category);
     } else {
         // If CMS is installed
         if (class_exists('ModelAsController')) {
             $controller = ModelAsController::create();
         }
     }
     $result = $controller->handleRequest($request, $model);
     $this->popCurrent();
     return $result;
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:26,代码来源:CommerceURLController.php

示例2: handleRequest

 /**
  * Check catalogue URL's before we get to the CMS (if it exists)
  * 
  * @param SS_HTTPRequest $request
  * @param DataModel|null $model
  * @return SS_HTTPResponse
  */
 public function handleRequest(SS_HTTPRequest $request, DataModel $model)
 {
     $this->request = $request;
     $this->setDataModel($model);
     $this->pushCurrent();
     // Create a response just in case init() decides to redirect
     $this->response = new SS_HTTPResponse();
     $this->init();
     // If we had a redirection or something, halt processing.
     if ($this->response->isFinished()) {
         $this->popCurrent();
         return $this->response;
     }
     // If DB is not present, build
     if (!DB::isActive() || !ClassInfo::hasTable('CatalogueProduct') || !ClassInfo::hasTable('CatalogueCategory')) {
         return $this->response->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
     }
     $urlsegment = $request->param('URLSegment');
     $this->extend('onBeforeInit');
     $this->init();
     $this->extend('onAfterInit');
     // Find link, regardless of current locale settings
     if (class_exists('Translatable')) {
         Translatable::disable_locale_filter();
     }
     $filter = array('URLSegment' => $urlsegment, 'Disabled' => 0);
     if ($object = CatalogueProduct::get()->filter($filter)->first()) {
         $controller = $this->controller_for($object);
     } elseif ($object = CatalogueCategory::get()->filter($filter)->first()) {
         $controller = $this->controller_for($object);
     } elseif (class_exists('ModelAsController')) {
         // If CMS installed
         $controller = ModelAsController::create();
     } else {
         $controller = Controller::create();
     }
     if (class_exists('Translatable')) {
         Translatable::enable_locale_filter();
     }
     $result = $controller->handleRequest($request, $model);
     $this->popCurrent();
     return $result;
 }
开发者ID:alialamshahi,项目名称:silverstripe-catalogue-prowall,代码行数:50,代码来源:CatalogueURLController.php


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