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


PHP self::setError方法代码示例

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


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

示例1: initializeByString

 /**
  * Method for object initialization by the string
  * @param string $string response string
  * @return Error error object
  */
 public static function initializeByString($string)
 {
     $object = json_decode($string);
     $Response = new self();
     $Response->setError($object->error);
     return $Response;
 }
开发者ID:alxmsl,项目名称:googleclient,代码行数:12,代码来源:Error.php

示例2: initializeByString

 /**
  * Method for object initialization by the string
  * @param string $string response string with error data
  * @return Error response object
  */
 public static function initializeByString($string)
 {
     $data = array();
     parse_str($string, $data);
     $Error = new self();
     $Error->setError($data['error'])->setDescription($data['error_description']);
     return $Error;
 }
开发者ID:Aliance,项目名称:VkontakteClient,代码行数:13,代码来源:Error.php

示例3: get

 public static function get($bin = null)
 {
     $_bl = new self();
     if (!is_numeric($bin)) {
         $_bl->setError('no bin provided or not numeric');
         return $_bl;
     }
     return $_bl->fetch($bin);
 }
开发者ID:ikanc,项目名称:binlist,代码行数:9,代码来源:Binlist.php

示例4: failure

 public static function failure($msg = null, $extra = array())
 {
     $result = new self();
     $result->setError();
     $result->setMessage($msg);
     foreach ($extra as $k => $v) {
         $result->{$k} = $v;
     }
     return $result;
 }
开发者ID:corneltek,项目名称:lazyrecord,代码行数:10,代码来源:Result.php

示例5: showListForCentral

 /**
  * Show list for central view
  *
  * @param $personal boolean   display rssfeeds created by me ? (true by default)
  *
  * @return Nothing (display function)
  **/
 static function showListForCentral($personal = true)
 {
     global $DB, $CFG_GLPI;
     $users_id = Session::getLoginUserID();
     $today = date('Y-m-d');
     $now = date('Y-m-d H:i:s');
     if ($personal) {
         /// Personal notes only for central view
         if ($_SESSION['glpiactiveprofile']['interface'] == 'helpdesk') {
             return false;
         }
         $query = "SELECT `glpi_rssfeeds`.*\n                   FROM `glpi_rssfeeds`\n                   WHERE `glpi_rssfeeds`.`users_id` = '{$users_id}'\n                         AND `glpi_rssfeeds`.`is_active` = '1'\n                   ORDER BY `glpi_rssfeeds`.`name`";
         $titre = "<a href='" . $CFG_GLPI["root_doc"] . "/front/rssfeed.php'>" . _n('Personal RSS feed', 'Personal RSS feeds', Session::getPluralNumber()) . "</a>";
     } else {
         // Show public rssfeeds / not mines : need to have access to public rssfeeds
         if (!self::canView()) {
             return false;
         }
         $restrict_user = '1';
         // Only personal on central so do not keep it
         if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
             $restrict_user = "`glpi_rssfeeds`.`users_id` <> '{$users_id}'";
         }
         $query = "SELECT `glpi_rssfeeds`.*\n                   FROM `glpi_rssfeeds` " . self::addVisibilityJoins() . "\n                   WHERE {$restrict_user}\n                         AND " . self::addVisibilityRestrict() . "\n                   ORDER BY `glpi_rssfeeds`.`name`";
         if ($_SESSION['glpiactiveprofile']['interface'] != 'helpdesk') {
             $titre = "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/rssfeed.php\">" . _n('Public RSS feed', 'Public RSS feeds', Session::getPluralNumber()) . "</a>";
         } else {
             $titre = _n('Public RSS feed', 'Public RSS feeds', Session::getPluralNumber());
         }
     }
     $result = $DB->query($query);
     $items = array();
     $rssfeed = new self();
     if ($nb = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             if ($rssfeed->getFromDB($data['id'])) {
                 // Force fetching feeds
                 if ($feed = self::getRSSFeed($data['url'], $data['refresh_rate'])) {
                     // Store feeds in array of feeds
                     $items = array_merge($items, $feed->get_items(0, $data['max_items']));
                     $rssfeed->setError(false);
                 } else {
                     $rssfeed->setError(true);
                 }
             }
         }
     }
     echo "<br><table class='tab_cadrehov'>";
     echo "<tr class='noHover'><th colspan='2'><div class='relative'><span>{$titre}</span>";
     if ($personal && self::canCreate() || !$personal && Session::haveRight('rssfeed_public', CREATE)) {
         echo "<span class='floatright'>";
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/rssfeed.form.php'>";
         echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/plus.png' alt='" . __s('Add') . "' title=\"" . __s('Add') . "\"></a></span>";
     }
     echo "</div></th></tr>\n";
     if ($nb) {
         usort($items, array('SimplePie', 'sort_items'));
         foreach ($items as $item) {
             echo "<tr class='tab_bg_1'><td>";
             echo HTML::convDateTime($item->get_date('Y-m-d H:i:s'));
             echo "</td><td>";
             $link = $item->feed->get_permalink();
             if (empty($link)) {
                 echo $item->feed->get_title();
             } else {
                 echo "<a target='_blank' href='{$link}'>" . $item->feed->get_title() . '</a>';
             }
             $link = $item->get_permalink();
             //                echo "<br>";
             //                echo $item->get_title();
             //                echo "</td><td>";
             $rand = mt_rand();
             echo "<div id='rssitem{$rand}' class='pointer rss'>";
             if (!is_null($link)) {
                 echo "<a target='_blank' href='{$link}'>";
             }
             echo $item->get_title();
             //                echo Html::resume_text(Html::clean(Toolbox::unclean_cross_side_scripting_deep($item->get_content())), 300);
             if (!is_null($link)) {
                 echo "</a>";
             }
             echo "</div>";
             Html::showToolTip(Toolbox::unclean_html_cross_side_scripting_deep($item->get_content()), array('applyto' => "rssitem{$rand}", 'display' => true));
             echo "</td></tr>";
         }
     }
     echo "</table>\n";
 }
