/**
  * 写入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);
 }
Ejemplo n.º 2
0
 /**
  * 设置缓存数据
  * 
  * @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);
 }
Ejemplo n.º 3
0
 /**
  * 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;
     }
 }
Ejemplo n.º 4
0
 /**
  * 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;
 }
Ejemplo n.º 5
0
 /**
  * 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;
     }
 }
Ejemplo n.º 6
0
 /**
  * 设置缓存
  * @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;
 }
  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));
  }
Ejemplo n.º 8
0
 /**
  * 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;
     }
 }
 /**
  * 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']));
     }
 }
  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);
  }
  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());
  }
Ejemplo n.º 12
0
  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'));

  }
Ejemplo n.º 13
0
 /**
  * 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;
 }
Ejemplo n.º 14
0
 function set($key, $value)
 {
     $i = self::checkInt($key);
     if ($i !== null && $i >= $this->length) {
         $this->length = $i + 1;
     }
     return parent::set($key, $value);
 }
  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();
  }
Ejemplo n.º 16
0
 /**
  * 设置缓存数据
  * 
  * @param String $key 键值
  * @param Mixed $value 要缓存的内容
  * @param Integer $ttl 存活时间
  * @return void
  */
 public function set($key, $value, $ttl = CACHE_DEFAULT_EXP_TIME_REDIS)
 {
     $this->mObject->set($key, serialize($value), $ttl);
 }
  function testDelete()
  {
    $mapper = new ObjectMapper();
    $object = new Object();
    $object->__class_name = 'Object';

    $this->db->insert('sys_class', array('id' => $class_id = 5,
                                         'name' => $object->__class_name));

    $this->db->insert('sys_object', array('oid' => $id1 = 1,
                                         'class_id' => $class_id));

    $this->db->insert('sys_object', array('oid' => $id2 = 2,
                                         'class_id' => $class_id));


    $object->set('oid', $id1);
    $object->set('class_id', $class_id);

    $mapper->delete($object);

    $rs =& $this->db->select('sys_class');
    $classes = $rs->getArray();
    $this->assertEqual(sizeof($classes), 1);

    $rs =& $this->db->select('sys_object');
    $objects = $rs->getArray();
    $this->assertEqual(sizeof($objects), 1);

    $this->assertEqual($objects[0]['oid'], $id2);
    $this->assertEqual($objects[0]['class_id'], $class_id);
  }
Ejemplo n.º 18
0
 /**
  * 写入SESSION
  * @param string $sid
  * @param string $data
  * @return void
  */
 function write($sid, $data)
 {
     return $this->redis->set($sid, $this->card . '|#|' . $data);
 }
Ejemplo n.º 19
0
 /**
  * Sets a definition on the un-compiled container
  *
  * @param String $id
  * @param Object $service
  * @param String $scope
  * @return void
  * @author Dan Cox
  */
 public function set($id, $service, $scope = ContainerBuilder::SCOPE_CONTAINER)
 {
     static::$container->set($id, $service, $scope);
 }
