本文整理汇总了PHP中Drupal\Component\Utility\NestedArray::unsetValue方法的典型用法代码示例。如果您正苦于以下问题:PHP NestedArray::unsetValue方法的具体用法?PHP NestedArray::unsetValue怎么用?PHP NestedArray::unsetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Component\Utility\NestedArray
的用法示例。
在下文中一共展示了NestedArray::unsetValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clear
/**
* Unsets a value in this configuration object.
*
* @param string $key
* Name of the key whose value should be unset.
*
* @return $this
* The configuration object.
*/
public function clear($key)
{
$parts = explode('.', $key);
if (count($parts) == 1) {
unset($this->data[$key]);
} else {
NestedArray::unsetValue($this->data, $parts);
}
return $this;
}
示例2: removeDestinationProperty
/**
* Removes destination property.
*
* @param string $property
* The name of the destination property.
*/
public function removeDestinationProperty($property)
{
unset($this->rawDestination[$property]);
NestedArray::unsetValue($this->destination, explode(static::PROPERTY_SEPARATOR, $property));
}
示例3: unsetValue
/**
* Implements \Drupal\Core\Form\FormStateInterface::unsetValue()
*/
public function unsetValue($key)
{
NestedArray::unsetValue($this->getValues(), (array) $key);
return $this;
}
示例4: setOverrideValue
/**
* Overrides the specified library asset.
*
* @param array $library
* The containing library definition.
* @param array $sub_key
* An array containing the sub-keys specifying the library asset, e.g.
* @code['js']@endcode or @code['css', 'component']@endcode
* @param array $overrides
* Specifies the overrides, this is an array where the key is the asset to
* be overridden while the value is overriding asset.
*/
protected function setOverrideValue(array &$library, array $sub_key, array $overrides, $theme_path)
{
foreach ($overrides as $original => $replacement) {
// Get the attributes of the asset to be overridden. If the key does
// not exist, then throw an exception.
$key_exists = NULL;
$parents = array_merge($sub_key, [$original]);
// Save the attributes of the library asset to be overridden.
$attributes = NestedArray::getValue($library, $parents, $key_exists);
if ($key_exists) {
// Remove asset to be overridden.
NestedArray::unsetValue($library, $parents);
// No need to replace if FALSE is specified, since that is a removal.
if ($replacement) {
// Ensure the replacement path is relative to drupal root.
$replacement = $this->resolveThemeAssetPath($theme_path, $replacement);
$new_parents = array_merge($sub_key, [$replacement]);
// Replace with an override if specified.
NestedArray::setValue($library, $new_parents, $attributes);
}
}
}
}
示例5: testUnsetValue
/**
* Tests unsetting nested array values.
*
* @covers ::unsetValue
*/
public function testUnsetValue()
{
// Verify unsetting a non-existing nested element throws no errors and the
// non-existing key is properly reported.
$key_existed = NULL;
$parents = $this->parents;
$parents[] = 'foo';
NestedArray::unsetValue($this->form, $parents, $key_existed);
$this->assertTrue(isset($this->form['details']['element']['#value']), 'Outermost nested element key still exists.');
$this->assertFalse($key_existed, 'Non-existing key not found.');
// Verify unsetting a nested element.
$key_existed = NULL;
NestedArray::unsetValue($this->form, $this->parents, $key_existed);
$this->assertFalse(isset($this->form['details']['element']), 'Removed nested element not found.');
$this->assertTrue($key_existed, 'Existing key was found.');
}
示例6: clear
public function clear($property)
{
NestedArray::unsetValue($this->data, $this->toKey($property));
return $this;
}