开发者ID:stweil,项目名称:glpi,代码行数:95,代码来源:rssfeed.class.php

示例6: fromArray

 /**
  * @param array $array
  * @param bool $strict
  * @return Document
  * @throws FromArrayCompilationException
  */
 public static function fromArray(array $array, $strict = true)
 {
     $document = new self();
     if (array_key_exists('collection', $array)) {
         if (!is_array($array['collection'])) {
             throw new ExpectedArrayException('collection', gettype($array['collection']));
         }
         try {
             $document->setCollection(Collection::fromArray($array['collection'], $strict));
         } catch (FromArrayCompilationException $e) {
             throw new FromArrayCompilationException('collection', $e->getMessage());
         }
     }
     if (array_key_exists('error', $array)) {
         if (!is_array($array['error'])) {
             throw new ExpectedArrayException('error', gettype($array['error']));
         }
         try {
             $document->setError(Error::fromArray($array['error']));
         } catch (FromArrayCompilationException $e) {
             throw new FromArrayCompilationException('error', $e->getMessage());
         }
     }
     if (array_key_exists('template', $array)) {
         if (!is_array($array['template'])) {
             throw new ExpectedArrayException('template', gettype($array['template']));
         }
         try {
             $document->setTemplate(Template::fromArray($array['template'], $strict));
         } catch (FromArrayCompilationException $e) {
             throw new FromArrayCompilationException('template', $e->getMessage());
         }
     }
     if (array_key_exists('queries', $array)) {
         if (!is_array($array['queries'])) {
             throw new ExpectedArrayException('queries', gettype($array['queries']));
         }
         try {
             foreach ($array['queries'] as $key => $queryArray) {
                 if (!is_array($queryArray)) {
                     throw new ExpectedArrayException($key, gettype($queryArray));
                 }
                 try {
                     $document->getQueries()->add(Query::fromArray($queryArray, $strict));
                 } catch (FromArrayCompilationException $e) {
                     throw new FromArrayCompilationException($key, $e->getMessage());
                 }
             }
         } catch (FromArrayCompilationException $e) {
             throw new FromArrayCompilationException('queries', $e->getMessage());
         }
     }
     return $document;
 }
开发者ID:0N3S3C,项目名称:PhpCollectionJson,代码行数:60,代码来源:Document.php

