本文整理汇总了PHP中Joomla\Registry\Registry::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::exists方法的具体用法?PHP Registry::exists怎么用?PHP Registry::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joomla\Registry\Registry
的用法示例。
在下文中一共展示了Registry::exists方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __get
/**
* Get a global template var.
*
* @param string $key The template var key.
*
* @return mixed
*
* @since 1.0
*/
public function __get($key)
{
if ($this->globals->exists($key)) {
return $this->globals->get($key);
}
if ($this->debug) {
trigger_error('No template var: ' . $key);
}
return '';
}
示例2: has
/**
* Check whether data exists in the session store
*
* @param string $name Name of variable
*
* @return boolean True if the variable exists
*
* @since 4.0
*/
public function has($name)
{
if (!$this->isStarted()) {
$this->start();
}
return $this->data->exists($name);
}
示例3: 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;
}
$input = new Registry($data);
$output = new Registry();
// 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) {
$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);
$key = $group ? $group . '.' . $name : $name;
// Filter the value if it exists.
if ($input->exists($key)) {
$output->set($key, $this->filterField($field, $input->get($key, (string) $field['default'])));
}
}
return $output->toArray();
}
示例4: testExists
/**
* Test the Joomla\Registry\Registry::exists method.
*
* @return void
*
* @covers Joomla\Registry\Registry::exists
* @since 1.0
*/
public function testExists()
{
$a = new Registry();
$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.');
}
示例5: 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;
}
$input = new Registry($data);
$output = new Registry();
// 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) {
$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);
$key = $group ? $group . '.' . $name : $name;
// Filter the value if it exists.
if ($input->exists($key)) {
$output->set($key, $this->filterField($field, $input->get($key, (string) $field['default'])));
}
// Get the JFormField object for this field, only it knows if it is supposed to be multiple.
$jfield = $this->getField($name, $group);
// Fields supporting multiple values must be stored as empty arrays when no values are selected.
// If not, they will appear to be unset and then revert to their default value.
if ($jfield && $jfield->multiple && !$output->exists($key)) {
$output->set($key, array());
}
}
return $output->toArray();
}
示例6: has
/**
* Check whether data exists in the session store
*
* @param string $name Name of variable
* @param string $namespace Namespace to use, default to 'default'
*
* @return boolean True if the variable exists
*
* @since 11.1
*/
public function has($name, $namespace = 'default')
{
return $this->data->exists($namespace . '.' . $name);
}
示例7: testEnsureEmptyPathsDoNotExist
/**
* @testdox The Registry does not validate an empty path exists
*
* @covers Joomla\Registry\Registry::exists
*/
public function testEnsureEmptyPathsDoNotExist()
{
$a = new Registry();
$this->assertFalse($a->exists(''), 'An empty path should not exist.');
}