本文整理汇总了PHP中Registry::has方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::has方法的具体用法?PHP Registry::has怎么用?PHP Registry::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Registry
的用法示例。
在下文中一共展示了Registry::has方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: model
/**
* @param string $model
* @param string $mode
* @return bool
* @throws AException
*/
public function model($model, $mode = '')
{
//force mode alows to load models for ALL extensions to bypass extension enabled only status
$force = '';
if ($mode == 'force') {
$force = 'all';
}
$file = DIR_APP_SECTION . 'model/' . $model . '.php';
if ($this->registry->has('extensions') && ($result = $this->extensions->isExtensionResource('M', $model, $force))) {
if (is_file($file)) {
$warning = new AWarning("Extension <b>{$result['extension']}</b> override model <b>{$model}</b>");
$warning->toDebug();
}
$file = $result['file'];
}
$class = 'Model' . preg_replace('/[^a-zA-Z0-9]/', '', $model);
if (file_exists($file)) {
include_once $file;
$this->registry->set('model_' . str_replace('/', '_', $model), new $class($this->registry));
} else {
if ($mode != 'silent') {
throw new AException(AC_ERR_LOAD, 'Error: Could not load model ' . $model . ' from ' . $file);
} else {
return false;
}
}
}
示例2: __call
public function __call($method, $args)
{
if (!$this->registry->has('extensions')) {
return null;
}
array_unshift($args, $this);
$return = call_user_func_array(array($this->extensions, $method), $args);
return $return;
}
示例3: get
/**
* Данные пользователя
* @param string $key название поля в таблице
* @return string|object данные пользователя
*/
public static function get($key = null)
{
if (Registry::has('user')) {
$user = Registry::get('user');
return $key ? $user->{$key} : $user;
}
}
示例4: post_list
function post_list()
{
// only run on the first call
if (!Registry::has('rwar_post_archive')) {
// capture original article if one is set
if ($article = Registry::get('article')) {
Registry::set('original_article', $article);
}
}
if (!($posts = Registry::get('rwar_post_archive'))) {
$posts = Post::where('status', '=', 'published')->sort('created', 'desc')->get();
Registry::set('rwar_post_archive', $posts = new Items($posts));
}
if ($result = $posts->valid()) {
// register single post
Registry::set('article', $posts->current());
// move to next
$posts->next();
} else {
// back to the start
$posts->rewind();
// reset original article
Registry::set('article', Registry::get('original_article'));
// remove items
Registry::set('rwar_post_archive', false);
}
return $result;
}
示例5: get
/**
* Получение настроек
* @param string $key Имя настройки
* @return string Значение настройки
*/
public static function get($key)
{
if (!Registry::has('setting')) {
Registry::set('setting', App::arrayAssoc(self::all(), 'name', 'value'));
}
return Registry::get('setting')[$key];
}
示例6: __destruct
/**
* Destructor function
*
* Sets the previous URL to the current URL, so the that next request
* can refer to it easily and know whatthe previous request URL was.
*/
public function __destruct()
{
if (Registry::has('router')) {
$this->_zula->resetCwd();
if ($this->storePrevious === true && $this->_dispatcher->getStatusCode() != 404) {
$_SESSION['previous_url'] = $this->_router->getCurrentUrl();
}
$_SESSION['last_activity'] = time();
}
}
示例7: model
/**
* @param string $model
* @param string $mode
* @return bool
* @throws AException
*/
public function model($model, $mode = '')
{
//force mode alows to load models for ALL extensions to bypass extension enabled only status
//This might be helpful in storefront. In admin all installed extenions are available
$force = '';
if ($mode == 'force') {
$force = 'all';
}
//mode to force load storefront model
$section = DIR_APP_SECTION;
if ($mode == 'storefront') {
$section = DIR_ROOT . '/storefront/';
}
$file = $section . 'model/' . $model . '.php';
if ($this->registry->has('extensions') && ($result = $this->extensions->isExtensionResource('M', $model, $force, $mode))) {
if (is_file($file)) {
$warning = new AWarning("Extension <b>{$result['extension']}</b> override model <b>{$model}</b>");
$warning->toDebug();
}
$file = $result['file'];
}
$class = 'Model' . preg_replace('/[^a-zA-Z0-9]/', '', $model);
$obj_name = 'model_' . str_replace('/', '_', $model);
//if modal is loaded return it back
if (is_object($this->registry->get($obj_name))) {
return $this->registry->get($obj_name);
} else {
if (file_exists($file)) {
include_once $file;
$this->registry->set($obj_name, new $class($this->registry));
return $this->registry->get($obj_name);
} else {
if ($mode != 'silent') {
$backtrace = debug_backtrace();
$file_info = $backtrace[0]['file'] . ' on line ' . $backtrace[0]['line'];
throw new AException(AC_ERR_LOAD, 'Error: Could not load model ' . $model . ' from ' . $file_info);
return false;
} else {
return false;
}
}
}
}
示例8: logMessage
/**
* Main method that is called on all loggers from
* the Log class.
*
* @param string $message
* @param int $level
* @param string $file
* @param int $line
* @return bool
*/
public function logMessage($msg, $level, $file = 'unknown', $line = 0)
{
$fileName = $this->makeFileName($level);
$filePath = $this->logDir . '/' . $fileName;
if (!zula_is_writable($this->logDir)) {
return false;
}
$uid = Registry::has('session') ? $this->_session->getUserId() : 'unknown';
$msgFormat = '[%1$s] [%2$s | uid %3$s] [%4$s] -- (%5$s:%6$d) %7$s' . "\r\n";
$entry = sprintf($msgFormat, date('c'), zula_get_client_ip(), $uid, $this->levelName($level), basename($file), $line, $msg);
return error_log($entry, 3, $filePath);
}
示例9: _detect_language_xml_file
/**
* Detect file for default or extension language
* @param string $filename
* @param string $language_dir_name
* @return null|string
*/
protected function _detect_language_xml_file($filename, $language_dir_name = 'english')
{
if (empty($filename)) {
return null;
}
$file_path = $this->language_path . $language_dir_name . '/' . $filename . '.xml';
if ($this->registry->has('extensions') && ($result = $this->registry->get('extensions')->isExtensionLanguageFile($filename, $language_dir_name, $this->is_admin))) {
if (is_file($file_path)) {
$warning = new AWarning("Extension <b>{$result['extension']}</b> overrides language file <b>{$filename}</b>");
$warning->toDebug();
}
$file_path = $result['file'];
}
return $file_path;
}
示例10: hookBootstrapLoaded
/**
* Listener for 'bootstrap_loaded' hook.
* Adds in required JS files for the editor to display
*
* @return array
*/
public function hookBootstrapLoaded()
{
if ($this->loadEditor === true && Registry::has('theme')) {
foreach (new DirectoryIterator($this->_zula->getDir('js') . '/tinymce/plugins') as $file) {
if (substr($file, 0, 1) != '.' && $file->isDir()) {
$tinyMcePlugins[] = $file->getFileName();
}
}
$tinyMcePlugins = implode(',', $tinyMcePlugins);
$this->_theme->addHead('js', array(), 'var tcmEditor = {defaultFormat: "' . Editor::defaultFormat() . '", tinymcePlugins: "' . $tinyMcePlugins . '"};');
$this->_theme->addJsFile('tinymce/jquery.tinymce.js');
$this->_theme->addJsFile('js/init.js', true, 'editor');
}
return true;
}
示例11: __construct
/**
* Generates a DateTime object using the given parameters.
*
* @param string $time A string which represents the current time.
* @param string|\DateTimeZone $timezone The locale to set the timezone.
*/
public function __construct($time = 'now', $timezone = 'UTC')
{
if (Registry::has('config')) {
$timezoneString = Registry::get('config')->get('timezone');
if (!empty($timezoneString)) {
$this->timeZoneLocal = new \DateTimeZone($timezoneString);
}
}
if (!isset($this->timeZoneLocal)) {
$this->timeZoneLocal = new \DateTimeZone(SERVER_TIMEZONE);
}
if (is_string($timezone)) {
$timezone = new \DateTimeZone($timezone);
}
$this->timeZone = $timezone;
parent::__construct($time, $timezone);
}
示例12: indexSection
/**
* Check if the currently installed version is supported
* by this upgrader
*
* @return bool|string
*/
public function indexSection()
{
$_SESSION['upgradeStage'] = 1;
if (Registry::has('sql') && in_array(_PROJECT_VERSION, $this->supportedVersions)) {
if (isset($_SESSION['upgradeStage'])) {
++$_SESSION['upgradeStage'];
}
$_SESSION['project_version'] = _PROJECT_VERSION;
// Set the event and redirect to next stage
$langStr = t('Found version "%1$s" and will upgrade to "%2$s"');
$this->_event->success(sprintf($langStr, _PROJECT_VERSION, _PROJECT_LATEST_VERSION));
return zula_redirect($this->_router->makeUrl('upgrade', 'security'));
}
$langStr = t('Version %s is not supported by this upgrader');
$this->_event->error(sprintf($langStr, _PROJECT_VERSION));
if ($this->_zula->getMode() == 'cli') {
$this->_zula->setExitCode(3);
return false;
} else {
return zula_redirect($this->_router->makeUrl('index'));
}
}
示例13: logError
/**
* Logs the error that has occurred via the main Logger
* if set to log error messages.
*
* @param string $summary
* @param string $details
* @param int $level
* @return bool
*/
protected function logError($message, $level, $file = null, $line = null)
{
if ($this->logErrors && Registry::has('log')) {
return $this->_log->message($message, $level, $file, $line);
}
}
示例14: hookCntrlrPreDispatch
/**
* Add in the right RSS feed to the HTML head
*
* @param array $rData
* @return array
*/
public function hookCntrlrPreDispatch($rData)
{
if (Registry::has('theme')) {
if ($rData['module'] != 'rss' && $rData['controller'] != 'feed') {
// Get the default feed
try {
$defFeed = array();
$defFeed[] = $this->_config->get('rss/default_feed');
if (!Rss::feedExists($defFeed[0])) {
unset($defFeed[0]);
}
} catch (Config_KeyNoExist $e) {
$this->_log->message('RSS config key "rss/default_feed" does not exist, unable to add default feed to head.', Log::L_WARNING);
}
// Find all the RSS feeds for the current page
$feeds = Hooks::notifyAll('rss_insert_head', $rData['module'], $rData['controller'], $rData['section']);
if (is_array($feeds)) {
foreach (array_filter(array_merge($defFeed, $feeds)) as $feed) {
// Add all found feeds to head
$rss = new Rss($feed);
if ($rss->hasFeedInfo()) {
$details = array('rel' => 'alternate', 'type' => 'application/rss+xml', 'href' => $this->_router->makeFullUrl('rss', 'feed', $feed), 'title' => $rss->getFeedInfo('title'));
$this->_theme->addHead('link', $details);
} else {
$this->_log->message('Feed "' . $feed . '" does not have feed info set.', Log::L_WARNING);
}
}
}
}
}
return $rData;
}
示例15: router
/**
* Данные роутов
* @return object данные роутов
*/
public static function router($key)
{
if (Registry::has('router')) {
return Registry::get('router')[$key];
}
}