本文整理汇总了PHP中self::setDescription方法的典型用法代码示例。如果您正苦于以下问题:PHP self::setDescription方法的具体用法?PHP self::setDescription怎么用?PHP self::setDescription使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类self
的用法示例。
在下文中一共展示了self::setDescription方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: from
/**
* @param Transaction|null $transaction
* @param TransactionListItem $transactionListItem
* @param string $apiUrl
* @param string $explorerUrl
* @return $this
*/
public static function from($transaction, TransactionListItem $transactionListItem, $apiUrl, $explorerUrl)
{
$transactionListItemDto = new self();
// From local app transaction
if ($transaction !== null) {
$transactionListItemDto->setDescription($transaction->getDescription());
} else {
$transactionListItemDto->setDescription($transactionListItem->getTxHash());
}
// From BlockCypher TXRef
$transactionListItemDto->setTxHash($transactionListItem->getTxHash());
//$transactionListItemDto->setTxInputN($transactionListItem->getTxInputN());
//$transactionListItemDto->setValue($transactionListItem->getValue());
$transactionListItemDto->setConfirmations($transactionListItem->getConfirmations());
if ($transactionListItem->getReceived() !== null) {
$transactionListItemDto->setReceived($transactionListItem->getReceived());
}
if ($transactionListItem->getConfirmed() !== null) {
$transactionListItemDto->setConfirmed($transactionListItem->getConfirmed());
}
$transactionListItemDto->setBlockHeight($transactionListItem->getBlockHeight());
$transactionListItemDto->setTotal($transactionListItem->getFinalTotal());
$transactionListItemDto->setApiUrl($apiUrl);
$transactionListItemDto->setExplorerUrl($explorerUrl);
return $transactionListItemDto;
}
示例2: factory
/**
* Factory method to create a new TogglClient
*
* The following array keys and values are available options:
* - base_url: Base URL of web service
* - username: username or API key
* - password: password (if empty, then username is a API key)
*
* See https://www.toggl.com/public/api#api_token for more information on the api token
*
* @param array|Collection $config Configuration data
*
* @return self
*/
public static function factory($config = array())
{
$default = array('base_url' => 'https://www.toggl.com/api/{apiVersion}', 'debug' => false, 'apiVersion' => 'v8', 'api_key' => '', 'username' => '', 'password' => '');
$required = array('api_key', 'username', 'password', 'base_url', 'apiVersion');
$config = Collection::fromConfig($config, $default, $required);
$client = new self($config->get('base_url'), $config);
// Attach a service description to the client
if ($config->get('apiVersion') == 'v8') {
$description = ServiceDescription::factory(__DIR__ . '/services_v8.json');
} else {
die('Only v8 is supported at this time');
}
$client->setDescription($description);
$client->setDefaultHeaders(array("Content-type" => "application/json"));
if (!empty($config->get('api_key'))) {
$config->set('username', $config->get('api_key'));
$config->set('password', 'api_token');
}
if (empty($config->get('password'))) {
$config->set('password', 'api_token');
}
$authPlugin = new CurlAuthPlugin($config->get('username'), $config->get('password'));
$client->addSubscriber($authPlugin);
if ($config->get('debug')) {
$client->addSubscriber(LogPlugin::getDebugPlugin());
}
return $client;
}
示例3: createFromTest
/**
* Import relevant properties from given test
*
* @param ilObjTest $a_test
* @return object
*/
public static function createFromTest(ilObjTest $a_test, $a_user_id)
{
global $lng;
$lng->loadLanguageModule("wsp");
$newObj = new self();
$newObj->setTitle($lng->txt("wsp_type_tstv") . " \"" . $a_test->getTitle() . "\"");
$newObj->setDescription($a_test->getDescription());
$active_id = $a_test->getActiveIdOfUser($a_user_id);
$pass = ilObjTest::_getResultPass($active_id);
$date = $a_test->getPassFinishDate($active_id, $pass);
$newObj->setProperty("issued_on", new ilDate($date, IL_CAL_UNIX));
// create certificate
include_once "Services/Certificate/classes/class.ilCertificate.php";
include_once "Modules/Test/classes/class.ilTestCertificateAdapter.php";
$certificate = new ilCertificate(new ilTestCertificateAdapter($a_test));
$certificate = $certificate->outCertificate(array("active_id" => $active_id, "pass" => $pass), false);
// save pdf file
if ($certificate) {
// we need the object id for storing the certificate file
$newObj->create();
$path = self::initStorage($newObj->getId(), "certificate");
$file_name = "tst_" . $a_test->getId() . "_" . $a_user_id . "_" . $active_id . ".pdf";
if (file_put_contents($path . $file_name, $certificate)) {
$newObj->setProperty("file", $file_name);
$newObj->update();
return $newObj;
}
// file creation failed, so remove to object, too
$newObj->delete();
}
}
示例4: factory
/**
* @param array $config
* @return \Guzzle\Service\Client|ImageRelayClient
* @throws \Guzzle\Common\Exception\InvalidArgumentException
*/
public static function factory($config = array())
{
$default = array('base_url' => 'https://{imagerelay_url}/api/v2/', 'imagerelay_url' => 'subdomain.imagerelay.com');
$config = Collection::fromConfig($config, $default);
$client = new self($config->get('base_url'), $config);
if ($config['auth'] === 'http') {
if (!isset($config['username'], $config['password'])) {
throw new InvalidArgumentException("Username and password required when using http auth.");
}
$authorization = 'Basic ' . base64_encode($config['username'] . ':' . $config['password']);
}
if ($config['auth'] === 'oauth') {
if (!isset($config['token'])) {
throw new InvalidArgumentException("Access token required when using oauth.");
}
$authorization = sprintf('Bearer %s', $config['token']);
}
if (!isset($authorization)) {
throw new InvalidArgumentException("Must use either http or oauth authentication method.");
}
// Attach a service description to the client
$description = ServiceDescription::factory(__DIR__ . '/Resources/api.php');
$client->setDescription($description);
// Set required User-Agent
$client->setUserAgent(sprintf('%s (%s)', $config['app_name'], $config['app_contact']));
$client->getEventDispatcher()->addListener('request.before_send', function (Event $event) use($authorization) {
$event['request']->addHeader('Authorization', $authorization);
});
return $client;
}
示例5: factory
public static function factory($config = array())
{
if (isset($config['developer_mode']) && is_bool($config['developer_mode'])) {
$developerMode = $config['developer_mode'];
} else {
$developerMode = false;
}
$baseUrl = array('https://api.auspost.com.au', 'https://devcentre.auspost.com.au/myapi');
// Ignore unnecessary user-specified configuration values
if ($developerMode) {
unset($config['email_address']);
unset($config['password']);
}
unset($config['base_url']);
$default = array('developer_mode' => $developerMode, 'base_url' => $baseUrl[$developerMode], 'email_address' => 'anonymous@auspost.com.au', 'password' => 'password');
$required = array('developer_mode', 'base_url', 'email_address', "password");
$config = Collection::fromConfig($config, $default, $required);
$client = new self($config->get('base_url'), $config);
$client->getConfig()->setPath('request.options/headers/Authorization', 'Basic ' . base64_encode($config->get('email_address') . ':' . $config->get('password')));
$client->setDescription(ServiceDescription::factory(__DIR__ . '/service.json'));
$client->setSslVerification(false);
$client->getEventDispatcher()->addListener('request.before_send', function (Event $event) {
$request = $event['request'];
$request->addCookie('OBBasicAuth', 'fromDialog');
});
return $client;
}
示例6: factory
public static function factory($config = array())
{
// The following values are required when creating the client
$required = array('base_url', 'username', 'password');
// Merge in default settings and validate the config
$config = Collection::fromConfig($config, array(), $required);
// Create a new sData client
$client = new self($config->get('base_url'), $config);
// JSON by default
$client->setDefaultOption('query/format', 'json');
// Authentication
$client->setDefaultOption('auth', array($config->get('username'), $config->get('password'), 'Basic'));
// Strip the BOM from results
$client->addSubscriber(new StripBomPlugin());
// Optional logging
if ($config->get('log')) {
$client->getEventDispatcher()->addListener('request.before_send', function (Event $event) {
$req = $event['request'];
\Log::info('sData', ['request' => $req->getMethod() . ' ' . $req->getResource()]);
});
}
// Set the service description
$services = \Config::get('sdata::services');
if (!empty($services)) {
$client->setDescription(ServiceDescription::factory($services));
}
// Done
return $client;
}
示例7: createFromExercise
/**
* Import relevant properties from given exercise
*
* @param ilObjExercise $a_test
* @return object
*/
public static function createFromExercise(ilObjExercise $a_exercise, $a_user_id)
{
global $lng;
$lng->loadLanguageModule("exercise");
$newObj = new self();
$newObj->setTitle($a_exercise->getTitle());
$newObj->setDescription($a_exercise->getDescription());
include_once "Services/Tracking/classes/class.ilLPMarks.php";
$lp_marks = new ilLPMarks($a_exercise->getId(), $a_user_id);
$newObj->setProperty("issued_on", new ilDate($lp_marks->getStatusChanged(), IL_CAL_DATETIME));
// create certificate
include_once "Services/Certificate/classes/class.ilCertificate.php";
include_once "Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php";
$certificate = new ilCertificate(new ilExerciseCertificateAdapter($a_exercise));
$certificate = $certificate->outCertificate(array("user_id" => $a_user_id), false);
// save pdf file
if ($certificate) {
// we need the object id for storing the certificate file
$newObj->create();
$path = self::initStorage($newObj->getId(), "certificate");
$file_name = "exc_" . $a_exercise->getId() . "_" . $a_user_id . ".pdf";
if (file_put_contents($path . $file_name, $certificate)) {
$newObj->setProperty("file", $file_name);
$newObj->update();
return $newObj;
}
// file creation failed, so remove to object, too
$newObj->delete();
}
// remove if certificate works
$newObj->create();
return $newObj;
}
示例8: factory
/**
* @param string $serviceDescription
* @param array $config
* @return \Guzzle\Service\Client
*/
public static function factory($config = array())
{
if (!isset($config['serviceDescription'])) {
throw new \Exception("Cannot create a twuzzle client without a service description");
}
$oauthConfig = array();
if (!isset($config['consumerKey'])) {
throw new \Exception("Cannot create an twuzzle client without a consumer key");
} else {
$oauthConfig['consumer_key'] = $config['consumerKey'];
}
if (!isset($config['consumerSecret'])) {
throw new \Exception("Cannot create an twuzzle client without a consumer secret");
} else {
$oauthConfig['consumer_secret'] = $config['consumerSecret'];
}
if (isset($config['token']) && !empty($config['token'])) {
$oauthConfig['token'] = $config['token'];
}
if (isset($config['tokenSecret']) && !empty($config['tokenSecret'])) {
$oauthConfig['token_secret'] = $config['tokenSecret'];
}
$client = new self();
$client->setDescription(ServiceDescription::factory($config['serviceDescription']));
$oauth = new OauthPlugin($oauthConfig);
$client->addSubscriber($oauth);
return $client;
}
示例9: factory
/**
* {@inheritdoc}
*/
public static function factory($config = array())
{
$default = array('url' => false, 'munchkin_id' => false, 'version' => 1, 'bulk' => false);
$required = array('client_id', 'client_secret', 'version');
$config = Collection::fromConfig($config, $default, $required);
$url = $config->get('url');
if (!$url) {
$munchkin = $config->get('munchkin_id');
if (!$munchkin) {
throw new \Exception('Must provide either a URL or Munchkin code.');
}
$url = sprintf('https://%s.mktorest.com', $munchkin);
}
$grantType = new Credentials($url, $config->get('client_id'), $config->get('client_secret'));
$auth = new Oauth2Plugin($grantType);
if ($config->get('bulk') === true) {
$restUrl = sprintf('%s/bulk/v%d', rtrim($url, '/'), $config->get('version'));
} else {
$restUrl = sprintf('%s/rest/v%d', rtrim($url, '/'), $config->get('version'));
}
$client = new self($restUrl, $config);
$client->addSubscriber($auth);
$client->setDescription(ServiceDescription::factory(__DIR__ . '/service.json'));
$client->setDefaultOption('headers/Content-Type', 'application/json');
return $client;
}
示例10: factory
/**
* @param array $config
* @return \Guzzle\Service\Client|BasecampClient
* @throws \Guzzle\Common\Exception\InvalidArgumentException
*/
public static function factory($config = array())
{
$default = array('base_url' => 'https://basecamp.com/{user_id}/api/{version}/', 'version' => 'v1', 'auth' => 'http', 'token' => null, 'username' => null, 'password' => null);
$required = array('user_id', 'app_name', 'app_contact');
$config = Collection::fromConfig($config, $default, $required);
$client = new self($config->get('base_url'), $config);
if ($config['auth'] === 'http') {
if (!isset($config['username'], $config['password'])) {
throw new InvalidArgumentException("Config must contain username and password when using http auth");
}
$authorization = 'Basic ' . base64_encode($config['username'] . ':' . $config['password']);
}
if ($config['auth'] === 'oauth') {
if (!isset($config['token'])) {
throw new InvalidArgumentException("Config must contain token when using oauth");
}
$authorization = sprintf('Bearer %s', $config['token']);
}
if (!isset($authorization)) {
throw new InvalidArgumentException("Config must contain valid authentication method");
}
// Attach a service description to the client
$description = ServiceDescription::factory(__DIR__ . '/Resources/service.php');
$client->setDescription($description);
// Set required User-Agent
$client->setUserAgent(sprintf('%s (%s)', $config['app_name'], $config['app_contact']));
$client->getEventDispatcher()->addListener('request.before_send', function (Event $event) use($authorization) {
$event['request']->addHeader('Authorization', $authorization);
});
return $client;
}
示例11: factory
/**
* @param array $config
* @return \Guzzle\Service\Client|BasecampClient
* @throws \Guzzle\Common\Exception\InvalidArgumentException
*/
public static function factory($config = array())
{
$default = array('base_url' => 'https://basecamp.com/', 'version' => 'v1', 'token' => null, 'user_agent' => null, 'auth_method' => 'oauth');
$required = [];
$config = Collection::fromConfig($config, $default, $required);
$client = new self($config->get('base_url'), $config);
if (empty($config['token'])) {
throw new InvalidArgumentException("Config must contain token when using oath");
}
$authorization = sprintf('Bearer %s', $config['token']);
if (!isset($authorization)) {
throw new InvalidArgumentException("Config must contain valid authentication method");
}
// Attach a service description to the client
$description = ServiceDescription::factory(__DIR__ . '/Resources/service.php');
$client->setDescription($description);
// Set required User-Agent
$client->setUserAgent($config['user_agent']);
$client->getEventDispatcher()->addListener('request.before_send', function (Event $event) use($authorization) {
$event['request']->addHeader('Authorization', $authorization);
});
// Add cache plugin
$cachePlugin = new CachePlugin(['storage' => new DefaultCacheStorage(new DoctrineCacheAdapter(new ApcCache()))]);
$client->addSubscriber($cachePlugin);
return $client;
}
示例12: import
public static function import($string, $plugin)
{
$name = strstr($string, "\$", true);
$members = explode(",", substr(strstr(strstr($string, "\$"), "#", true), 1));
$desc = str_replace("|", " ", strstr(strstr($string, "#"), "%", true));
$leaderID = 0;
foreach ($members as $num => $text) {
if (strpos($text, ":Leader")) {
$leaderID = $num;
}
}
$leader = strstr($members[$leaderID], ":", true);
$faction = new self($plugin, $name, $leader);
if (strcmp(substr(strstr($string, "%"), 1), "null") != 0) {
$home_raw = str_replace("%", "", strstr($string, "%"));
$home_array = explode("_", $home_raw);
$x = $home_array[0];
$y = $home_array[1];
$z = $home_array[2];
$levelName = $home_array[3];
$level = $plugin->getServer()->getLevelByName($levelName);
$faction->sethome(new Position($x, $y, $z, $level));
}
unset($members[$leaderID]);
foreach ($members as $num => $text) {
$player = strstr($text, ":", true);
$rank = substr(strstr($text, ":"), 1);
$faction->addPlayer($player, $rank);
}
$faction->setDescription($desc);
if ($plugin->prefs->get("Developer Mode")) {
$plugin->getServer()->getLogger()->info($plugin->formatMessage("[X] {$name}", true));
}
}
示例13: factory
public static function factory($config = array()) {
$client = new self(null, $config);
$description = ServiceDescription::factory(__DIR__ . '/descriptor.php');
$client->setDescription($description);
return $client;
}
示例14: fromReflection
/**
* fromReflection()
*
* @param Zend_Reflection_Docblock_Tag $reflectionTagReturn
* @return Zend_CodeGenerator_Php_Docblock_Tag_License
*/
public static function fromReflection(Zend_Reflection_Docblock_Tag $reflectionTagLicense)
{
$returnTag = new self();
$returnTag->setName('license');
$returnTag->setUrl($reflectionTagLicense->getUrl());
$returnTag->setDescription($reflectionTagLicense->getDescription());
return $returnTag;
}
示例15: factory
/**
* Factory method to create the client, add the service description, and set
* the user again
*
* @param array $config
*
* @return Client
*/
public static function factory($config = array())
{
$client = new self();
$description = ServiceDescription::factory(__DIR__ . '/Config/endpoints.json');
$client->setDescription($description);
$client->setUserAgent('Shelf/' . Version::VERSION, true);
return $client;
}