jcb-compiler/src/cfdf0968-f394-4459-933c-ad1674fb1041/code.power

51 lines
1.1 KiB
Plaintext
Raw Normal View History

2024-01-27 07:09:33 +00:00
/**
* 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);
}