jcb-compiler/src/f48764e0-16c6-459c-8576-af7616f3b720/code.power

73 lines
2.0 KiB
Plaintext
Raw Normal View History

2023-10-04 18:28:29 +00:00
/**
* The FieldDynamic Class.
*
* @var FieldDynamic
* @since 3.2.0
*/
protected FieldDynamic $fielddynamic;
/**
* The Xml Class.
*
* @var Xml
* @since 3.2.0
*/
protected Xml $xml;
/**
* Constructor.
*
* @param FieldDynamic $fielddynamic The FieldDynamic Class.
* @param Xml $xml The Xml Class.
*
* @since 3.2.0
*/
public function __construct(FieldDynamic $fielddynamic, Xml $xml)
{
$this->fielddynamic = $fielddynamic;
$this->xml = $xml;
}
/**
* Get field as a string (no matter the build type)
*
* @param array $field The field data
* @param array $view The view data
* @param int $viewType The view type
* @param string $langView The language string of the view
* @param string $nameSingleCode The single view name
* @param string $nameListCode The list view name
* @param array $placeholders The placeholder and replace values
* @param string $dbkey The custom table key
* @param boolean $build The switch to set the build option
*
* @return string The complete field in xml-string
* @since 3.2.0
*/
public function get(array &$field, array &$view, int $viewType, string $langView,
string $nameSingleCode, string $nameListCode, array &$placeholders,
string &$dbkey, bool $build = false): string
{
// get field
$field_xml = $this->fielddynamic->get(
$field, $view, $viewType, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $dbkey, $build
);
if (is_string($field_xml))
{
return $field_xml;
}
elseif (is_object($field_xml) && isset($field_xml->fieldXML))
{
return PHP_EOL . Indent::_(2) . "<!--"
. Line::_(__Line__, __Class__) . " "
. $field_xml->comment . ' -->' . PHP_EOL
. Indent::_(1) . $this->xml->pretty(
$field_xml->fieldXML, 'field'
);
}
return '';
}