示例7: fromArray

 /**
  * {@inheritdoc}
  */
 public static function fromArray(array $values)
 {
     $message = new self();
     $values = array_merge(['error' => null, 'hash' => null, 'settings' => null], $values);
     $message->setError($values['error']);
     $message->setHash($values['hash']);
     $message->setSettings($values['settings']);
     return $message;
 }
开发者ID:jaspervdm,项目名称:pogoprotos-php,代码行数:12,代码来源:DownloadSettingsResponse.php

示例8: exception

 /**
  * Create and throw Exception
  * @param $key
  * @param $error
  * @return self
  */
 public static function exception($key, $error)
 {
     $exception = new self();
     $exception->setError($key, $error);
     return $exception;
 }
开发者ID:9618211,项目名称:framework,代码行数:12,代码来源:ValidatorException.php

示例9: parseGuzzleResponse

 /**
  * @param \Guzzle\Http\Message\Response $guzzleResponse
  * @param ActionsInterface              $action
  * @return Response
  */
 public static function parseGuzzleResponse(\Guzzle\Http\Message\Response $guzzleResponse, ActionsInterface $action)
 {
     $response = new self();
     if ($guzzleResponse->getStatusCode() != 200) {
         $response->setStatus(false);
         $response->setError($response::ERROR_REQUEST_ERROR);
         return $response;
     }
     $responseArray = json_decode($guzzleResponse->getBody(true), true);
     $response->setStatus($responseArray['ok']);
     if ($response->getStatus() === false) {
         $response->setError($responseArray['error']);
         return $response;
     }
     $response->setData($action->parseResponse($responseArray));
     return $response;
 }
开发者ID:Chokapix,项目名称:SlackBundle,代码行数:22,代码来源:Response.php

示例10: initializeByObject

 /**
  * Initialization method
  * @param stdClass $Object object for initialization
  * @return Error initialized object
  */
 public static function initializeByObject(stdClass $Object)
 {
     $Error = new self();
     if (isset($Object->error)) {
         $Error->setError($Object->error);
     }
     if (isset($Object->error_description)) {
         $Error->setDescription($Object->error_description);
     }
     return $Error;
 }
开发者ID:alxmsl,项目名称:odnoklassnikiclient,代码行数:16,代码来源:Error.php

示例11: fromResponse

 /**
  * @param Response $response
  *
  * @return RepositoryResponse
  */
 public static function fromResponse(Response $response)
 {
     $self = new self();
     $error = new Error();
     $self->setSuccessful(false);
     $responseContent = self::getResponseContent($response);
     $self->setResponse($responseContent);
     $responseArray = json_decode($responseContent, true);
     if (isset($responseArray['response']['status'])) {
         $self->setSuccessful($responseArray['response']['status'] == self::STATUS_SUCCESS);
     }
     if (!$self->isSuccessful()) {
         $error = Error::fromArray($responseArray['response']);
     }
     $self->setError($error);
     return $self;
 }
开发者ID:audiens,项目名称:appnexus-client,代码行数:22,代码来源:RepositoryResponse.php

