• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP DataModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: preFetchData

 protected function preFetchData(DataModel $controller, &$response)
 {
     $maxPerPage = $this->getOptionalModuleVar('MAX_RESULTS', 10);
     $controller->setStart(0);
     $controller->setLimit($maxPerPage);
     return parent::preFetchData($controller, $response);
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:7,代码来源:VideoShellModule.php


示例2: preFetchData

 protected function preFetchData(DataModel $controller, &$response)
 {
     $retriever = $controller->getRetriever();
     $posts = $retriever->getPosts();
     $response = $retriever->getLastResponse();
     foreach ($posts as $key => $post) {
         if (is_object($post) && ($author = $post->getAuthor()) && !in_array($author, $this->authors)) {
             $this->authors[] = $author;
             $controller->getUser($author);
         }
     }
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:12,代码来源:SocialShellModule.php


示例3: run

 public function run()
 {
     $parameterId = 2;
     $dataModel = new DataModel();
     $userModel = new UserModel();
     Session::init();
     $userId = Session::get('user')['user_id'];
     $userData = $dataModel->getData($userId, $parameterId);
     $users = $userModel->run();
     $var = ['userData' => $userData, 'users' => $users];
     //            Session::init();
     //            print_r($_SESSION);
     $this->view->render('dashboard.twig', $var);
 }
开发者ID:uxcoder,项目名称:runtime,代码行数:14,代码来源:DashboardController.php


示例4: 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


示例5: 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


示例6: load

 /**
  *
  */
 public static function load()
 {
     if (!DataModel::$s_datamodel_instance_cache) {
         DataModel::$s_datamodel_instance_cache = new Datamodel();
     }
     return DataModel::$s_datamodel_instance_cache;
 }
开发者ID:ffarago,项目名称:pawtucket2,代码行数:10,代码来源:Datamodel.php


示例7: 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


示例8: 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


示例9: 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


示例10: getFeed

 protected function getFeed($feed = null)
 {
     $feed = isset($this->feeds[$feed]) ? $feed : $this->getDefaultSection();
     $feedData = $this->feeds[$feed];
     $modelClass = isset($feedData['MODEL_CLASS']) ? $feedData['MODEL_CLASS'] : self::$defaultModel;
     $controller = DataModel::factory($modelClass, $feedData);
     return $controller;
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:8,代码来源:PhotosShellModule.php


示例11: 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


示例12: handleRequest

 private function handleRequest()
 {
     $result['message'] = '';
     //            $job = isset($this->submit['action']) ? $this->submit['action'] : '';
     $job = $this->request->get('action');
     switch ($job) {
         case 'save':
             $parameterId = 2;
             $dataModel = new DataModel();
             $userId = Session::get('user')['user_id'];
             $dataModel->saveData($userId, $parameterId, $this->request->get('heart_rate'));
             //                $dataModel->saveData(1, $this->submit['req']['heart_rate']);
             $result['message'] = 'Your data has been saved.';
             break;
         default:
     }
     return $result;
 }
开发者ID:uxcoder,项目名称:runtime,代码行数:18,代码来源:AdminController.php


示例13: 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


示例14: 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


示例15: initializeForCommand

 public function initializeForCommand()
 {
     switch ($this->command) {
         case 'notice':
             $response = null;
             $responseVersion = 1;
             if ($this->getOptionalModuleVar('BANNER_ALERT', false, 'notice')) {
                 $noticeData = $this->getOptionalModuleSection('notice');
                 if ($noticeData) {
                     $response = array('notice' => '', 'moduleID' => null, 'link' => $this->getOptionalModuleVar('BANNER_ALERT_MODULE_LINK', false, 'notice'));
                     // notice can either take a module or data model class or retriever class. The section is passed on. It must implement the HomeAlertInterface interface
                     if (isset($noticeData['BANNER_ALERT_MODULE'])) {
                         $moduleID = $noticeData['BANNER_ALERT_MODULE'];
                         $controller = WebModule::factory($moduleID);
                         $response['moduleID'] = $moduleID;
                         $string = "Module {$moduleID}";
                     } elseif (isset($noticeData['BANNER_ALERT_MODEL_CLASS'])) {
                         $controller = DataModel::factory($noticeData['BANNER_ALERT_MODEL_CLASS'], $noticeData);
                         $string = $noticeData['BANNER_ALERT_MODEL_CLASS'];
                     } elseif (isset($noticeData['BANNER_ALERT_RETRIEVER_CLASS'])) {
                         $controller = DataRetriever::factory($noticeData['BANNER_ALERT_RETRIEVER_CLASS'], $noticeData);
                         $string = $noticeData['BANNER_ALERT_RETRIEVER_CLASS'];
                     } else {
                         throw new KurogoConfigurationException("Banner alert not properly configured");
                     }
                     if (!$controller instanceof HomeAlertInterface) {
                         throw new KurogoConfigurationException("{$string} does not implement HomeAlertModule interface");
                     }
                     $response['notice'] = $controller->getHomeScreenAlert();
                 }
             }
             $this->setResponse($response);
             $this->setResponseVersion($responseVersion);
             break;
         case 'modules':
             if ($setcontext = $this->getArg('setcontext')) {
                 Kurogo::sharedInstance()->setUserContext($setcontext);
             }
             $responseVersion = 2;
             $response = array('primary' => array(), 'secondary' => array(), 'customize' => $this->getOptionalModuleVar('ALLOW_CUSTOMIZE', true), 'displayType' => $this->getOptionalModuleVar('display_type', 'springboard'));
             $allmodules = $this->getAllModules();
             $navModules = Kurogo::getSiteSections('navigation', Config::APPLY_CONTEXTS_NAVIGATION);
             foreach ($navModules as $moduleID => $moduleData) {
                 if ($module = Kurogo::arrayVal($allmodules, $moduleID)) {
                     $title = Kurogo::arrayVal($moduleData, 'title', $module->getModuleVar('title'));
                     $type = Kurogo::arrayVal($moduleData, 'type', 'primary');
                     $visible = Kurogo::arrayVal($moduleData, 'visible', 1);
                     $response[$type][] = array('tag' => $moduleID, 'title' => $title, 'visible' => (bool) $visible);
                 }
             }
             $this->setResponse($response);
             $this->setResponseVersion($responseVersion);
             break;
         default:
             $this->invalidCommand();
     }
 }
开发者ID:sponto,项目名称:msbm-mobile,代码行数:57,代码来源:HomeAPIModule.php


示例16: 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


示例17: 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


示例18: getFeed

 protected function getFeed($feed)
 {
     if (!isset($this->feeds[$feed])) {
         throw new KurogoException(get_class($this) . ": Invalid Album id: {$feed}");
         return false;
     }
     $feedData = $this->feeds[$feed];
     $modelClass = isset($feedData['MODEL_CLASS']) ? $feedData['MODEL_CLASS'] : 'PhotosDataModel';
     $controller = DataModel::factory($modelClass, $feedData);
     return $controller;
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:11,代码来源:PhotosAPIModule.php


示例19: getFeed

 protected function getFeed($feed = null)
 {
     $feed = isset($this->feeds[$feed]) ? $feed : $this->getDefaultSection();
     $feedData = $this->feeds[$feed];
     $modelClass = isset($feedData['MODEL_CLASS']) ? $feedData['MODEL_CLASS'] : self::$defaultModel;
     $controller = DataModel::factory($modelClass, $feedData);
     $maxResultsOption = $this->pagetype == 'tablet' ? 'MAX_TABLET_RESULTS' : 'MAX_RESULTS';
     $maxPerPage = $this->getOptionalModuleVar($maxResultsOption, 20);
     $controller->setLimit($maxPerPage);
     return $controller;
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:11,代码来源:PhotosWebModule.php


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP DataObject类代码示例发布时间:2022-05-23
下一篇:
PHP DataMapper类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap