本文整理汇总了PHP中Joomla\Registry\Registry::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::set方法的具体用法?PHP Registry::set怎么用?PHP Registry::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joomla\Registry\Registry
的用法示例。
在下文中一共展示了Registry::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onExtensionAfterSave
public function onExtensionAfterSave($context, $table, $isNew)
{
if (!($context == 'com_plugins.plugin' && $table->element == 'giftd')) {
return true;
}
$app = JFactory::getApplication();
$code = $app->getUserState('plugins.system.giftd.code', '');
$token_prefix = $app->getUserState('plugins.system.giftd.token_prefix', '');
$app->setUserState('plugins.system.giftd.code', '');
$app->setUserState('plugins.system.giftd.token_prefix', '');
if (!empty($code) || !empty($token_prefix)) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('params'))->from($db->quoteName('#__extensions'))->where($db->quoteName('element') . ' = ' . $db->quote('giftd'))->where($db->quoteName('type') . ' = ' . $db->quote('plugin'));
$params = new Registry($db->setQuery($query, 0, 1)->loadResult());
if (!empty($code)) {
$params->set('partner_code', $code);
}
if (!empty($token_prefix)) {
$params->set('partner_token_prefix', $token_prefix);
}
$query->clear()->update($db->quoteName('#__extensions'));
$query->set($db->quoteName('params') . '= ' . $db->quote((string) $params));
$query->where($db->quoteName('element') . ' = ' . $db->quote('giftd'));
$query->where($db->quoteName('type') . ' = ' . $db->quote('plugin'));
$db->setQuery($query);
$db->execute();
}
return true;
}
示例2: check
/**
* Method to perform sanity checks on the JTable instance properties to ensure
* they are safe to store in the database. Child classes should override this
* method to make sure the data they are storing in the database is safe and
* as expected before storage.
*
* @return boolean True if the instance is sane and able to be stored in the database.
*
* @since 2.5
*/
public function check()
{
try {
parent::check();
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
if (trim($this->alias) == '') {
$this->alias = $this->title;
}
$this->alias = JApplicationHelper::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') {
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
}
$params = new Registry($this->params);
$nullDate = $this->_db->getNullDate();
$d1 = $params->get('d1', $nullDate);
$d2 = $params->get('d2', $nullDate);
// Check the end date is not earlier than the start date.
if ($d2 > $nullDate && $d2 < $d1) {
// Swap the dates.
$params->set('d1', $d2);
$params->set('d2', $d1);
$this->params = (string) $params;
}
return true;
}
示例3: initializeState
/**
* Sets the state for the model object
*
* @param \JModel $model Model object
*
* @return Registry
*
* @since 2.0
*/
protected function initializeState(\JModel $model)
{
$state = new Registry();
// Load the parameters.
$params = \JComponentHelper::getParams('com_patchtester');
$state->set('github_user', $params->get('org', 'joomla'));
$state->set('github_repo', $params->get('repo', 'joomla-cms'));
return $state;
}
示例4: register
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return Container Returns the container to support chaining.
*
* @since 1.0
* @throws \RuntimeException
*/
public function register(Container $container)
{
return $container->set('BabDev\\Transifex\\Transifex', function () use($container) {
$options = new Registry();
/* @var \JTracker\Application $app */
$app = $container->get('app');
$options->set('api.username', $app->get('transifex.username'));
$options->set('api.password', $app->get('transifex.password'));
// Instantiate Transifex
return new Transifex($options);
})->alias('transifex', 'BabDev\\Transifex\\Transifex');
}
示例5: populateState
public function populateState()
{
//get states
$app = \Cobalt\Container::fetch('app');
$filter_order = $app->getUserStateFromRequest('Categories.filter_order', 'filter_order', 'c.name');
$filter_order_Dir = $app->getUserStateFromRequest('Categories.filter_order_Dir', 'filter_order_Dir', 'asc');
$state = new Registry();
//set states
$state->set('Categories.filter_order', $filter_order);
$state->set('Categories.filter_order_Dir', $filter_order_Dir);
$this->setState($state);
}
示例6: getGithub
/**
* Gets a Github object.
*
* @param Container $c A DI container.
*
* @return Github
*
* @since 2.0
*/
public function getGithub(Container $c)
{
/* @var $config Registry */
$config = $c->get('config');
/* @var $input Joomla\Input\Input */
$input = $c->get('input');
$options = new Registry();
$options->set('headers.Accept', 'application/vnd.github.html+json');
$options->set('api.username', $input->get('username', $config->get('api.username')));
$options->set('api.password', $input->get('password', $config->get('api.password')));
$options->set('api.url', $config->get('api.url'));
$github = new Github($options);
return $github;
}
示例7: getInstance
/**
* Retrieves an instance of the GitHub object
*
* @param \Joomla\Application\AbstractApplication $app Application object
* @param boolean $useBot Flag to use a bot account.
* @param string $botUser The bot account user name.
* @param string $botPassword The bot account password.
*
* @return GitHub
*
* @since 1.0
* @throws \RuntimeException
*/
public static function getInstance($app, $useBot = false, $botUser = '', $botPassword = '')
{
$options = new Registry();
// Check if we're in the web application and a token exists
if ($app instanceof \JTracker\Application) {
$session = $app->getSession();
$token = $session->get('gh_oauth_access_token');
} else {
$token = false;
}
// If a token is active in the session (web app), and we haven't been instructed to use a bot account, use that for authentication
if ($token && !$useBot) {
$options->set('gh.token', $token);
} else {
// Check if credentials are supplied
if ($botUser && $botPassword) {
$user = $botUser;
$password = $botPassword;
} else {
// Check for support for multiple accounts
$accounts = $app->get('github.accounts');
if ($accounts) {
$user = isset($accounts[0]->username) ? $accounts[0]->username : null;
$password = isset($accounts[0]->password) ? $accounts[0]->password : null;
// Store the other accounts
$options->set('api.accounts', $accounts);
} else {
// Support for a single account
$user = $app->get('github.username');
$password = $app->get('github.password');
}
}
// Add the username and password to the options object if both are set
if ($user && $password) {
// Set the options from the first account
$options->set('api.username', $user);
$options->set('api.password', $password);
}
}
// The cURL extension is required to properly work.
$transport = HttpFactory::getAvailableDriver($options, array('curl'));
// Check if we *really* got a cURL transport...
if (!$transport instanceof Curl) {
throw new \RuntimeException('Please enable cURL.');
}
$http = new Http($options, $transport);
// Instantiate the object
return new Github($options, $http);
}
示例8: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
*
* @since 3.0
*/
protected function setUp()
{
parent::setUp();
// Store the factory state so we can mock the necessary objects
$this->saveFactoryState();
JFactory::$application = $this->getMockCmsApp();
JFactory::$config = $this->getMockConfig();
JFactory::$session = $this->getMockSession();
JFactory::$language = JLanguage::getInstance('en-GB');
// Set up our mock config
$this->config = JFactory::getConfig();
$this->config->set('helpurl', 'https://help.joomla.org/proxy/index.php?option=com_help&keyref=Help{major}{minor}:{keyref}');
// Load the admin en-GB.ini language file
JFactory::getLanguage()->load('', JPATH_ADMINISTRATOR);
}
示例9: initializeGithub
/**
* Initializes the JGithub object
*
* @return \JGithub
*
* @since 2.0
*/
public static function initializeGithub()
{
$params = \JComponentHelper::getParams('com_patchtester');
$options = new Registry();
// If an API token is set in the params, use it for authentication
if ($params->get('gh_token', '')) {
$options->set('gh.token', $params->get('gh_token', ''));
} elseif ($params->get('gh_user', '') && $params->get('gh_password')) {
$options->set('api.username', $params->get('gh_user', ''));
$options->set('api.password', $params->get('gh_password', ''));
} else {
\JFactory::getApplication()->enqueueMessage(\JText::_('COM_PATCHTESTER_NO_CREDENTIALS'), 'notice');
}
return new \JGithub($options);
}
示例10: __construct
/**
* Overrides JGithub constructor to initialise the api property.
*
* @param mixed $input An optional argument to provide dependency injection for the application's
* input object. If the argument is a JInputCli object that object will become
* the application's input object, otherwise a default input object is created.
* @param mixed $config An optional argument to provide dependency injection for the application's
* config object. If the argument is a JRegistry object that object will become
* the application's config object, otherwise a default config object is created.
* @param mixed $dispatcher An optional argument to provide dependency injection for the application's
* event dispatcher. If the argument is a JDispatcher object that object will become
* the application's event dispatcher, if it is null then the default event dispatcher
* will be created based on the application's loadDispatcher() method.
*
* @see loadDispatcher()
* @since 11.1
*/
public function __construct()
{
parent::__construct();
$options = new Registry();
$options->set('headers.Accept', 'application/vnd.github.html+json');
$this->api = new Github($options);
}
示例11: onExtensionBeforeSave
public function onExtensionBeforeSave($context, $table, $isNew)
{
if (!($context == 'com_plugins.plugin' && $table->element == 'giftd')) {
return true;
}
$app = JFactory::getApplication();
$input = $app->input;
$data = $input->get('jform', array(), 'array');
$params = $data['params'];
$userId = $this->params->get('user_id', '');
$apiKey = $this->params->get('api_key', '');
if (empty($params['api_key']) && !empty($userId) || empty($params['api_key']) && !empty($apiKey)) {
$client = new Giftd_Client($userId, $apiKey);
$client->query("joomla/uninstall");
return true;
}
if (!empty($params['api_key']) && $params['api_key'] == $this->params->get('api_key') || empty($params['user_id'])) {
return true;
}
$user = JFactory::getUser();
$jconfig = JFactory::getConfig();
$data = array('email' => $user->get('email', ''), 'phone' => '', 'name' => $user->get('name', ''), 'url' => JUri::root(), 'title' => $jconfig->get('sitename', ''), 'joomla_version' => JVERSION);
$this->loadShopData($data);
$client = new Giftd_Client($params['user_id'], $params['api_key']);
$result = $client->query("joomla/install", $data);
if ($result['type'] == 'data') {
if (!empty($result['data'])) {
$requestData = $result['data'];
if (!empty($requestData['token_prefix']) && !empty($requestData['code'])) {
$code = $requestData['code'];
$token_prefix = $requestData['token_prefix'];
$this->params->set('partner_token_prefix', $token_prefix);
$this->params->set('partner_code', $code);
$this->params->set('api_key', $params['api_key']);
$this->params->set('user_id', $params['user_id']);
$this->updateJavaScript();
$tableParams = new Registry($table->params);
$tableParams->set('partner_token_prefix', $token_prefix);
$tableParams->set('partner_code', $code);
$table->params = (string) $tableParams;
}
}
} else {
$app->enqueueMessage(JText::_('PLG_SYSTEM_GIFT_ERROR_QUERY'), 'error');
}
return true;
}
示例12: display
/**
* Display function
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed
*
* @since 1.7.2
*/
public function display($tpl = null)
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
$state = $this->get('State');
$items = $this->get('Items');
$this->return = $this->get('ReturnPage');
// Get the parameters
$params = JComponentHelper::getParams('com_churchdirectory');
$params->merge($state->params);
// Check for errors.
if (count($errors = $this->get('Errors')))
{
$app->enqueueMessage(implode("\n", $errors), 'error');
return false;
}
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$mod_params = ['style' => 'xhtml'];
$contents = '';
$mod = JModuleHelper::getModule('mod_finder');
$registry = new Registry;
$registry->loadString($mod->params);
$registry->set('searchfilter', 'paramvalue');
$registry->set('show_advanced', '0');
$registry->set('opensearch', '1');
$registry->set('set_itemid', $app->input->getInt('Itemid'));
$registry->set('size-lbl', '12');
$registry->set('show_button', '1');
$registry->set('button_pos', 'right');
$mod->params = (string) $registry;
$contents .= $renderer->render($mod, $mod_params);
$this->search = $contents;
$this->renderHelper = new ChurchDirectoryRenderHelper;
$this->params = & $params;
$this->user = & $user;
$this->items = & $items;
$this->prepareDocument();
return parent::display($tpl);
}
示例13: set
/**
* Set data into the session store
*
* @param string $name Name of a variable.
* @param mixed $value Value of a variable.
*
* @return mixed Old value of a variable.
*
* @since 4.0
*/
public function set($name, $value = null)
{
if (!$this->isStarted()) {
$this->start();
}
$old = $this->data->get($name);
$this->data->set($name, $value);
return $old;
}
示例14: getAjax
public static function getAjax()
{
$module = JModuleHelper::getModule('mod_' . JFactory::getApplication()->input->get('module'));
if (empty($module)) {
return false;
}
JFactory::getLanguage()->load($module->module);
$params = new Registry($module->params);
$params->set('ajax', 0);
ob_start();
require JPATH_ROOT . '/modules/' . $module->module . '/' . $module->module . '.php';
return ob_get_clean();
}
示例15: __construct
/**
* Constructor.
*
* @param \Windwalker\DI\Container $container
* @param \CodeGenerator\IO\IOInterface $io
* @param Registry $config
*/
public function __construct(Container $container, IOInterface $io, Registry $config = null)
{
// Get item & list name
$ctrl = $config['ctrl'] ?: $io->getArgument(1);
$ctrl = explode('.', $ctrl);
$inflector = \JStringInflector::getInstance();
if (empty($ctrl[0])) {
$ctrl[0] = 'item';
}
if (empty($ctrl[1])) {
$ctrl[1] = $inflector->toPlural($ctrl[0]);
}
list($itemName, $listName) = $ctrl;
$this->replace['extension.element.lower'] = strtolower($config['element']);
$this->replace['extension.element.upper'] = strtoupper($config['element']);
$this->replace['extension.element.cap'] = ucfirst($config['element']);
$this->replace['extension.name.lower'] = strtolower($config['name']);
$this->replace['extension.name.upper'] = strtoupper($config['name']);
$this->replace['extension.name.cap'] = ucfirst($config['name']);
$this->replace['controller.list.name.lower'] = strtolower($listName);
$this->replace['controller.list.name.upper'] = strtoupper($listName);
$this->replace['controller.list.name.cap'] = ucfirst($listName);
$this->replace['controller.item.name.lower'] = strtolower($itemName);
$this->replace['controller.item.name.upper'] = strtoupper($itemName);
$this->replace['controller.item.name.cap'] = ucfirst($itemName);
// Set replace to config.
foreach ($this->replace as $key => $val) {
$config->set('replace.' . $key, $val);
}
// Set copy dir.
$config->set('dir.dest', PathHelper::get(strtolower($config['element']), $config['client']));
$config->set('dir.tmpl', GENERATOR_BUNDLE_PATH . '/Template/' . $config['extension'] . '/' . $config['template']);
$config->set('dir.src', $config->get('dir.tmpl') . '/' . $config['client']);
// Replace DS
$config['dir.dest'] = Path::clean($config['dir.dest']);
$config['dir.tmpl'] = Path::clean($config['dir.tmpl']);
$config['dir.src'] = Path::clean($config['dir.src']);
parent::__construct($container, $io, $config);
}