本文整理匯總了PHP中JArrayHelper::isAssociative方法的典型用法代碼示例。如果您正苦於以下問題:PHP JArrayHelper::isAssociative方法的具體用法?PHP JArrayHelper::isAssociative怎麽用?PHP JArrayHelper::isAssociative使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JArrayHelper
的用法示例。
在下文中一共展示了JArrayHelper::isAssociative方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: set
/**
* Set a registry value.
*
* @param string $path Registry Path (e.g. joomla.content.showauthor)
* @param mixed $value Value of entry
*
* @return mixed The value of the that has been set.
*
* @since 11.1
*/
public function set($path, $values)
{
// Get the old value if exists so we can return it
if (is_array($values) && JArrayHelper::isAssociative($values) || is_object($values) && count((array) $values)) {
foreach ($values as $key => $value) {
$this->data->set("{$path}.{$key}", $value);
}
} else {
$this->data->set($path, $values);
}
return $this;
}
示例2: testIsAssociative
/**
* Test the JArrayHelper::isAssociate method.
*/
public function testIsAssociative()
{
$this->assertThat(
JArrayHelper::isAssociative(array(1,2,3)),
$this->isFalse(),
'Line: '.__LINE__.' This array should not be associative.'
);
$this->assertThat(
JArrayHelper::isAssociative(array('a' => 1, 'b' => 2, 'c' => 3)),
$this->isTrue(),
'Line: '.__LINE__.' This array should be associative.'
);
$this->assertThat(
JArrayHelper::isAssociative(array('a' => 1, 2, 'c' => 3)),
$this->isTrue(),
'Line: '.__LINE__.' This array should be associative.'
);
}
示例3: bindLevel
/**
* Method to bind data to the form for the group level.
*
* @param string $group The dot-separated form group path on which to bind the data.
* @param mixed $data An array or object of data to bind to the form for the group level.
*
* @return void
*
* @since 11.1
*/
protected function bindLevel($group, $data)
{
// Ensure the input data is an array.
settype($data, 'array');
// Process the input data.
foreach ($data as $k => $v) {
if ($this->findField($k, $group)) {
// If the field exists set the value.
$this->data->set($group . '.' . $k, $v);
} elseif (is_object($v) || JArrayHelper::isAssociative($v)) {
// If the value is an object or an associative array, hand it off to the recursive bind level method
$this->bindLevel($group . '.' . $k, $v);
}
}
}
示例4: bindData
/**
* Method to recursively bind data to a parent object.
*
* @param object $parent The parent object on which to attach the data values.
* @param mixed $data An array or object of data to bind to the parent object.
*
* @return void
* @since 1.6
*/
protected function bindData(&$parent, $data)
{
// Ensure the input data is an array.
if (is_object($data)) {
$data = get_object_vars($data);
} else {
$data = (array) $data;
}
foreach ($data as $k => $v) {
if (is_array($v) && JArrayHelper::isAssociative($v) || is_object($v)) {
$parent->{$k} = new stdClass();
$this->bindData($parent->{$k}, $v);
} else {
$parent->{$k} = $v;
}
}
}
示例5: bindLevel
/**
* Method to bind data to the form for the group level.
*
* @param string $group The dot-separated form group path on which to bind the data.
* @param mixed $data An array or object of data to bind to the form for the group level.
*
* @return void
*
* @since 11.1
*/
protected function bindLevel($group, $data)
{
// Ensure the input data is an array.
if (is_object($data)) {
if ($data instanceof Registry) {
// Handle a Registry.
$data = $data->toArray();
} elseif ($data instanceof JObject) {
// Handle a JObject.
$data = $data->getProperties();
} else {
// Handle other types of objects.
$data = (array) $data;
}
}
// Process the input data.
foreach ($data as $k => $v) {
$level = $group ? $group . '.' . $k : $k;
if ($this->findField($k, $group)) {
// If the field exists set the value.
$this->data->set($level, $v);
} elseif (is_object($v) || JArrayHelper::isAssociative($v)) {
// If the value is an object or an associative array, hand it off to the recursive bind level method.
$this->bindLevel($level, $v);
}
}
}
示例6: _prepareQueyrBetweenFiltersANDValuesAND
/**
* @since 1.1.0
*/
protected static function _prepareQueyrBetweenFiltersANDValuesAND($query)
{
$db = JFactory::getDbo();
if (JArrayHelper::isAssociative(self::$filters)) {
if (count(self::$filters) > 1) {
foreach (self::$filters as $filter => &$filter_values) {
$filter = (int) $filter;
self::_checkArg($filter_values);
if (!$filter || empty($filter_values)) {
continue;
}
while ($value = array_shift($filter_values)) {
$alias = 'c' . $value;
$and = array($db->quoteName($alias . '.element_id') . ' = ' . $db->quoteName('e.id'), $db->quoteName($alias . '.field_id') . ' = ' . $filter, $db->quoteName($alias . '.field_value_id') . ' = ' . $value);
$query->join('INNER', $db->quoteName('#__fieldsandfilters_connections', $alias) . ' ON ' . implode(' AND ', $and));
unset($and);
}
}
} else {
self::_prepareQueyrValueAssociativeArray($query);
}
} else {
self::_prepareQueyrFilterArray($query);
}
}
示例7: bindData
/**
* Method to recursively bind data to a parent object.
*
* @param object $parent The parent object on which to attach the data values.
* @param mixed $data An array or object of data to bind to the parent object.
* @param boolean $recursive True to support recursive bindData.
*
* @return void
*
* @since 1.0
*/
protected function bindData($parent, $data, $recursive = true)
{
// Ensure the input data is an array.
if (is_object($data)) {
$data = get_object_vars($data);
} else {
$data = (array) $data;
}
foreach ($data as $k => $v) {
// Modification from joomla/registry package - Using CMS JArrayHelper versus importing joomla/utilities package
if ($recursive && (is_array($v) && \JArrayHelper::isAssociative($v) || is_object($v))) {
if (!isset($parent->{$k})) {
$parent->{$k} = new \stdClass();
}
$this->bindData($parent->{$k}, $v);
} else {
$parent->{$k} = $v;
}
}
}