本文整理汇总了PHP中Symfony\Component\HttpFoundation\ParameterBag::add方法的典型用法代码示例。如果您正苦于以下问题:PHP ParameterBag::add方法的具体用法?PHP ParameterBag::add怎么用?PHP ParameterBag::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\ParameterBag
的用法示例。
在下文中一共展示了ParameterBag::add方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getParameters
/**
* Return request parameter from query or post body
*/
public function getParameters()
{
if ($this->parameters === null) {
$this->parameters = new ParameterBag($this->request->query->all());
if ($this->request->getMethod() !== Request::METHOD_GET) {
$this->parameters->add($this->request->request->all());
}
}
return $this->parameters;
}
示例2: testRemove
public function testRemove()
{
$bag = new ParameterBag(array('foo' => 'bar'));
$bag->add(array('bar' => 'bas'));
$this->assertEquals(array('foo' => 'bar', 'bar' => 'bas'), $bag->all());
$bag->remove('bar');
$this->assertEquals(array('foo' => 'bar'), $bag->all());
}
示例3: setQuery
/**
*
* @param String|Array $query
* @return \Spore\HttpFoundation\Request
* @throws \InvalidArgumentException
*/
public function setQuery($query)
{
if (is_string($query)) {
parse_str($query, $query);
}
if (!is_array($query)) {
throw new \InvalidArgumentException("Invalid argument");
}
if (empty($this->query)) {
$this->query = new ParameterBag($query);
} else {
$this->query->add($query);
}
return $this;
}
示例4: __construct
/**
* @param array $attributes
* @param array $disk
* @param array $database
*/
public function __construct(array $attributes = array(), array $disk = array(), array $database = array())
{
$this->attributes = new ParameterBag($this->attributes_default);
$this->disk = new ParameterBag($this->disk_default);
$this->database = new ParameterBag($this->database_default);
// Set all attributes
$this->attributes->add($attributes);
$this->disk->add($disk);
$this->database->add($database);
$version = is_null($this->attributes->get('version')) && $this->disk->get('is_valid') ? $this->disk->get('version') : $this->attributes->get('version');
$img = $this->attributes->get('img');
if (empty($img)) {
$this->attributes->set('img', __PS_BASE_URI__ . 'img/questionmark.png');
}
$this->attributes->set('version', $version);
$this->attributes->set('type', $this->convertType($this->get('origin_filter_value')));
// Unfortunately, we can sometime have an array, and sometimes an object.
// This is the first place where this value *always* exists
$this->attributes->set('price', (array) $this->attributes->get('price'));
}
示例5: parseConnections
protected function parseConnections($options, $defaultHost, $defaultPort)
{
if (isset($options['host']) || isset($options['port'])) {
$options['connections'][] = $options;
} elseif ($options['connection']) {
$options['connections'][] = $options['connection'];
}
/** @var ParameterBag[] $toParse */
$toParse = [];
if (isset($options['connections'])) {
foreach ((array) $options['connections'] as $alias => $conn) {
if (is_string($conn)) {
$conn = ['host' => $conn];
}
$conn += ['scheme' => 'tcp', 'host' => $defaultHost, 'port' => $defaultPort];
$conn = new ParameterBag($conn);
if ($conn->has('password')) {
$conn->set('pass', $conn->get('password'));
$conn->remove('password');
}
$conn->set('uri', Uri::fromParts($conn->all()));
$toParse[] = $conn;
}
} elseif (isset($options['save_path'])) {
foreach (explode(',', $options['save_path']) as $conn) {
$uri = new Uri($conn);
$connBag = new ParameterBag();
$connBag->set('uri', $uri);
$connBag->add(parse_query($uri->getQuery()));
$toParse[] = $connBag;
}
}
$connections = [];
foreach ($toParse as $conn) {
/** @var Uri $uri */
$uri = $conn->get('uri');
$parts = explode(':', $uri->getUserInfo(), 2);
$password = isset($parts[1]) ? $parts[1] : null;
$connections[] = ['scheme' => $uri->getScheme(), 'host' => $uri->getHost(), 'port' => $uri->getPort(), 'path' => $uri->getPath(), 'alias' => $conn->get('alias'), 'prefix' => $conn->get('prefix'), 'password' => $password, 'database' => $conn->get('database'), 'persistent' => $conn->get('persistent'), 'weight' => $conn->get('weight'), 'timeout' => $conn->get('timeout')];
}
return $connections;
}
示例6: parseConnections
protected function parseConnections($options, $defaultHost, $defaultPort, $defaultScheme = 'tcp')
{
if (isset($options['host']) || isset($options['port'])) {
$options['connections'][] = $options;
} elseif ($options['connection']) {
$options['connections'][] = $options['connection'];
}
/** @var ParameterBag[] $toParse */
$toParse = [];
if (isset($options['connections'])) {
foreach ((array) $options['connections'] as $alias => $conn) {
if (is_string($conn)) {
$conn = ['host' => $conn];
}
$conn += ['scheme' => $defaultScheme, 'host' => $defaultHost, 'port' => $defaultPort];
$conn = new ParameterBag($conn);
if ($conn->has('password')) {
$conn->set('pass', $conn->get('password'));
$conn->remove('password');
}
$conn->set('uri', Uri::fromParts($conn->all()));
$toParse[] = $conn;
}
} else {
$connections = isset($options['save_path']) ? (array) explode(',', $options['save_path']) : [];
if (empty($connections)) {
$connections[] = $defaultHost . ':' . $defaultPort;
}
foreach ($connections as $conn) {
// Default scheme if not given so parse_url works correctly.
if (!preg_match('~^\\w+://.+~', $conn)) {
$conn = $defaultScheme . '://' . $conn;
}
$uri = new Uri($conn);
$connBag = new ParameterBag();
$connBag->set('uri', $uri);
$connBag->add(Psr7\parse_query($uri->getQuery()));
$toParse[] = $connBag;
}
}
$connections = [];
foreach ($toParse as $conn) {
/** @var Uri $uri */
$uri = $conn->get('uri');
$parts = explode(':', $uri->getUserInfo(), 2);
$password = isset($parts[1]) ? $parts[1] : null;
$connections[] = ['scheme' => $uri->getScheme(), 'host' => $uri->getHost(), 'port' => $uri->getPort(), 'path' => $uri->getPath(), 'alias' => $conn->get('alias'), 'prefix' => $conn->get('prefix'), 'password' => $password, 'database' => $conn->get('database'), 'persistent' => $conn->get('persistent'), 'weight' => $conn->get('weight'), 'timeout' => $conn->get('timeout')];
}
return $connections;
}
示例7: postSequence
public static function postSequence(Application $app, Request $request, $dataType, $dataTypeAccessHash, $recordId, $property)
{
/** @var Repository $repository */
$repository = self::getRepository($app, $dataType, $dataTypeAccessHash);
$dataTypeDefinition = self::getDataTypeDefinition($app, $repository, $dataType, $dataTypeAccessHash);
if ($repository && $dataTypeDefinition) {
$items = array();
foreach ($request->request->getIterator() as $key => $value) {
$split = explode('_', $key);
if (count($split >= 3)) {
if ($split[0] == 'item') {
$nr = (int) $split[1];
$l = strlen('item_' . $nr);
$property = substr($key, $l + 1);
$items[$nr][$property] = $value;
}
}
}
$sequence = array();
if ($request->request->has('sequence')) {
$types = $request->get('type');
$i = 0;
foreach ($request->get('sequence') as $nr) {
$item = $items[$nr];
$type = $types[$i];
$clippingDefinition = $dataTypeDefinition->getClippingDefinition($type);
$bag = new ParameterBag();
$bag->add($item);
$item = $app['form']->extractFormElementValuesFromPostRequest($bag, $clippingDefinition->getFormElementDefinitions(), array());
$sequence[] = array($type => $item);
$i++;
}
}
return $app->json(array('sequence' => $sequence));
}
}
示例8: addOption
/**
* Add an option for this event
*
* @param string $key
* @param mixed $value
*/
public final function addOption($key, $value)
{
$this->options->add(array($key => $value));
}