本文整理汇总了PHP中Error::setTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Error::setTitle方法的具体用法?PHP Error::setTitle怎么用?PHP Error::setTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::setTitle方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Retorna uma lista de usuários
*
* @license http://www.gnu.org/copyleft/gpl.html GPL
* @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
* @sponsor Caixa Econômica Federal
* @author José Vicente Tezza Jr.
* @return Retorna uma lista de usuários do LDAP
* @access public
* */
function get($request, $id)
{
$response = new Response($request);
$response->addHeader('Content-type', 'aplication/json');
$response->code = Response::OK;
$h = new Hypermedia();
$c = new Collection($request->resources, 'PersonalContactResource');
try {
$this->secured();
$contacts = !!$id ? Controller::find(array('concept' => 'contact'), false, array('filter' => array('AND', array('=', 'user', Config::me("uidNumber")), array('=', 'id', $id)))) : Controller::find(array('concept' => 'contact'), false, array('filter' => array('=', 'user', Config::me("uidNumber"))));
//Se nao foi encontrado contatos na consulta
if ($contacts === false) {
$error = new Error();
$error->setCode(Response::NOTFOUND);
$error->setTitle('Contacts not found');
$error->setDescription('Contacts not found.');
$c->setError($error);
$h->setCollection($c);
$response->code = Response::NOTFOUND;
$response->body = $h->getHypermedia($request->accept[10][0]);
return $response;
}
foreach ($contacts as $value) {
$i = new Item($request->resources, 'PersonalContactResource', $value['id']);
$d = new Data();
$d->setName('name');
$d->setValue($value['name']);
$d->setPrompt('Nome do Contato');
$d->setDataType('string');
$d->setMaxLength('100');
$d->setMinLength(null);
$d->setRequired(true);
$i->addData($d);
$d = new Data();
$d->setName('id');
$d->setValue($value['id']);
$d->setPrompt('Id do Contato');
$d->setDataType('string');
$d->setMaxLength('100');
$d->setMinLength(null);
$d->setRequired(true);
$i->addData($d);
$d = new Data();
$d->setName('email');
$d->setValue($value['email']);
$d->setPrompt('Email do Contato');
$d->setDataType('string');
$d->setMaxLength('100');
$d->setMinLength(null);
$d->setRequired(true);
$i->addData($d);
$l = new Link();
$l->setHref('');
$l->setRel('delete');
$l->setAlt('Remover');
$l->setPrompt('Remover');
$l->setRender('link');
$i->addLink($l);
$l = new Link();
$l->setHref('');
$l->setRel('put');
$l->setAlt('Atualizar');
$l->setPrompt('Atualizar');
$l->setRender('link');
$i->addLink($l);
$l = new Link();
$l->setHref('/contact/' . $value['id']);
$l->setRel('get');
$l->setAlt('Buscar');
$l->setPrompt('Buscar');
$l->setRender('link');
$i->addLink($l);
$c->addItem($i);
}
$t = new Template();
$d = new Data();
$d->setName('name');
$d->setValue(null);
$d->setPrompt('Nome do Contato');
$d->setDataType('string');
$d->setMaxLength(100);
$d->setMinLength(null);
$d->setRequired(true);
$t->addData($d);
$d = new Data();
$d->setName('email');
$d->setValue(null);
$d->setPrompt('Email do Contato');
$d->setDataType('string');
$d->setMaxLength(100);
//.........这里部分代码省略.........
示例2: get
/**
* Retorna uma lista de usuários
*
* @license http://www.gnu.org/copyleft/gpl.html GPL
* @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
* @sponsor Caixa Econômica Federal
* @author José Vicente Tezza Jr.
* @return Retorna um usuário do LDAP filtrado pelo atributo 'uid'
* @access public
* */
function get($request, $id)
{
$response = new Response($request);
$response->addHeader('Content-type', 'aplication/json');
$response->code = Response::OK;
$h = new Hypermedia();
$c = new Collection($request->resources, 'UserResource');
try {
$this->secured();
$user = Controller::find(array('concept' => 'user', 'service' => 'OpenLDAP'), false, array('filter' => array('=', 'uid', $id), 'notExternal' => true));
//Se nao foi encontrado usuario na consulta
if ($user === false) {
$error = new Error();
$error->setCode(Response::NOTFOUND);
$error->setTitle('UserLDAP not found');
$error->setDescription('User not found.');
$c->setError($error);
$h->setCollection($c);
$response->code = Response::NOTFOUND;
$response->body = $h->getHypermedia($request->accept[10][0]);
return $response;
}
$t = new Template();
$d = new Data();
$d->setName('name');
$d->setValue(null);
$d->setPrompt('Nome do Usuário');
$d->setDataType('string');
$d->setMaxLength(100);
$d->setMinLength(null);
$d->setRequired(true);
$t->addData($d);
$d = new Data();
$d->setName('email');
$d->setValue(null);
$d->setPrompt('Email do Usuário');
$d->setDataType('string');
$d->setMaxLength(100);
$d->setMinLength(null);
$d->setRequired(true);
$t->addData($d);
$d = new Data();
$d->setName('telefone');
$d->setValue(null);
$d->setPrompt('Telefone do Usuário');
$d->setDataType('string');
$d->setMaxLength(100);
$d->setMinLength(null);
$d->setRequired(true);
$t->addData($d);
$c->setTemplate($t);
$d = new Data();
$d->setName('name');
$d->setValue($user[0]['name']);
$d->setPrompt('Nome do Usuário');
$d->setDataType('string');
$d->setMaxLength('100');
$d->setMinLength(null);
$d->setRequired(true);
$c->addData($d);
$d = new Data();
$d->setName('email');
$d->setValue($user[0]['mail']);
$d->setPrompt('Email do Usuário');
$d->setDataType('string');
$d->setMaxLength('100');
$d->setMinLength(null);
$d->setRequired(true);
$c->addData($d);
$d = new Data();
$d->setName('telephoneNumber');
$d->setValue($user[0]['telephoneNumber']);
$d->setPrompt('Telefone do Usuário');
$d->setDataType('string');
$d->setMaxLength('100');
$d->setMinLength(null);
$d->setRequired(true);
$c->addData($d);
$l = new Link();
$l->setHref('');
$l->setRel('delete');
$l->setAlt('Remover');
$l->setPrompt('Remover');
$l->setRender('link');
$c->addLink($l);
$l = new Link();
$l->setHref('');
$l->setRel('put');
$l->setAlt('Atualizar');
$l->setPrompt('Atualizar');
//.........这里部分代码省略.........
示例3: createException
private function createException($request, &$response, $code, $title, $description)
{
$response->code = $code;
$h = new Hypermedia();
$c = new Collection($request->resources, 'DynamicContactResource');
$e = new Error();
$e->setCode($code);
$e->setTitle($title);
$e->setDescription($description);
$c->setError($e);
$h->setCollection($c);
$response->body = $h->getHypermedia($request->accept[10][0]);
}
示例4: create
public function create($article)
{
$postArgs = array('post_title' => $article->entityName, 'post_type' => DPSFA_Article_Slug, 'post_content' => '', 'post_excerpt' => '', 'post_status' => 'publish');
$post = wp_insert_post($postArgs);
if ($post) {
$date = new \DateTime();
$article->id = $post;
$article->date_created = $date->getTimestamp();
$article->save();
} else {
$error = new Error("Error", 400);
$error->setTitle('Could not create Article');
$error->setMessage('Wordpress could not create the article');
$error->setRaw($post);
}
}
开发者ID:jerwarren,项目名称:digital-publishing-tools-for-wordpress,代码行数:16,代码来源:dpsfa-cms-wordpress-cpt-article.php
示例5: has_api_credentials
public function has_api_credentials()
{
// Make sure all credentials have been entered
// If nothign has been entered, return false
if (empty($this->key) && empty($this->secret) && empty($this->device_token) && empty($this->device_id)) {
return false;
} else {
$missing = array();
if (empty($this->key)) {
array_push($missing, "API Key");
}
if (empty($this->secret)) {
array_push($missing, "API Secret");
}
if (empty($this->device_token)) {
array_push($missing, "Device Token");
}
if (empty($this->device_id)) {
array_push($missing, "Device ID");
}
if (empty($missing)) {
return true;
} else {
// Throw new error
$error = new Error("Error", $code);
$error->setTitle('Missing Credentials');
$error->setMessage('One of the required API credentials is missing, please fill out: ' . implode(", ", $missing));
throw $error;
}
}
}
示例6: refresh_access_token
/**
* This method will get the access token.
*
* @param {String} $refresh_token - The base-64 encoded refresh token
* @param {String} $grant_type - The grant type, optional parameters
* @example $grant_type = 'refresh_token';
* @param {String} $scope - The scope value, optional parameters
* @example $scope = 'AdobeID,openid';
*/
public function refresh_access_token($grant_type = 'refresh_token', $scope = 'AdobeID,openid')
{
// set request header:
// [+] Accept: application/json
// [+] Content-Type: application/x-www-form-urlencoded
$headers = array('Accept: application/json', 'Content-Type: Content-Type: application/x-www-form-urlencoded');
// set request URL
$url = $this->authentication_endpoint . "/ims/token/v1?grant_type=device&client_id=" . $this->client_id . "&client_secret=" . $this->client_secret . "&scope=openid&device_token=" . $this->device_token . "&device_id=" . $this->device_id;
// call helper to initiate the cURL request
$curl = new Curl('POST', $url, $headers);
// Parse out token
$data = $curl->getResponseBody();
if (!empty($data['error'])) {
// Throw new error
$error = new Error("Error", 401);
$error->setRaw(array("headers" => $curl->getResponseHeader(), "body" => $curl->getResponseBody(), "url" => $curl->getRequestUrl(), "entity" => ''));
$error->setTitle('API Credentials Not Valid');
$error->setMessage('The API credentials supplied are not valid. The plugin will not allow you to access any of the cloud functions without proper credentials: ' . $data['error']);
// Return token
$this->access_token = "";
$this->refresh_token = "";
// Save access token
$settings = new Settings();
$settings->access_token = "";
$settings->refresh_token = "";
$settings->publications = array();
$settings->permissions = array();
$settings->save();
throw $error;
} else {
$access_token = isset($data['access_token']) ? $data['access_token'] : null;
$refresh_token = isset($data['refresh_token']) ? $data['refresh_token'] : null;
// Save access token
$settings = new Settings();
$settings->access_token = $access_token;
$settings->refresh_token = $refresh_token;
$settings->save();
// Return token
$this->access_token = $access_token;
$this->refresh_token = $refresh_token;
}
}
示例7: get
/**
* Retorna uma lista de usuários
*
* @license http://www.gnu.org/copyleft/gpl.html GPL
* @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
* @sponsor Caixa Econômica Federal
* @author José Vicente Tezza Jr.
* @return Retorna uma lista de usuários do LDAP
* @access public
* */
function get($request)
{
$response = new Response($request);
$response->addHeader('Content-type', 'aplication/json');
$response->code = Response::OK;
$h = new Hypermedia();
$c = new Collection($request->resources, 'UsersResource');
$this->secured();
try {
//Executa uma consulta de usuários do LDAP a partir de um determinado atributo e valor
if (isset($_GET['field']) && isset($_GET['value'])) {
//recupera os atributos definidos no conceito 'user'
$map = Config::get('user', 'OpenLDAP.mapping');
//verifica se o campo(atributo) passado pelo usuário está definido no conceito 'user'
if (isset($map[$_GET['field']])) {
$users = Controller::find(array('concept' => 'user', 'service' => 'OpenLDAP'), false, array('filter' => array('=', $_GET['field'], $_GET['value']), 'notExternal' => true));
} else {
//lança warning no log do Expresso
trigger_error("Invalid field (" . $_GET['field'] . ") in the query.", E_USER_WARNING);
//formata os atributos LDAP do conceito 'user'
$attributes = implode(', ', $map);
//Configura o erro na hypermedia
$error = new Error();
$error->setCode(Response::NOTFOUND);
$error->setTitle('UserLDAP not found');
$error->setDescription("Invalid field (" . $_GET['field'] . ") in the query. Use of these: " . $attributes);
$c->setError($error);
$h->setCollection($c);
//retorna a hypermedia
$response->code = Response::NOTFOUND;
$response->body = $h->getHypermedia($request->accept[10][0]);
return $response;
}
} else {
//Executa a consulta dos primeiros 20 usuarios do LDAP
$users = Controller::find(array('concept' => 'user', 'service' => 'OpenLDAP'), false, array('filter' => array('=', 'phpgwAccountType', 'u'), 'limit' => 20, 'notExternal' => true));
}
//Se nao foi encontrado usuarios na consulta
if ($users === false) {
$error = new Error();
$error->setCode(Response::NOTFOUND);
$error->setTitle('UserLDAP not found');
$error->setDescription('Users not found.');
$c->setError($error);
$h->setCollection($c);
$response->code = Response::NOTFOUND;
$response->body = $h->getHypermedia($request->accept[10][0]);
return $response;
}
foreach ($users as $value) {
$d = new Data();
$i = new Item($request->resources, 'UsersResource', $value['uid']);
$d->setName('name');
$d->setValue($value['name']);
$d->setPrompt('Nome do Usuario');
$d->setDataType('string');
$d->setMaxLength('100');
$d->setMinLength(null);
$d->setRequired(true);
$i->addData($d);
$d = new Data();
$d->setName('email');
$d->setValue($value['mail']);
$d->setPrompt('Email do Usuario');
$d->setDataType('string');
$d->setMaxLength('100');
$d->setMinLength(null);
$d->setRequired(true);
$i->addData($d);
$d = new Data();
$d->setName('telephoneNumber');
$d->setValue($value['telephoneNumber']);
$d->setPrompt('Telefone do Usuario');
$d->setDataType('string');
$d->setMaxLength('100');
$d->setMinLength(null);
$d->setRequired(true);
$i->addData($d);
$d = new Data();
$d->setName('vacationActive');
$d->setValue($value['vacationActive']);
$d->setPrompt('Status da Regra fora de Escritorio');
$d->setDataType('boolean');
$d->setMaxLength('10');
$d->setMinLength(null);
$d->setRequired(null);
$i->addData($d);
$d = new Data();
$d->setName('vacationInfo');
$d->setValue($value['vacationInfo']);
//.........这里部分代码省略.........
示例8: exec
/**
* This method will initialize and execute the HTTPS request.
*/
public function exec()
{
// initialize the cURL
$this->curl = curl_init();
// initialize cURL parameters
curl_setopt_array($this->curl, $this->curl_options);
// execute cURL request
$this->curl_response = curl_exec($this->curl);
// get the response HTTP code
$this->curl_http_code = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
// get the response header size
$this->curl_response_size = curl_getinfo($this->curl, CURLINFO_HEADER_SIZE);
// call helper to parse & store the response header and body
$this->formatResponse();
if (curl_errno($this->curl)) {
$error = new Error("Error", curl_errno($this->curl));
$error = new Error("Error", 300);
$error->setTitle('Unable to send a request to the Adobe API');
$error->setMessage(curl_error($this->curl));
throw $error;
}
// close cURL request
curl_close($this->curl);
}