示例12: fromArray

 /**
  * @param array $array
  * @param bool $strict
  * @return Collection
  * @throws FromArrayCompilationException
  */
 public static function fromArray(array $array, $strict = true)
 {
     $href = '';
     $version = '1.0';
     if (array_key_exists('href', $array)) {
         $href = $array['href'];
     } elseif ($strict) {
         throw new MissingArgumentException('href');
     }
     if (array_key_exists('version', $array)) {
         $version = $array['version'];
     }
     $collection = new self($href, $version);
     if (array_key_exists('links', $array)) {
         if (!is_array($array['links'])) {
             throw new ExpectedArrayException('links', gettype($array['links']));
         }
         try {
             foreach ($array['links'] as $key => $linkArray) {
                 if (!is_array($linkArray)) {
                     throw new ExpectedArrayException($key, gettype($linkArray));
                 }
                 try {
                     $collection->getLinks()->add(Link::fromArray($linkArray, $strict));
                 } catch (FromArrayCompilationException $e) {
                     throw new FromArrayCompilationException($key, $e->getMessage());
                 }
             }
         } catch (FromArrayCompilationException $e) {
             throw new FromArrayCompilationException('links', $e->getMessage());
         }
     }
     if (array_key_exists('items', $array)) {
         if (!is_array($array['items'])) {
             throw new ExpectedArrayException('items', gettype($array['items']));
         }
         try {
             foreach ($array['items'] as $key => $itemArray) {
                 if (!is_array($itemArray)) {
                     throw new ExpectedArrayException($key, gettype($itemArray));
                 }
                 try {
                     $collection->getItems()->add(Item::fromArray($itemArray, $strict));
                 } catch (FromArrayCompilationException $e) {
                     throw new FromArrayCompilationException($key, $e->getMessage());
                 }
             }
         } catch (FromArrayCompilationException $e) {
             throw new FromArrayCompilationException('items', $e->getMessage());
         }
     }
     if (array_key_exists('queries', $array)) {
         if (!is_array($array['queries'])) {
             throw new ExpectedArrayException('queries', gettype($array['queries']));
         }
         try {
             foreach ($array['queries'] as $key => $queryArray) {
                 if (!is_array($queryArray)) {
                     throw new ExpectedArrayException($key, gettype($queryArray));
                 }
                 try {
                     $collection->getQueries()->add(Query::fromArray($queryArray, $strict));
                 } catch (FromArrayCompilationException $e) {
                     throw new FromArrayCompilationException($key, $e->getMessage());
                 }
             }
         } catch (FromArrayCompilationException $e) {
             throw new FromArrayCompilationException('queries', $e->getMessage());
         }
     }
     if (array_key_exists('template', $array)) {
         if (!is_array($array['template'])) {
             throw new ExpectedArrayException('template', gettype($array['template']));
         }
         try {
             $collection->setTemplate(Template::fromArray($array['template'], $strict));
         } catch (FromArrayCompilationException $e) {
             throw new FromArrayCompilationException('template', $e->getMessage());
         }
     }
     if (array_key_exists('error', $array)) {
         if (!is_array($array['error'])) {
             throw new ExpectedArrayException('error', gettype($array['error']));
         }
         try {
             $collection->setError(Error::fromArray($array['error']));
         } catch (FromArrayCompilationException $e) {
             throw new FromArrayCompilationException('error', $e->getMessage());
         }
     }
     if (array_key_exists('paging', $array)) {
         if (!is_array($array['paging'])) {
             throw new ExpectedArrayException('paging', gettype($array['paging']));
         }
//.........这里部分代码省略.........
开发者ID:0N3S3C,项目名称:PhpCollectionJson,代码行数:101,代码来源:Collection.php

示例13: fromArray

 /**
  * {@inheritdoc}
  */
 public static function fromArray(array $values)
 {
     $message = new self();
     $values = array_merge(['error' => null, 'file' => []], $values);
     $message->setError($values['error']);
     foreach ($values['file'] as $item) {
         $message->addFile($item);
     }
     return $message;
 }
开发者ID:protobuf-php,项目名称:google-protobuf-proto,代码行数:13,代码来源:CodeGeneratorResponse.php

示例14: outputErrorMessage

 public static function outputErrorMessage($message)
 {
     $response = new self();
     $response->setError(0, $message);
     $response->output();
 }
开发者ID:grzchr15,项目名称:phplist-plugin-restapi,代码行数:6,代码来源:response.php

示例15: fromArray

 /**
  * @param array $data
  * @throws Exception
  * @return self
  */
 public static function fromArray($data)
 {
     if (empty($data['jsonrpc'])) {
         throw new Exception('Response is not valid JsonRPC response: missing protocol version');
     }
     if ($data['jsonrpc'] != Request::VERSION) {
         throw new Exception('Response is not valid JsonRPC response: invalid protocol version');
     }
     $response = new self();
     if (!empty($data['error'])) {
         $response->setError(static::getErrorObject($data['error']));
     } else {
         if (empty($data['result'])) {
             throw new Exception('Response is not valid JsonRPC response: missing result');
         }
         $response->setResult($data['result']);
     }
     if (empty($data['id'])) {
         throw new Exception('Response is not valid JsonRPC response: missing id');
     }
     $response->setId($data['id']);
     return $response;
 }
开发者ID:moaction,项目名称:jsonrpc-common,代码行数:28,代码来源:Response.php


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