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


PHP Resource类代码示例

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


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

示例1: clearUserRating

 function clearUserRating()
 {
     global $user;
     $source = $_REQUEST['source'];
     $recordId = $_REQUEST['recordId'];
     $result = array('result' => false);
     if ($source == 'VuFind') {
         require_once ROOT_DIR . '/Drivers/marmot_inc/UserRating.php';
         $resource = new Resource();
         $resource->record_id = $recordId;
         $resource->source = 'VuFind';
         if ($resource->find(true)) {
             $rating = new UserRating();
             $rating->userid = $user->id;
             $rating->resourceid = $resource->id;
             if ($rating->find(true)) {
                 if ($rating->delete()) {
                     $result = array('result' => true, 'message' => 'deleted user rating for resource ' . $rating->resourceid);
                 }
             }
         }
     } else {
         require_once ROOT_DIR . '/sys/eContent/EContentRating.php';
         $econtentRating = new EContentRating();
         $econtentRating->userId = $user->id;
         $econtentRating->recordId = $recordId;
         if ($econtentRating->find(true)) {
             if ($econtentRating->delete()) {
                 $result = array('result' => true);
             }
         }
     }
     return json_encode($result);
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:34,代码来源:AJAX.php

示例2: addResource

 public function addResource($route, Resource $resource)
 {
     $resource->setRoute($route);
     $resource->setPrefix($this);
     $this->resources[$route] = $resource;
     return $resource;
 }
开发者ID:m4nolo,项目名称:slim-restful,代码行数:7,代码来源:Prefix.php

示例3: testResetSearchResult

 public function testResetSearchResult()
 {
     $this->resource->expects($this->once())->method('getTableName')->with('search_query', ResourceConnection::DEFAULT_CONNECTION)->willReturn('table_name_search_query');
     $this->connection->expects($this->once())->method('update')->with('table_name_search_query', ['is_processed' => 0], ['is_processed != 0'])->willReturn(10);
     $result = $this->target->resetSearchResults();
     $this->assertEquals($this->target, $result);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:7,代码来源:FulltextTest.php

示例4: addResource

 private function addResource($type, $file_names, $single = false)
 {
     if ($single) {
         if (count($file_names) > 1) {
             $file_names = array($file_names[0]);
         }
         $Resource = new Resource();
         $type == 'file' ? $Resource->setFile($file_names[0]) : $Resource->setString($file_names[0]);
         /*$Resource->setDriver($this->driver);*/
         $this->resources[] = $Resource;
         $Resource->collection = $this;
         return $Resource;
     } else {
         $class = __CLASS__;
         $Collection = new $class();
         $Collection->collection = $this;
         $this->resources[] = $Collection;
         foreach ($file_names as $data) {
             if (is_string($data)) {
                 $type == 'file' ? $Collection->addSingleFile($data) : $Collection->addSingleString($data);
             } else {
                 $type == 'file' ? $Collection->addFile($data) : $Collection->addString($data);
             }
         }
         return $Collection;
     }
 }
开发者ID:Buran,项目名称:ResourceManager,代码行数:27,代码来源:ResourceCollection.php

示例5: launch

 function launch()
 {
     global $interface;
     global $configArray;
     $rating = $_REQUEST['rating'];
     $interface->assign('rating', $rating);
     $id = $_REQUEST['id'];
     // Check if user is logged in
     if (!$this->user) {
         // Needed for "back to record" link in view-alt.tpl:
         $interface->assign('id', $id);
         //Display the login form
         $login = $interface->fetch('Record/ajax-rate-login.tpl');
         header('Content-type: text/plain');
         header('Cache-Control: no-cache, must-revalidate');
         // HTTP/1.1
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         echo json_encode(array('result' => 'true', 'loginForm' => $login));
         exit;
     }
     if (isset($_GET['submit'])) {
         global $user;
         //Save the rating
         $resource = new Resource();
         $resource->record_id = $id;
         $resource->source = 'VuFind';
         if (!$resource->find(true)) {
             $resource->insert();
         }
         $resource->addRating($rating, $user);
         return json_encode(array('result' => 'true', 'rating' => $rating));
     }
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:33,代码来源:Rate.php

示例6: __construct

 function __construct($relType, Resource $resource)
 {
     $this->setRelType($relType);
     $this->setName($resource->getName());
     $this->setCollectionName($resource->getCollectionName());
     $this->setHref($resource->getHref());
 }
开发者ID:rstgroup,项目名称:json-api-php,代码行数:7,代码来源:Relation.php

示例7: launch

 public function launch()
 {
     global $interface;
     global $user;
     //Load user ratings
     require_once ROOT_DIR . '/Drivers/marmot_inc/UserRating.php';
     $rating = new UserRating();
     $resource = new Resource();
     $rating->joinAdd($resource);
     $rating->userid = $user->id;
     $rating->find();
     $ratings = array();
     while ($rating->fetch()) {
         if ($rating->deleted == 0) {
             $ratings[] = array('id' => $rating->id, 'title' => $rating->title, 'author' => $rating->author, 'format' => $rating->format, 'rating' => $rating->rating, 'resourceId' => $rating->resourceid, 'fullId' => $rating->record_id, 'shortId' => $rating->shortId, 'link' => '/Record/' . $rating->record_id . '/Home', 'dateRated' => $rating->dateRated, 'ratingData' => array('user' => $rating->rating), 'source' => 'VuFind');
         }
     }
     //Load econtent ratings
     require_once ROOT_DIR . '/sys/eContent/EContentRating.php';
     $eContentRating = new EContentRating();
     $econtentRecord = new EContentRecord();
     $eContentRating->joinAdd($econtentRecord);
     $eContentRating->userId = $user->id;
     $eContentRating->find();
     while ($eContentRating->fetch()) {
         if ($eContentRating->status == 'active') {
             $resource = new Resource();
             $resource->record_id = $eContentRating->id;
             $resource->source = 'eContent';
             $resource->find(true);
             $ratings[] = array('id' => $eContentRating->id, 'title' => $eContentRating->title, 'author' => $eContentRating->author, 'format' => $resource->format_category, 'rating' => $eContentRating->rating, 'fullId' => $eContentRating->id, 'shortId' => $eContentRating->id, 'link' => '/EcontentRecord/' . $eContentRating->id . '/Home', 'dateRated' => $eContentRating->dateRated, 'ratingData' => array('user' => $eContentRating->rating), 'source' => 'eContent');
         }
     }
     asort($ratings);
     //Load titles the user is not interested in
     $notInterested = array();
     $notInterestedObj = new NotInterested();
     $resource = new Resource();
     $notInterestedObj->joinAdd($resource);
     $notInterestedObj->userId = $user->id;
     $notInterestedObj->deleted = 0;
     $notInterestedObj->selectAdd('user_not_interested.id as user_not_interested_id');
     $notInterestedObj->find();
     while ($notInterestedObj->fetch()) {
         if ($notInterestedObj->source == 'VuFind') {
             $link = '/Record/' . $notInterestedObj->record_id;
         } else {
             $link = '/EcontentRecord/' . $notInterestedObj->record_id;
         }
         if ($notInterestedObj->deleted == 0) {
             $notInterested[] = array('id' => $notInterestedObj->user_not_interested_id, 'title' => $notInterestedObj->title, 'author' => $notInterestedObj->author, 'dateMarked' => $notInterestedObj->dateMarked, 'link' => $link);
         }
     }
     $interface->assign('ratings', $ratings);
     $interface->assign('notInterested', $notInterested);
     $interface->setPageTitle('My Ratings');
     $interface->setTemplate('myRatings.tpl');
     $interface->display('layout.tpl');
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:59,代码来源:MyRatings.php

示例8: testMostSpecificRuleAppliesIfNoExactRuleIsFound

 public function testMostSpecificRuleAppliesIfNoExactRuleIsFound()
 {
     $this->repository->addRule($this->role1, $this->resource1, true);
     $this->repository->addRule($this->role1, $this->resource2, false);
     $rule = $this->repository->getMostApplyingRule($this->role2, $this->resource2);
     $this->assertSame($this->role1->getRoleId(), $rule->getRoleId());
     $this->assertSame($this->resource2->getResourceId(), $rule->getResourceId());
 }
开发者ID:heho,项目名称:gatekeeper,代码行数:8,代码来源:RuleRepositoryTest.php

示例9: addResource

 public function addResource(Resource $resource)
 {
     $className = $resource->getClassName();
     if (true === isset($this->resources[$className])) {
         throw new \InvalidArgumentException(sprintf('Resource for class %s has been added', $className));
     }
     $this->resources[$className] = $resource;
 }
开发者ID:baethon,项目名称:jsonapi-encoder,代码行数:8,代码来源:ResourceCollection.php

示例10: isAuthorized

 /**
  * Check to see if the given Subject is authorized for the given Resource
  *
  * @param Subject $subject Subject making request
  * @param \Xacmlphp\Resource $resource Resource being accessed (policies attached)
  * @param Action $action Action instance
  *
  * @return bool Allowed/not allowed status
  */
 public function isAuthorized(Subject $subject, Resource $resource, Action $action)
 {
     $decider = $this->getDecider();
     if ($decider === null) {
         throw new \InvalidArgumentException('Invalid Decider object');
     }
     $policies = $resource->getPolicies();
     return $decider->evaluate($subject, $policies, $action);
 }
开发者ID:Milstein,项目名称:xacmlphp,代码行数:18,代码来源:Enforcer.php

示例11: populate

 /**
  * @param array $values
  * @return $this
  */
 public function populate(array $values = [])
 {
     foreach ($values as $value) {
         $resource = new Resource();
         $resource->populate($value);
         $this->resources[] = $resource;
     }
     return $this;
 }
开发者ID:imoneza,项目名称:imoneza-php-api,代码行数:13,代码来源:ResourceCollection.php

示例12: run

 /**
  * @see AbstractController::run()
  */
 public function run(Resource $resource)
 {
     $uriParams = $resource->getParams();
     $formParams = RequestManager::getAllParams();
     $uc = new UserPreferencesController();
     $uc->getUserPreference(Utils::getLoggedInUserId());
     $this->populateProgramData($uriParams, $formParams);
     $this->getView()->setViewName(self::MODULE_KEY)->display();
 }
开发者ID:Abhishek627,项目名称:crux,代码行数:12,代码来源:IndexController.php

示例13: run

 public function run(Resource $resource)
 {
     $uriParams = $resource->getParams();
     $formParams = RequestManager::getAllParams();
     if (!empty($formParams[self::FILE_UPLOAD_ACTION_NAME]) && $formParams[self::FILE_UPLOAD_ACTION_NAME] == self::FILE_UPLOAD_ACTION_VALUE) {
         $this->uploadFile($formParams);
     } else {
         $this->getView()->setViewName(self::MODULE_KEY)->display();
     }
 }
开发者ID:Abhishek627,项目名称:crux,代码行数:10,代码来源:UploadController.php

示例14: testManage

 public function testManage()
 {
     // Run first time to generate assets
     $this->resource->manage([__DIR__]);
     foreach ($this->files as $file) {
         $this->assertFileExists(ResourceManager::$cacheRoot . dirname($file) . '/' . pathinfo($file, PATHINFO_FILENAME) . '.' . $this->resource->convertType($file));
     }
     // Run second time to use cache
     $this->resource->manage([__DIR__]);
 }
开发者ID:samsonphp,项目名称:resource,代码行数:10,代码来源:ResourceTest.php

示例15: run

 /**
  * @see AbstractController::run()
  */
 public function run(Resource $resource)
 {
     $inputParams = $resource->getParams();
     $pid = $inputParams[Constants::INPUT_PARAM_ACTION];
     if (!empty($pid)) {
         $this->downloadFile($pid);
     } else {
         throw new Exception("No File Info Provided!");
     }
 }
开发者ID:Abhishek627,项目名称:crux,代码行数:13,代码来源:DownloadController.php


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