Ejemplo n.º 20
0
 /**
  * Route request handling ObjectResult hooks
  *
  * @param   ObjectResult    $route  An implementation of ObjectResultInterface
  * @return  string                  Content (stuff that will go on screen)
  */
 private function route(ObjectResultInterface $route)
 {
     // Starting from the routing instance, select the relative level2 hook
     // This means event engine will fire a dispatcher.[routetype] event
     // In case of wrong instance, create an ObjectError (500, null) instance
     if ($route instanceof ObjectSuccess) {
         $hook = "dispatcher.route";
     } else {
         if ($route instanceof ObjectError) {
             $hook = "dispatcher.error";
         } else {
             if ($route instanceof ObjectRedirect) {
                 $hook = "dispatcher.redirect";
             } else {
                 $hook = "dispatcher.error";
                 $route = new ObjectError();
             }
         }
     }
     // Fire first hook, a generic "dispatcher.result", Object Type independent
     $fork = $this->events->fire("dispatcher.result", "RESULT", $route);
     if ($fork instanceof \Comodojo\Dispatcher\ObjectResult\ObjectResultInterface) {
         $route = $fork;
     }
     // Fire second hook (level2), as specified above
     $fork = $this->events->fire($hook, "RESULT", $route);
     if ($fork instanceof \Comodojo\Dispatcher\ObjectResult\ObjectResultInterface) {
         $route = $fork;
     }
     // Now select and fire last hook (level3)
     // This means that event engine will fire something like "dispatcher.route.200"
     // or "dispatcher.error.500"
     $fork = $this->events->fire($hook . "." . $route->getStatusCode(), "RESULT", $route);
     if ($fork instanceof \Comodojo\Dispatcher\ObjectResult\ObjectResultInterface) {
         $route = $fork;
     }
     // Fire special event, it may modify result
     $fork = $this->events->fire("dispatcher.result.#", "RESULT", $route);
     if ($fork instanceof \Comodojo\Dispatcher\ObjectResult\ObjectResultInterface) {
         $route = $fork;
     }
     // After hooks:
     // - store cache
     // - start composing header
     // - return result
     $cache = $route instanceof \Comodojo\Dispatcher\ObjectResult\ObjectSuccess ? $this->serviceroute->getCache() : null;
     if ($this->request_method == "GET" and ($cache == "SERVER" or $cache == "BOTH") and $this->result_comes_from_cache == false and $route instanceof \Comodojo\Dispatcher\ObjectResult\ObjectSuccess) {
         $this->cacher->set($this->service_url, $route);
     }
     $this->header->free();
     if ($cache == "CLIENT" or $cache == "BOTH") {
         $this->header->setClientCache($this->serviceroute->getTtl());
     }
     $this->header->setContentType($route->getContentType(), $route->getCharset());
     foreach ($route->getHeaders() as $header => $value) {
         $this->header->set($header, $value);
     }
     $message = $route->getContent();
     $this->header->compose($route->getStatusCode(), strlen($message), $route->getLocation());
     # ><!/\!°>
     // Return the content (stuff that will go on screen)
     return $message;
 }
Ejemplo n.º 21
0
 /**
  * @param Object $obj
  */
 static function eventify($obj)
 {
     $obj->set('on', self::$on);
     $obj->set('emit', self::$emit);
 }
Ejemplo n.º 22
0
 /**
  * Heart of the Controller. This is where all the action takes place
  *
  *   - The rows are fetched and stored depending on the type of output needed
  *
  *   - For export/printing all rows are selected.
  *
  *   - for displaying on screen paging parameters are used to display the
  *     required rows.
  *
  *   - also depending on output type of session or template rows are appropriately stored in session
  *     or template variables are updated.
  *
  *
  * @return void
  *
  */
 function run()
 {
     // get the column headers
     $columnHeaders =& $this->_object->getColumnHeaders($this->_action, $this->_output);
     // we need to get the rows if we are exporting or printing them
     if ($this->_output == self::EXPORT || $this->_output == self::SCREEN) {
         // get rows (without paging criteria)
         $rows = self::getRows($this);
         if ($this->_output == self::EXPORT) {
             // export the rows.
             CRM_Core_Report_Excel::writeCSVFile($this->_object->getExportFileName(), $columnHeaders, $rows);
             exit(1);
         } else {
             // assign to template and display them.
             self::$_template->assign_by_ref('rows', $rows);
             self::$_template->assign_by_ref('columnHeaders', $columnHeaders);
         }
     } else {
         // output requires paging/sorting capability
         $rows = self::getRows($this);
         $rowsEmpty = count($rows) ? false : true;
         $qill = $this->getQill();
         $summary = $this->getSummary();
         // if we need to store in session, lets update session
         if ($this->_output & self::SESSION) {
             $this->_store->set("{$this->_prefix}columnHeaders", $columnHeaders);
             $this->_store->set("{$this->_prefix}rows", $rows);
             $this->_store->set("{$this->_prefix}rowCount", $this->_total);
             $this->_store->set("{$this->_prefix}rowsEmpty", $rowsEmpty);
             $this->_store->set("{$this->_prefix}qill", $qill);
             $this->_store->set("{$this->_prefix}summary", $summary);
         } else {
             self::$_template->assign_by_ref("{$this->_prefix}pager", $this->_pager);
             self::$_template->assign_by_ref("{$this->_prefix}sort", $this->_sort);
             self::$_template->assign_by_ref("{$this->_prefix}columnHeaders", $columnHeaders);
             self::$_template->assign_by_ref("{$this->_prefix}rows", $rows);
             self::$_template->assign("{$this->_prefix}rowsEmpty", $rowsEmpty);
             self::$_template->assign("{$this->_prefix}qill", $qill);
             self::$_template->assign("{$this->_prefix}summary", $summary);
         }
         // always store the current pageID and sortID
         $this->_store->set($this->_prefix . CRM_Utils_Pager::PAGE_ID, $this->_pager->getCurrentPageID());
         $this->_store->set($this->_prefix . CRM_Utils_Sort::SORT_ID, $this->_sort->getCurrentSortID());
         $this->_store->set($this->_prefix . CRM_Utils_Sort::SORT_DIRECTION, $this->_sort->getCurrentSortDirection());
         $this->_store->set($this->_prefix . CRM_Utils_Sort::SORT_ORDER, $this->_sort->orderBy());
         $this->_store->set($this->_prefix . CRM_Utils_Pager::PAGE_ROWCOUNT, $this->_pager->_perPage);
     }
 }
