本文整理汇总了PHP中JRegistry::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP JRegistry::exists方法的具体用法?PHP JRegistry::exists怎么用?PHP JRegistry::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JRegistry
的用法示例。
在下文中一共展示了JRegistry::exists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testExists
/**
* Test the JReigstry::exists method.
*/
public function testExists()
{
$a = new JRegistry();
$a->set('foo', 'bar1');
$a->set('config.foo', 'bar2');
$a->set('deep.level.foo', 'bar3');
$this->assertThat($a->exists('foo'), $this->isTrue(), 'Line: ' . __LINE__ . ' The path should exist, returning true.');
$this->assertThat($a->exists('config.foo'), $this->isTrue(), 'Line: ' . __LINE__ . ' The path should exist, returning true.');
$this->assertThat($a->exists('deep.level.foo'), $this->isTrue(), 'Line: ' . __LINE__ . ' The path should exist, returning true.');
$this->assertThat($a->exists('deep.level.bar'), $this->isFalse(), 'Line: ' . __LINE__ . ' The path should not exist, returning false.');
$this->assertThat($a->exists('bar.foo'), $this->isFalse(), 'Line: ' . __LINE__ . ' The path should not exist, returning false.');
}
示例2: setRegistrationField
private function setRegistrationField($name, $value)
{
$app = JFactory::getApplication();
$cs = $app->getUserState('com_users.registration.data');
$state = new JRegistry();
$state->loadArray($cs);
if (!$state->exists($name)) {
JFactory::getApplication()->setUserState('com_users.registration.data.' . $name, $value);
}
}
示例3: patch
/**
* Method to send the PATCH command to the server.
*
* @param string $url Path to the resource.
* @param mixed $data Either an associative array or a string to be sent with the request.
* @param array $headers An array of name-value pairs to include in the header of the request.
* @param integer $timeout Read timeout in seconds.
*
* @return BDHttpResponse
*
* @since 1.0
*/
public function patch($url, $data, array $headers = null, $timeout = null)
{
// Look for headers set in the options.
$temp = (array) $this->options->get('headers');
foreach ($temp as $key => $val) {
if (!isset($headers[$key])) {
$headers[$key] = $val;
}
}
// Look for timeout set in the options.
if ($timeout === null && $this->options->exists('timeout')) {
$timeout = $this->options->get('timeout');
}
return $this->transport->request('PATCH', new JUri($url), $data, $headers, $timeout, $this->options->get('userAgent', null));
}
示例4: filter
/**
* Method to filter the form data.
*
* @param array $data An array of field values to filter.
* @param string $group The dot-separated form group path on which to filter the fields.
*
* @return mixed Array or false.
*
* @since 11.1
*/
public function filter($data, $group = null)
{
// Make sure there is a valid JForm XML document.
if (!$this->xml instanceof SimpleXMLElement) {
return false;
}
// Initialise variables.
$input = new JRegistry($data);
$output = new JRegistry();
// Get the fields for which to filter the data.
$fields = $this->findFieldsByGroup($group);
if (!$fields) {
// PANIC!
return false;
}
// Filter the fields.
foreach ($fields as $field) {
// Initialise variables.
$name = (string) $field['name'];
// Get the field groups for the element.
$attrs = $field->xpath('ancestor::fields[@name]/@name');
$groups = array_map('strval', $attrs ? $attrs : array());
$group = implode('.', $groups);
// Get the field value from the data input.
if ($group) {
// Filter the value if it exists.
if ($input->exists($group . '.' . $name)) {
$output->set($group . '.' . $name, $this->filterField($field, $input->get($group . '.' . $name, (string) $field['default'])));
}
} else {
// Filter the value if it exists.
if ($input->exists($name)) {
$output->set($name, $this->filterField($field, $input->get($name, (string) $field['default'])));
}
}
}
return $output->toArray();
}
示例5: migrateProfilePluginSettings612
private function migrateProfilePluginSettings612()
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// fixed PHP notice from invalid query
$query->select("setting,value")->from($db->qn("#__jfbconnect_config"))->where($db->qn('setting') . " LIKE " . $db->q("profile_%"))->order('setting');
$rows = $db->setQuery($query)->loadObjectList();
if (!empty($rows)) {
require_once JPATH_ADMINISTRATOR . '/components/com_jfbconnect/models/config.php';
$configModel = new JFBConnectModelConfig();
foreach ($rows as $row) {
$values = explode("_", $row->setting);
$pluginName = $values[1];
$settings = new JRegistry();
$settings->loadString($row->value);
if ($settings->exists('field_map') && $settings->exists('field_map.facebook')) {
$fieldMap = clone $settings->get('field_map');
foreach ($fieldMap->facebook as $key => $value) {
if ($value == "sex") {
$fieldMap->facebook->{$key} = "gender";
}
if ($value == "profile_url") {
$fieldMap->facebook->{$key} = "link";
}
if ($value == "about_me") {
$fieldMap->facebook->{$key} = "bio";
}
if ($value == "tv") {
$fieldMap->facebook->{$key} = "television";
}
if (in_array($value, array("hometown_location.city", "hometown_location.state", "hometown_location.country"))) {
$fieldMap->facebook->{$key} = "hometown.name";
}
if (in_array($value, array("current_location.city", "current_location.state", "current_location.country"))) {
$fieldMap->facebook->{$key} = "location.name";
}
}
$settings->set("field_map", null);
$settings->set("field_map", $fieldMap);
$configModel->update('profile_' . $pluginName, $settings->toString());
}
}
}
}