本文整理汇总了PHP中Ak::singleton方法的典型用法代码示例。如果您正苦于以下问题:PHP Ak::singleton方法的具体用法?PHP Ak::singleton怎么用?PHP Ak::singleton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ak
的用法示例。
在下文中一共展示了Ak::singleton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Test_of_addObserver
public function Test_of_addObserver()
{
$Observed = new ObservedPerson();
$null = null;
$Observer =& Ak::singleton('ObservedPersonObserver', $null);
$params = 'ObservedAccount';
$Auditor =& Ak::singleton('TestAuditor', $params);
$Auditor->observe($Observed);
$ObeserversReference =& $Observed->getObservers();
$ObeserversReference[0]->message = 'Hello. I come from the past';
$this->assertEqual($ObeserversReference[0]->__singleton_id, $Observer->__singleton_id);
$this->assertReference($ObeserversReference[1], $Auditor);
}
示例2: _PhpStringRecode
/**
* AkCharset::RecodeString() Pure PHP implementation
*
* @access private
* @uses _Utf8StringEncode
* @uses _Utf8StringDecode
* @see RecodeString
* @see _Utf8StringEncode
* @see _Utf8StringDecode
* @return string Recoded string if possible, otherwise it will
* return the string without modifications.
*/
function _PhpStringRecode($string, $target_charset, $origin_charset)
{
$target_charset = $this->_GetCharset($target_charset,false);
$origin_charset = $this->_GetCharset($origin_charset,false);
if((!$this->_ConversionIsNeeded($origin_charset, $target_charset)|!$this->usePhpRecoding) && !$this->isUtf8($string)){
return $string;
}
if($origin_charset=='utf8'){
include_once(AK_LIB_DIR.DS.'AkCharset'.DS.'utf8_mappings'.DS.$target_charset.'.php');
if(class_exists($target_charset)){
$mappingObject =& Ak::singleton($target_charset, $target_charset);
if(method_exists($mappingObject,'_Utf8StringDecode')){
return $mappingObject->_Utf8StringDecode($string);
}else{
return $string;
}
}else{
return $string;
}
}elseif($target_charset=='utf8'){
include_once(AK_LIB_DIR.DS.'AkCharset'.DS.'utf8_mappings'.DS.$origin_charset.'.php');
if(class_exists($origin_charset)){
$mappingObject =& Ak::singleton($origin_charset, $origin_charset);
if(method_exists($mappingObject,'_Utf8StringEncode')){
return $mappingObject->_Utf8StringEncode($string);
}else{
return $string;
}
}else{
return $string;
}
}else{
$utf8String = $this->_PhpStringRecode($string,'utf8',$origin_charset);
return $this->_PhpStringRecode($utf8String,$target_charset,'utf8');
}
}// -- end of &_PhpStringRecode -- //
示例3: func_num_args
/**
* Function for getting the singleton controller;
*
* @return AkActionController instance
*/
function &AkActionController()
{
$params = func_num_args() == 0 ? null : func_get_args();
$AkActionController =& Ak::singleton('AkActionController', $params);
return $AkActionController;
}
示例4: init
function init($options = array())
{
$default_options = array('inflector' => 'AkInflector', 'file_path' => false);
$options = array_merge($default_options, $options);
$this->_code = $options['code'];
require_once AK_LIB_DIR . DS . $options['inflector'] . '.php';
$this->_Inflector = Ak::singleton('AkInflector', $options['inflector']);
$this->options = $options;
}
示例5:
function &AkRouter()
{
$null = null;
$AkRouter =& Ak::singleton('AkRouter', $null);
return $AkRouter;
}
示例6: _phpStringRecode
/**
* AkCharset::recodeString() Pure PHP implementation
*
* @access private
* @uses _utf8StringEncode
* @uses _utf8StringDecode
* @see recodeString
* @see _utf8StringEncode
* @see _utf8StringDecode
* @return string Recoded string if possible, otherwise it will
* return the string without modifications.
*/
protected function _phpStringRecode($string, $target_charset, $origin_charset)
{
$target_charset = $this->_getCharset($target_charset, false);
$origin_charset = $this->_getCharset($origin_charset, false);
if (!$target_charset || !$origin_charset || (!$this->_conversionIsNeeded($origin_charset, $target_charset) || !$this->usePhpRecoding) && !$this->isUtf8($string)) {
return $string;
}
if ($origin_charset == 'utf8') {
require_once AK_ACTIVE_SUPPORT_DIR . DS . 'i18n' . DS . 'charset' . DS . 'utf8_mappings' . DS . $target_charset . '.php';
if (class_exists($target_charset)) {
$mappingObject =& Ak::singleton($target_charset, $target_charset);
if (method_exists($mappingObject, '_utf8StringDecode')) {
return $mappingObject->_utf8StringDecode($string);
} else {
return $string;
}
} else {
return $string;
}
} elseif ($target_charset == 'utf8') {
require_once AK_ACTIVE_SUPPORT_DIR . DS . 'i18n' . DS . 'charset' . DS . 'utf8_mappings' . DS . $origin_charset . '.php';
if (class_exists($origin_charset)) {
$mappingObject =& Ak::singleton($origin_charset, $origin_charset);
if (method_exists($mappingObject, '_utf8StringEncode')) {
return $mappingObject->_utf8StringEncode($string);
} else {
return $string;
}
} else {
return $string;
}
} else {
$utf8String = $this->_phpStringRecode($string, 'utf8', $origin_charset);
return $this->_phpStringRecode($utf8String, $target_charset, 'utf8');
}
}
示例7: _PhpStringRecode
/**
* AkCharset::RecodeString() Pure PHP implementation
*
* @access private
* @uses _Utf8StringEncode
* @uses _Utf8StringDecode
* @see RecodeString
* @see _Utf8StringEncode
* @see _Utf8StringDecode
* @return string Recoded string if possible, otherwise it will
* return the string without modifications.
*/
function _PhpStringRecode($string, $target_charset, $origin_charset)
{
$this->_originCharset = $origin_charset;
$this->_error = false;
$target_charset = $this->_GetCharset($target_charset, false);
$origin_charset = $this->_GetCharset($origin_charset, false);
if (empty($origin_charset)) {
$this->_error = true;
return $string;
}
if (!$this->_ConversionIsNeeded($origin_charset, $target_charset) | !$this->usePhpRecoding && !$this->isUtf8($string)) {
return $string;
}
if ($origin_charset == 'utf8') {
include_once AK_LIB_DIR . DS . 'AkCharset' . DS . 'utf8_mappings' . DS . $target_charset . '.php';
if (class_exists($target_charset)) {
$mappingObject =& Ak::singleton($target_charset, $target_charset);
if (method_exists($mappingObject, '_Utf8StringDecode')) {
return $mappingObject->_Utf8StringDecode($string);
} else {
return $string;
}
} else {
return $string;
}
} elseif ($target_charset == 'utf8') {
@(include_once AK_LIB_DIR . DS . 'AkCharset' . DS . 'utf8_mappings' . DS . Ak::sanitize_include($origin_charset, 'paranoid') . '.php');
if (class_exists($origin_charset)) {
$mappingObject =& Ak::singleton($origin_charset, $origin_charset);
if (method_exists($mappingObject, '_Utf8StringEncode')) {
return $mappingObject->_Utf8StringEncode($string);
} else {
return $string;
}
} else {
return $string;
}
} else {
$utf8String = $this->_PhpStringRecode($string, 'utf8', $origin_charset);
return $this->_PhpStringRecode($utf8String, $target_charset, 'utf8');
}
}
示例8: _init
function _init($url, $constants = array(), $controllerVars = array())
{
$this->_reset();
$this->_response = null;
$this->_cacheHeaders = array();
$this->_setConstants($constants);
$parts = parse_url($url);
$_REQUEST['ak'] = isset($parts['path']) ? $parts['path'] : '/';
$_SERVER['AK_HOST'] = isset($parts['host']) ? $parts['host'] : 'localhost';
$cache_settings = Ak::getSettings('caching', false);
if ($cache_settings['enabled']) {
require_once AK_LIB_DIR . DS . 'AkActionController' . DS . 'AkCacheHandler.php';
$null = null;
$pageCache =& Ak::singleton('AkCacheHandler', $null);
$pageCache->init($null, $cache_settings);
if ($cachedPage = $pageCache->getCachedPage()) {
static $_cachedHeaders = array();
ob_start();
global $sendHeaders, $returnHeaders, $exit;
$sendHeaders = false;
$returnHeaders = true;
$exit = false;
$headers = (include $cachedPage);
//$headers = $cachedPage->render(false,false,true);
$this->_response = ob_get_clean();
if (is_array($headers)) {
$this->_cacheHeaders = $headers;
}
return true;
}
}
require_once AK_LIB_DIR . DS . 'AkUnitTest' . DS . 'AkTestDispatcher.php';
$this->Dispatcher =& new AkTestDispatcher($controllerVars);
}
示例9: _instantiateDefaultObserver
protected function _instantiateDefaultObserver()
{
$default_observer_name = $this->getModelName() . 'Observer';
if (class_exists($default_observer_name)) {
Ak::singleton($default_observer_name, $this);
}
}
示例10: empty
function &AkResponse()
{
$null = null;
$AkResponse =& Ak::singleton('AkResponse', $null);
AK_LOG_EVENTS && empty($AkResponse->_Logger) ? $AkResponse->_Logger =& Ak::getLogger() : null;
return $AkResponse;
}
示例11: _getCachedPage
function _getCachedPage($path)
{
$controller=$this->getController();
if ($controller) {
$cachedPage = $controller->getCachedPage($path);
} else {
$pageCache = &Ak::singleton('AkCacheHandler',$null);
$null = null;
$pageCache->init($null, 'file');
$cachedPage=$pageCache->getCachedPage($path);
}
return $cachedPage;
}
示例12: recode
static function recode($text, $output_string_encoding = null, $input_string_encoding = null, $recoding_engine = null)
{
$input_string_encoding = empty($input_string_encoding) ? Ak::encoding() : $input_string_encoding;
$Charset = Ak::singleton('AkCharset', $text);
return $Charset->recodeString($text, $output_string_encoding, $input_string_encoding, $recoding_engine);
}
示例13: _initCacheHandler
/**
* ########################################################################
* #
* # Modules
* #
* ########################################################################
*/
public function _initCacheHandler()
{
// TODOARNO
$cache_settings = Ak::getSettings('caching', false);
if ($cache_settings['enabled']) {
$null = null;
$this->_CacheHandler = Ak::singleton('AkCacheHandler', $null);
$this->_CacheHandler->init($this);
}
}
示例14: var_dump
function &AkRequest()
{
var_dump('function AkRequest() should not be used, anymore. Do you need it?');
$null = null;
$AkRequest =& Ak::singleton('AkRequest', $null);
return $AkRequest;
}
示例15: fromJson
/**
* Converts a JSON representation string into a PHP value.
*/
function fromJson($json_string)
{
require_once AK_VENDOR_DIR . DS . 'pear' . DS . 'Services' . DS . 'JSON.php';
$use = 0;
$json =& Ak::singleton('Services_JSON', $use);
return $json->decode($json_string);
}