Ejemplo n.º 23
0
 /**
  * @return Object
  */
 function getDescriptor()
 {
     $result = new Object();
     $result->set('value', $this->value);
     $result->set('writable', $this->writable);
     $result->set('enumerable', $this->enumerable);
     $result->set('configurable', $this->configurable);
     return $result;
 }
Ejemplo n.º 24
0
 function write()
 {
     return $this->redis->set($this->session_id, serialize($this->items));
 }
 /**
  * Heart of the Controller. This is where all the action takes place
  *
  *   - The rows are fetched and stored depending on the type of output needed
  *
  *   - For export/printing all rows are selected.
  *
  *   - for displaying on screen paging parameters are used to display the
  *     required rows.
  *
  *   - also depending on output type of session or template rows are appropriately stored in session
  *     or template variables are updated.
  *
  *
  * @return void
  *
  */
 function run()
 {
     // get the column headers
     $columnHeaders =& $this->_object->getColumnHeaders($this->_action, $this->_output);
     $contextArray = explode('_', get_class($this->_object));
     $contextName = strtolower($contextArray[1]);
     // fix contribute and member
     if ($contextName == 'contribute') {
         $contextName = 'contribution';
     } elseif ($contextName == 'member') {
         $contextName = 'membership';
     }
     // we need to get the rows if we are exporting or printing them
     if ($this->_output == self::EXPORT || $this->_output == self::SCREEN) {
         // get rows (without paging criteria)
         $rows = self::getRows($this);
         CRM_Utils_Hook::searchColumns($contextName, $columnHeaders, $rows, $this);
         if ($this->_output == self::EXPORT) {
             // export the rows.
             CRM_Core_Report_Excel::writeCSVFile($this->_object->getExportFileName(), $columnHeaders, $rows);
             CRM_Utils_System::civiExit();
         } else {
             // assign to template and display them.
             self::$_template->assign_by_ref('rows', $rows);
             self::$_template->assign_by_ref('columnHeaders', $columnHeaders);
         }
     } else {
         // output requires paging/sorting capability
         $rows = self::getRows($this);
         CRM_Utils_Hook::searchColumns($contextName, $columnHeaders, $rows, $this);
         $rowsEmpty = count($rows) ? FALSE : TRUE;
         $qill = $this->getQill();
         $summary = $this->getSummary();
         // if we need to store in session, lets update session
         if ($this->_output & self::SESSION) {
             $this->_store->set("{$this->_prefix}columnHeaders", $columnHeaders);
             if ($this->_dynamicAction) {
                 $this->_object->removeActions($rows);
             }
             $this->_store->set("{$this->_prefix}rows", $rows);
             $this->_store->set("{$this->_prefix}rowCount", $this->_total);
             $this->_store->set("{$this->_prefix}rowsEmpty", $rowsEmpty);
             $this->_store->set("{$this->_prefix}qill", $qill);
             $this->_store->set("{$this->_prefix}summary", $summary);
         } else {
             self::$_template->assign_by_ref("{$this->_prefix}pager", $this->_pager);
             self::$_template->assign_by_ref("{$this->_prefix}sort", $this->_sort);
             self::$_template->assign_by_ref("{$this->_prefix}columnHeaders", $columnHeaders);
             self::$_template->assign_by_ref("{$this->_prefix}rows", $rows);
             self::$_template->assign("{$this->_prefix}rowsEmpty", $rowsEmpty);
             self::$_template->assign("{$this->_prefix}qill", $qill);
             self::$_template->assign("{$this->_prefix}summary", $summary);
         }
         // always store the current pageID and sortID
         $this->_store->set($this->_prefix . CRM_Utils_Pager::PAGE_ID, $this->_pager->getCurrentPageID());
         $this->_store->set($this->_prefix . CRM_Utils_Sort::SORT_ID, $this->_sort->getCurrentSortID());
         $this->_store->set($this->_prefix . CRM_Utils_Sort::SORT_DIRECTION, $this->_sort->getCurrentSortDirection());
         $this->_store->set($this->_prefix . CRM_Utils_Sort::SORT_ORDER, $this->_sort->orderBy());
         $this->_store->set($this->_prefix . CRM_Utils_Pager::PAGE_ROWCOUNT, $this->_pager->_perPage);
     }
 }
