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

PHP Resource类代码示例

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

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



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


示例16: run

 public function run(Resource $resource)
 {
     $uriParams = $resource->getParams();
     $formParams = RequestManager::getAllParams();
     if (strtolower($uriParams[Constants::INPUT_PARAM_ACTION]) === 'save') {
         if ($this->saveUserPreference($formParams)) {
             Response::sendResponse(Constants::SUCCESS_RESPONSE, Messages::SUCCESS_UPDATE);
         } else {
             Response::sendResponse(Constants::SUCCESS_RESPONSE, Messages::ERROR_OPERATION_FAILED);
         }
     }
 }
开发者ID:Abhishek627,项目名称:crux,代码行数:12,代码来源:UserPreferencesController.php


示例17: setCorrectParams

 /**
  * Set appropriate parameter for given resource
  * 
  * @param Resource $resource
  * @param array $set
  * @return resource
  */
 private static function setCorrectParams(Resource $resource, array $set)
 {
     $params = array();
     $altkeys = array(Constants::INDEX_URI_KEY, Constants::EXPLORER_URI_KEY);
     if (in_array($resource->getKey(), $altkeys)) {
         $params = array(Constants::INPUT_PARAM_LANG => $set[0], Constants::INPUT_PARAM_CATE => $set[1], Constants::INPUT_PARAM_PID => $set[2]);
     } else {
         $params = array(Constants::INPUT_PARAM_MODULE => $set[0], Constants::INPUT_PARAM_ACTION => $set[1], Constants::INPUT_PARAM_SUBACTION => $set[2]);
     }
     $resource->setParams($params);
     return $resource;
 }
开发者ID:Abhishek627,项目名称:crux,代码行数:19,代码来源:ResourceProvider.php


示例18: __construct

 /**
  * Constructor
  *
  * To save a few keystrokes, the Controller is executed as part of the
  * constructor instead of via a method. You either want the Controller or
  * you don't.
  */
 public function __construct()
 {
     parent::__construct();
     try {
         // Secure by default
         if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == false) {
             throw new \Exception('HTTPS is required.', 400);
         }
         // Grabs the requested page
         $request = $_REQUEST['request'];
         $components = explode('/', $request);
         $nouns = [];
         $uids = [];
         $version = array_shift($components);
         $_SERVER['__version'] = substr($version, 1);
         // Checks if we're trying to rock some OAuth
         if ($components[0] == 'oauth') {
             $class = 'Pickles\\OAuth2\\Resource';
         } else {
             // Loops through the components to determine nouns and IDs
             foreach ($components as $index => $component) {
                 if ($index % 2) {
                     $uids[end($nouns)] = $component;
                 } else {
                     $nouns[] = $component;
                 }
             }
             // Creates our class name
             array_unshift($nouns, '', 'Pickles', 'App', 'Resources', $version);
             $class = implode('\\', $nouns);
         }
         // Checks that the file is present and contains our class
         if (!class_exists($class)) {
             throw new \Exception('Not Found.', 404);
         }
         // Instantiates our resource with the UIDs
         $resource = new $class($uids);
     } catch (\Exception $e) {
         // Creates a resource object if we don't have one
         if (!isset($resource)) {
             $resource = new Resource();
         }
         $code = $e->getCode();
         // Anything below 200 is probably a PHP error
         if ($code < 200) {
             $code = 500;
         }
         $resource->status = $code;
         $resource->message = $e->getMessage();
     }
     $resource->respond();
 }
开发者ID:joshtronic,项目名称:pickles,代码行数:59,代码来源:Router.php


示例19: fromArray

 private static function fromArray($array)
 {
     $resource = new Resource();
     if (isset($array["abstract"]) && $array["abstract"]) {
         $resource->isAbstract();
     }
     foreach ($array as $key => $actionData) {
         if (in_array(strtolower($key), ["get", "post", "put", "delete", "any"])) {
             $resource->on(strtolower($key), $actionData);
         }
     }
     return $resource;
 }
开发者ID:phidias-sas,项目名称:api,代码行数:13,代码来源:Resource.php


示例20: getResources

 /**
  * Get all resources associated with the current tag.
  *
  * @return array
  * @access public
  */
 public function getResources()
 {
     $resList = array();
     $sql = 'SELECT "resource".* FROM "resource_tags", "resource" ' . 'WHERE "resource"."id" = "resource_tags"."resource_id" ' . 'AND "resource_tags"."tag_id" = ' . "'" . $this->escape($this->id) . "'";
     $res = new Resource();
     $res->query($sql);
     if ($res->N) {
         while ($res->fetch()) {
             $resList[] = clone $res;
         }
     }
     return $resList;
 }
开发者ID:bharatm,项目名称:NDL-VuFind,代码行数:19,代码来源:Tags.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP ResourceLoader类代码示例发布时间:2022-05-23
下一篇:
PHP Reservation类代码示例发布时间: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