當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DataModel::inst方法代碼示例

本文整理匯總了PHP中DataModel::inst方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataModel::inst方法的具體用法?PHP DataModel::inst怎麽用?PHP DataModel::inst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DataModel的用法示例。


在下文中一共展示了DataModel::inst方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handleItem

 public function handleItem($gridField, $request)
 {
     $controller = $gridField->getForm()->Controller();
     $record = $gridField->getList()->byId($request->param("ID"));
     $handler = Object::create('GridFieldExpandableForm_ItemRequest', $gridField, $this, $record, $controller, 'DetailForm', $this->formorfields);
     return $handler->handleRequest($request, DataModel::inst());
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-gridfield-addons,代碼行數:7,代碼來源:GridFieldExpandableForm.php

示例2: form_appears_and_saves

 /**
  * @test
  */
 public function form_appears_and_saves()
 {
     Config::inst()->update('Controller', 'extensions', array('QuickFeedbackExtension'));
     $controller = new TestController();
     $result = $controller->handleRequest(new SS_HTTPRequest('GET', 'form_appears_and_saves'), DataModel::inst());
     $body = $result->getBody();
     $this->assertContains('Form_QuickFeedbackForm', $body);
     $this->assertContains('Form_QuickFeedbackForm_Rating', $body);
     $this->assertContains('Form_QuickFeedbackForm_Comment', $body);
     preg_match('/action="([^"]+)"/', $body, $action);
     if (!count($action)) {
         $this->fail('No form action');
     }
     preg_match('/name="SecurityID" value="([^"]+)"/', $body, $token);
     if (!count($action)) {
         $this->fail('No token');
     }
     $parts = explode('/', $action[1]);
     $action = end($parts);
     $time = time();
     $data = ['SecurityID' => $token[1], 'Rating' => '0', 'Comment' => 'comment at ' . $time];
     $controller->handleRequest(new SS_HTTPRequest('POST', $action, array(), $data), DataModel::inst());
     $existing = Feedback::get()->filter('Comment', 'comment at ' . $time)->first();
     if (!$existing) {
         $this->fail('Record missing');
     }
 }
開發者ID:helpfulrobot,項目名稱:mandrew-silverstripe-quickfeedback,代碼行數:30,代碼來源:QuickFeedbackExtensionTest.php

示例3: fireSilverstripeCommand

 protected function fireSilverstripeCommand($url)
 {
     $this->bootSilverstripe($url);
     $_SERVER['REQUEST_URI'] = BASE_URL . '/' . $url;
     // Direct away - this is the "main" function, that hands control to the appropriate controller
     \Director::direct($url, \DataModel::inst());
 }
開發者ID:helpfulrobot,項目名稱:themonkeys-laravel-silverstripe,代碼行數:7,代碼來源:SilverstripeCommand.php

示例4: addfield

 public function addfield($gridField, $request)
 {
     $controller = $gridField->getForm()->Controller();
     $record = singleton('MetadataField');
     $handler = Object::create('MetaDataFieldAddForm_ItemRequest', $gridField, $this, $record, $controller, $this->name);
     $handler->setTemplate($this->template);
     return $handler->handleRequest($request, DataModel::inst());
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-australia-metadata,代碼行數:8,代碼來源:MetaDataFieldAddForm.php

示例5: handleManagePresentation

 public function handleManagePresentation(SS_HTTPRequest $r)
 {
     if ($presentation = Presentation::get()->byID($r->param('ID'))) {
         $request = PresentationAPI_PresentationRequest::create($presentation, $this);
         return $request->handleRequest($r, DataModel::inst());
     }
     return $this->httpError(404, "Presentation " . $r->param('ID') . " not found");
 }
開發者ID:OpenStackweb,項目名稱:openstack-org,代碼行數:8,代碼來源:PresentationAPI.php

示例6: testRedirectingMapping

 /**
  * Tests to make sure short codes get translated to full paths.
  *
  */
 public function testRedirectingMapping()
 {
     DocumentationPermalinks::add(array('foo' => 'en/framework/subfolder/foo', 'bar' => 'en/cms/bar'));
     $this->autoFollowRedirection = false;
     $v = new DocumentationViewer();
     $response = $v->handleRequest(new SS_HTTPRequest('GET', 'foo'), DataModel::inst());
     $this->assertEquals('301', $response->getStatusCode());
     $this->assertContains('en/framework/subfolder/foo', $response->getHeader('Location'));
 }
開發者ID:Jellygnite,項目名稱:silverstripe-docsviewer,代碼行數:13,代碼來源:DocumentationPermalinksTest.php

示例7: testUnserializeWithExtraData

 /**
  * @depends testSerializeWithExtraData
  * @covers \Heystack\Core\State\Traits\DataObjectSerializableTrait::unserialize
  */
 public function testUnserializeWithExtraData($data)
 {
     $t = $this->getMockForAbstractClass(__NAMESPACE__ . '\\TestDataObjectSerializableTraitWithExtraData');
     $t->expects($this->once())->method('setExtraData')->with(['test' => true]);
     $t->unserialize($data);
     $this->assertAttributeEquals(get_class($t), 'class', $t);
     $this->assertAttributeEquals(['test' => true], 'record', $t);
     $this->assertAttributeEquals(\DataModel::inst(), 'model', $t);
 }
開發者ID:helpfulrobot,項目名稱:heystack-heystack,代碼行數:13,代碼來源:DataObjectSerializableTraitTest.php

示例8: testProcessDoesProduceExpectedOutput

 /**
  * @covers \Heystack\Ecommerce\Controller\InputController::__construct
  */
 public function testProcessDoesProduceExpectedOutput()
 {
     $controller = new InputController($inputMock = $this->getMock('Heystack\\Core\\Input\\Handler'), $outptuMock = $this->getMock('Heystack\\Core\\Output\\Handler'));
     $request = new \SS_HTTPRequest('GET', '/input/process/test/');
     $inputMock->expects($this->once())->method('process')->with('test', $request)->will($this->returnValue(['success' => true]));
     $outptuMock->expects($this->once())->method('process')->with('test', $controller, ['success' => true])->will($this->returnValue('yay'));
     $response = $controller->handleRequest($request, \DataModel::inst());
     $this->assertEquals('yay', $response->getBody());
 }
開發者ID:helpfulrobot,項目名稱:heystack-ecommerce-core,代碼行數:12,代碼來源:InputControllerTest.php

示例9: process

 /**
  * @return string
  */
 public function process()
 {
     if ($this->siteUrl) {
         ob_start();
         Director::direct($this->url, \DataModel::inst());
         return ob_get_clean();
     } else {
         return @file_get_contents($this->url);
     }
 }
開發者ID:helpfulrobot,項目名稱:heyday-silverstripe-wkhtml,代碼行數:13,代碼來源:Url.php

示例10: onBeforeHTTPError

 /**
  *	Retrieve the correct error page for the current multisite instance.
  *	@param integer
  *	@param SS_HTTPRequest
  *	@throws SS_HTTPResponse_Exception
  */
 public function onBeforeHTTPError($code, $request)
 {
     $errorPage = ErrorPage::get()->filter(array('ErrorCode' => $code, 'SiteID' => Multisites::inst()->getCurrentSiteId()))->first();
     if ($errorPage) {
         Requirements::clear();
         Requirements::clear_combined_files();
         $response = ModelAsController::controller_for($errorPage)->handleRequest($request, DataModel::inst());
         throw new SS_HTTPResponse_Exception($response, $code);
     }
 }
開發者ID:helpfulrobot,項目名稱:sheadawson-silverstripe-multisites,代碼行數:16,代碼來源:MultisitesControllerExtension.php

示例11: testTemplateFunctionsForOtherSteps

 public function testTemplateFunctionsForOtherSteps()
 {
     $summaryRequest = new SS_HTTPRequest('GET', "summary");
     $this->checkout = new CheckoutPage_Controller();
     $this->checkout->handleRequest($summaryRequest, DataModel::inst());
     //change to summary step
     $this->assertTrue($this->checkout->StepExists('summary'));
     $this->assertFalse($this->checkout->IsPastStep('summary'));
     $this->assertTrue($this->checkout->IsCurrentStep('summary'));
     $this->assertFalse($this->checkout->IsFutureStep('summary'));
     $this->assertFalse($this->checkout->StepExists('nosuchstep'));
 }
開發者ID:NobrainerWeb,項目名稱:silverstripe-shop,代碼行數:12,代碼來源:SteppedCheckoutTest.php

示例12: process

 /**
  * @return string
  * @throws \RuntimeException
  */
 public function process()
 {
     $result = $this->getHandleMethod()->invoke(null, $this->request, $this->session, \DataModel::inst());
     if ($result instanceof SS_HTTPResponse) {
         ob_start();
         $result->output();
         return ob_get_clean();
     } elseif (is_string($result)) {
         return $result;
     } else {
         throw new \RuntimeException('Can\'t handle output from request');
     }
 }
開發者ID:helpfulrobot,項目名稱:heyday-silverstripe-wkhtml,代碼行數:17,代碼來源:Request.php

示例13: handleItem

 /**
  *
  * @param type $gridField
  * @param type $request
  * @return GridFieldDetailForm_ItemRequest 
  */
 public function handleItem($gridField, $request)
 {
     $controller = $gridField->getForm()->Controller();
     if (is_numeric($request->param('ID'))) {
         $record = $gridField->getList()->byId($request->param("ID"));
     } else {
         $record = Object::create($gridField->getModelClass());
     }
     $class = $this->getItemRequestClass();
     $handler = Object::create($class, $gridField, $this, $record, $controller, $this->name);
     $handler->setTemplate($this->template);
     return $handler->handleRequest($request, DataModel::inst());
 }
開發者ID:prostart,項目名稱:cobblestonepath,代碼行數:19,代碼來源:GridFieldDetailForm.php

示例14: handleItem

 public function handleItem($gridField, $request)
 {
     $controller = $gridField->getForm()->Controller();
     // we can't check on is_numeric, since some datasources use strings as identifiers
     if ($request->param('ID') && $request->param('ID') != 'new') {
         $record = $gridField->getList()->byId($request->param("ID"));
     } else {
         $record = Object::create($gridField->getModelClass());
     }
     $class = $this->getItemRequestClass();
     $handler = Object::create($class, $gridField, $this, $record, $controller, $this->name);
     $handler->setTemplate($this->template);
     return $handler->handleRequest($request, DataModel::inst());
 }
開發者ID:helpfulrobot,項目名稱:axyr-silverstripe-externaldata,代碼行數:14,代碼來源:ExternalDataGridFieldDetailForm.php

示例15: response_for

 /**
  * Get a {@link SS_HTTPResponse} to response to a HTTP error code if an {@link ErrorPage} for that code is present.
  *
  * @param int $statusCode
  * @return SS_HTTPResponse
  */
 public static function response_for($statusCode)
 {
     // first attempt to dynamically generate the error page
     if ($errorPage = DataObject::get_one('ErrorPage', "\"ErrorCode\" = {$statusCode}")) {
         return ModelAsController::controller_for($errorPage)->handleRequest(new SS_HTTPRequest('GET', ''), DataModel::inst());
     }
     // then fall back on a cached version
     $cachedPath = self::get_filepath_for_errorcode($statusCode, class_exists('Translatable') ? Translatable::get_current_locale() : null);
     if (file_exists($cachedPath)) {
         $response = new SS_HTTPResponse();
         $response->setStatusCode($statusCode);
         $response->setBody(file_get_contents($cachedPath));
         return $response;
     }
 }
開發者ID:prostart,項目名稱:cobblestonepath,代碼行數:21,代碼來源:ErrorPage.php


注:本文中的DataModel::inst方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。