本文整理汇总了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;
}
示例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;
}