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


PHP DataModel类代码示例

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


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


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