Ejemplo n.º 26
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testSettingPausesDirectly()
 {
     $P = new Pauses();
     $T = new Object();
     $T->set(Object::PAUSES, $P->asString());
 }
Ejemplo n.º 27
0
 /**
  * @see	\herosphp\session\interfaces\ISession::write().
  */
 public static function write($sessionId, $data)
 {
     self::$handler->set($sessionId, $data, self::$config['gc_maxlifetime']);
 }
Ejemplo n.º 28
0
Module::define('request', function () {
    $SERVER = isset($_SERVER) ? $_SERVER : array();
    $headers = null;
    $methods = array('getMethod' => function () use(&$SERVER) {
        return isset($SERVER['REQUEST_METHOD']) ? $SERVER['REQUEST_METHOD'] : 'GET';
    }, 'getURL' => function () use(&$SERVER) {
        return isset($SERVER['REQUEST_URI']) ? $SERVER['REQUEST_URI'] : '/';
    }, 'getHeaders' => function () use(&$SERVER, &$headers) {
        if ($headers === null) {
            $headers = new Object();
            foreach ($SERVER as $key => $value) {
                if (substr($key, 0, 5) === 'HTTP_') {
                    $key = strtolower(substr($key, 5));
                    $key = str_replace('_', '-', $key);
                    $headers->set($key, $value);
                }
            }
        }
        return $headers;
    }, 'getRemoteAddress' => function () use(&$SERVER) {
        return isset($SERVER['REMOTE_ADDR']) ? $SERVER['REMOTE_ADDR'] : '127.0.0.1';
    }, 'read' => function ($bytes) {
        throw new Ex(Error::create('not implemented: Request.read()'));
    });
    $request = new Object();
    $request->setMethods($methods, true, false, true);
    return $request;
});
Module::define('response', function () {
    $methods = array('writeHead' => function ($statusCode, $statusReason, $headers) {
Ejemplo n.º 29
0
 /**
  * 写入SESSION
  * @param string $sid
  * @param string $data
  * @return mixed
  */
 public function write($sid, $data)
 {
     return $this->memcache->set($sid, $data);
 }
Ejemplo n.º 30
0
 /**
  * inject the missing Application and Profile class definitions
  *
  * @return void
  * @author Dan Cox
  */
 public function injectDependencies()
 {
     $this->DIInstance();
     $this->DI->set('application', $this->App);
     $this->DI->set('profile', $this->App->profile);
 }