本文整理汇总了PHP中Object::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::set方法的具体用法?PHP Object::set怎么用?PHP Object::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Object
的用法示例。
在下文中一共展示了Object::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
/**
* 写入SESSION
* @param string $sid
* @param string $data
* @return void
*/
function write($sid, $data)
{
$m_data = array();
$m_data['card'] = $this->card;
$m_data['Data'] = $data;
return $this->memcache->set($sid, $m_data);
}
示例2: set
/**
* 设置缓存数据
*
* @param String $key 键值
* @param Mixed $value 要缓存的内容
* @param Integer $ttl 存活时间
* @return void
*/
public function set($key, $value, $ttl = CACHE_DEFAULT_EXP_TIME_TT)
{
//注: 第三个参数 memcache 与 ttserver 不一样 ; 上线后 $ttl 变为0 永远不过期
//$value = serialize($value);
//$content = array('value' => $value, 'uptime'=>time(), 'ttl' => $ttl);
// $this->mObject->set($key, $content, 0, $ttl);
$this->mObject->set($key, $value, 0, $ttl);
}
示例3: onAfterInitialise
/**
* Main dispatch method
*
* @access private
* @return boolean
*/
public function onAfterInitialise()
{
$app = JFactory::getApplication();
// Detect if current request come from a bot user agent
if ($this->isBotRequest() && $app->input->get('option') == 'com_jmap') {
$this->joomlaConfig->set('sef', false);
$_SERVER['REQUEST_METHOD'] = 'POST';
// Set dummy nobot var
$app->input->post->set('nobotsef', true);
$_POST['nobotsef'] = true;
}
}
示例4: validate
/**
* Evaluate request uri
*
* @param string $requestUri Request uri
* @param string $requestMethod Request method
*/
public function validate(string $requestUri, string $requestMethod) : bool
{
//check if route is already cached
if (($cachedRoute = $this->cache->get($requestUri)) !== false) {
//get cached route
$this->route = $cachedRoute;
return true;
}
//if route not cached, validate, if valid cache it
if (parent::validate($requestUri, $requestMethod)) {
}
//cache validated route
$this->cache->set($requestUri, $this->route);
return true;
return false;
}
示例5: _afterInit
/**
* This will decide what should happen with the return value of the initialized item
*
* @return void
* @throws Core_Main_AbstractException
*/
protected final function _afterInit($methodName, $value)
{
// If there is no value
if (null === $value) {
return;
}
// Decision tree here. There should not be many exceptions
switch ($methodName) {
case 'IncludePath':
set_include_path($value);
break;
// Store registry locally
// Store registry locally
case 'Registry':
// check interface of registry, make sure it has the right accessors (get() and set())
if (false === Core_Utility::hasInterface($value, 'Core_Interface_Registry')) {
throw new Core_Main_AbstractException(sprintf('Registry does not implement %s', $registryInterface));
}
$this->_registry = $value;
break;
default:
$this->_registry->set(strtolower($methodName), $value);
break;
}
}
示例6: set
/**
* 设置缓存
* @access public
* @param void $name 缓存名称
* @param void $value 缓存数据
* @param null $expire 缓存时间
* @return mixed
*/
public function set($name, $value, $expire = null)
{
//缓存KEY
$name = $this->options['prefix'] . $name;
//删除缓存
if (is_null($value)) {
return $this->memcacheObj->delete($name);
}
//是否压缩数据
$zip = $this->options['zip'] ? MEMCACHE_COMPRESSED : 0;
//过期时间
$expire = is_null($expire) ? $this->options['expire'] : (int) $expire;
//设置缓存
$data = $this->memcacheObj->set($name, $value, $zip, $expire);
return $data;
}
示例7: testPerformOK
function testPerformOK()
{
$object = new Object();
$object->__class_name = 'Object';
$object->set('title', $title = 'any title');
$toolkit =& Limb :: toolkit();
$command = new RegisterObjectCommand($object);
$this->assertEqual($command->perform(), LIMB_STATUS_OK);
$uow =& $toolkit->getUOW();
$this->assertTrue($uow->isNew($object));
}
示例8: onAfterInitialise
/**
* Main dispatch method
*
* @access private
* @return boolean
*/
public function onAfterInitialise()
{
$app = JFactory::getApplication();
// Avoid operations if plugin is executed in backend
if ($app->getClientId()) {
return;
}
// If Joomla 3.4+ and JMAP internal link force always the lang url param using the cookie workaround
if ($app->input->get('option') == 'com_jmap' && version_compare(JVERSION, '3.4', '>=')) {
$lang = $app->input->get('lang');
$sefs = JLanguageHelper::getLanguages('sef');
$lang_codes = JLanguageHelper::getLanguages('lang_code');
if (isset($sefs[$lang])) {
$lang_code = $sefs[$lang]->lang_code;
// Create a cookie.
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('config.cookie_domain', '');
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie(JApplication::getHash('language'), $lang_code, 86400, $cookie_path, $cookie_domain);
$app->input->cookie->set(JApplication::getHash('language'), $lang_code);
// Set the request var.
$app->input->set('language', $lang_code);
// Check if remove default prefix is active and the default language is not the current one
$defaultSiteLanguage = JComponentHelper::getParams('com_languages')->get('site', 'en-GB');
$pluginLangFilter = JPluginHelper::getPlugin('system', 'languagefilter');
$removeDefaultPrefix = @json_decode($pluginLangFilter->params)->remove_default_prefix;
if ($removeDefaultPrefix && $defaultSiteLanguage != $lang_code) {
$uri = JUri::getInstance();
$path = $uri->getPath();
// Force the language SEF code in the path
$path = $lang . '/' . ltrim($path, '/');
$uri->setPath($path);
}
}
}
// Detect if current request come from a bot user agent
if ($this->isBotRequest() && $app->input->get('option') == 'com_jmap') {
$this->joomlaConfig->set('sef', false);
$_SERVER['REQUEST_METHOD'] = 'POST';
// Set dummy nobot var
$app->input->post->set('nobotsef', true);
$_POST['nobotsef'] = true;
}
}
示例9: blogBlogContentAfterSave
/**
* blogBlogContentAfterSave
*
* @param CakeEvent $event
*/
public function blogBlogContentAfterSave(CakeEvent $event)
{
$Model = $event->subject();
$created = $event->data[0];
if ($created) {
$contentId = $Model->getLastInsertId();
} else {
$contentId = $Model->data[$Model->alias]['id'];
}
$saveData = $this->_generateContentSaveData($Model, $contentId);
if (isset($saveData['PetitBlogCustomFieldConfig']['id'])) {
// ブログ設定編集保存時に設定情報を保存する
$this->PetitBlogCustomFieldConfigModel->set($saveData);
} else {
// ブログ設定追加時に設定情報を保存する
$this->PetitBlogCustomFieldConfigModel->create($saveData);
}
if (!$this->PetitBlogCustomFieldConfigModel->save()) {
$this->log(sprintf('ID:%s のプチ・カスタムフィールド設定の保存に失敗しました。', $Model->data['PetitBlogCustomFieldConfig']['id']));
}
}
示例10: testFetch
function testFetch()
{
$toolkit =& Limb :: toolkit();
$resolver = new MockRequestResolver($this);
$toolkit->setRequestResolver('tree_based_entity', $resolver);
$resolver->tally();
$entity = new Object();
$entity->set('class_name', $class_name = 'TestArticle');
$request =& $toolkit->getRequest();
$resolver->setReturnReference('resolve', $entity, array($request));
$dao = new TreeBasedEntityDAO();
$result =& $dao->fetchRecord();
$expected_result = new Dataspace();
$expected_result->set('class_name', $class_name);
$this->assertEqual($result, $expected_result);
}
示例11: testAdd
function testAdd()
{
$obj1 = new Object();
$obj1->set('id', 1);
$obj2 = new Object();
$obj2->set('id', 2);
$arr = array($obj1);
$col = new ObjectCollection($arr);
$col->add($obj2);
$col->rewind();
$this->assertEqual($col->current(), $obj1);
$col->next();
$this->assertEqual($col->current(), $obj2);
$col->next();
$this->assertFalse($col->valid());
}
示例12: testExport
function testExport()
{
$e = new Entity();
$e->set('oid', $oid = 10);
$e->set('prop1', 'prop1');
$e->set('prop2', 'prop2');
$o1 = new Object();
$o1->set('prop1', 'prop11');
$o2 = new Object();
$o2->set('prop2', 'prop22');
$e->registerPart('part1', $o1);
$e->registerPart('part2', $o2);
$this->assertEqual($e->export(),
array('oid' => $oid,
'prop1' => 'prop1',
'prop2' => 'prop2',
'_part1_prop1' => 'prop11',
'_part2_prop2' => 'prop22'));
}
示例13: sendReviews
/**
* Send reviews to Slack
*
* @param array $reviews list of reviews to send
* @return boolean successful sending
*/
public function sendReviews($reviews)
{
if (!is_array($reviews) || !count($reviews)) {
return false;
}
if (!isset($this->slackSettings['endpoint'])) {
if ($this->logger) {
$this->logger->error('Reviewer: you should set endpoint in Slack settings');
}
return false;
}
$firstTime = !(bool) $this->storage->exists('tjournal:reviewer:init');
$config = ['username' => 'TJ Reviewer', 'icon' => 'https://i.imgur.com/GX1ASZy.png'];
if (isset($this->slackSettings['channel'])) {
$config['channel'] = $this->slackSettings['channel'];
}
$slack = new Slack($this->slackSettings['endpoint'], $config);
foreach ($reviews as $review) {
$ratingText = '';
for ($i = 1; $i <= 5; $i++) {
$ratingText .= $i <= $review['rating'] ? "★" : "☆";
}
try {
if (!$firstTime) {
$slack->attach(['fallback' => "{$ratingText} {$review['title']} — {$review['content']}", 'author_name' => $review['application']['name'], 'author_icon' => $review['application']['image'], 'author_link' => $review['application']['link'], 'color' => $review['rating'] >= 4 ? 'good' : ($review['rating'] == 3 ? 'warning' : 'danger'), 'fields' => [['title' => $review['title'], 'value' => $review['content']], ['title' => 'Rating', 'value' => $ratingText, 'short' => true], ['title' => 'Author', 'value' => "<{$review['author']['uri']}|{$review['author']['name']}>", 'short' => true], ['title' => 'Version', 'value' => $review['application']['version'], 'short' => true], ['title' => 'Country', 'value' => $review['country'], 'short' => true]]])->send();
}
$this->storage->sadd("tjournal:reviewer:reviews", $review['id']);
} catch (Exception $e) {
if ($this->logger) {
$this->logger->error('Reviewer: exception while sending reviews', ['exception' => $e]);
}
}
}
$this->storage->set('tjournal:reviewer:init', 1);
return true;
}
示例14: set
function set($key, $value)
{
$i = self::checkInt($key);
if ($i !== null && $i >= $this->length) {
$this->length = $i + 1;
}
return parent::set($key, $value);
}
示例15: testAdd
function testAdd()
{
$dao = new MockDAO($this);
$mapper = new ProxyTestMapper($this);
$proxy = new ProxyObjectCollection($dao, $mapper, new LimbHandle('Object'));
$raw_array = array(array('id' => 1));
$dao->expectOnce('fetch');
$dao->setReturnValue('fetch', $dataset = new ArrayDataSet($raw_array));
$ds1 = new DataSpace();
$ds1->import($raw_array[0]);
$mapper->expectOnce('load', array($ds1, new Object()));
$added_object = new Object();
$added_object->set('id', 2);
$proxy->add($added_object);
$proxy->rewind();
$fetched_object = new Object();
$fetched_object->set('id', 1);
$this->assertEqual($proxy->current(), $fetched_object);
$proxy->next();
$this->assertEqual($proxy->current(), $added_object);
$proxy->next();
$this->assertFalse($proxy->valid());
$dao->tally();
$mapper->tally();
}