51 lines
1.1 KiB
Plaintext
51 lines
1.1 KiB
Plaintext
|
/**
|
||
|
* The Request Class.
|
||
|
*
|
||
|
* @var RequestBuilder
|
||
|
* @since 3.2.0
|
||
|
*/
|
||
|
protected RequestBuilder $requestbuilder;
|
||
|
|
||
|
/**
|
||
|
* Constructor.
|
||
|
*
|
||
|
* @param RequestBuilder $requestbuilder The Request Class.
|
||
|
*
|
||
|
* @since 3.2.0
|
||
|
*/
|
||
|
public function __construct(RequestBuilder $requestbuilder)
|
||
|
{
|
||
|
$this->requestbuilder = $requestbuilder;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Set the request values
|
||
|
*
|
||
|
* @param string $view
|
||
|
* @param string $field
|
||
|
* @param string $search
|
||
|
* @param string $target
|
||
|
*
|
||
|
* @since 3.2.0
|
||
|
*/
|
||
|
public function set(string $view, string $field, string $search, string $target): void
|
||
|
{
|
||
|
$key = GetHelper::between($field, $search, '"');
|
||
|
if (!StringHelper::check($key))
|
||
|
{
|
||
|
// is not having special var
|
||
|
$key = $target;
|
||
|
// update field
|
||
|
$field = str_replace($search . '"', 'name="' . $key . '"', (string) $field);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
// update field
|
||
|
$field = str_replace(
|
||
|
$search . $key . '"', 'name="' . $key . '"', (string) $field
|
||
|
);
|
||
|
}
|
||
|
|
||
|
// set the values needed for view requests to be made
|
||
|
$this->requestbuilder->set("$target.$view.$key", $field);
|
||
|
}
|