Provide rendered value

@param mixed $data Data to use for provision
@param array $options Options to use for provision
@return mixed
343274
public function provide($data = null, array $options = [])
    {
        $result = '';
        $data = (string)$data;

        $listName = null;
        // Take list name from options or from fieldDefinitions
        if (!empty($options['listName'])) {
            $listName = (string)$options['listName'];
        } elseif (!empty($options['fieldDefinitions'])) {
            $listName = $options['fieldDefinitions']->getLimit();
        }

        // No known list name, so render value as safe string
        if (empty($listName)) {
            return parent::provide($data, $options);
        }

        return $this->config->getView()
            ->cell('CsvMigrations.Dblist::renderValue', [$data, $listName])
            ->render('renderValue');
    }
788664
protected function parseData($data, array $options, $key = null)
    {
        $architect = new Architect();

        return $architect->parseData($data, $options['modes'], $key);
    }
727819
public function provide($data = null, array $options = [])
    {
        $result = '';
        $data = (string)$data;

        if ('' === trim($data)) {
            return $result;
        }

        if (empty($options['listItems']) && empty($options['fieldDefinitions'])) {
            throw new InvalidArgumentException("No listItems or fieldDefinitions options provided");
        }

        if (empty($options['listItems'])) {
            $selectListItems = $this->config->getProvider('selectOptions');
            $selectListItems = new $selectListItems($this->config);
            $listName = $options['fieldDefinitions']->getLimit();
            $listOptions = [];

            $options['listItems'] = $selectListItems->provide($listName, $listOptions);
        }

        $listItems = $options['listItems'];

        if (!is_array($options['listItems'])) {
            throw new InvalidArgumentException("List items is not an array");
        }

        if (!isset($listItems[$data])) {
            return sprintf(static::VALUE_NOT_FOUND_HTML, parent::provide($data, $options));
        }

        // Concatenate all parents together with value
        // Nested values are dot-separated.  At least the
        // value itself will be included, if no parents.
        $parents = explode('.', $data);
        $path = '';
        foreach ($parents as $parent) {
            $path = empty($path) ? $parent : $path . '.' . $parent;
            $result .= isset($listItems[$path]) ? $listItems[$path] : '';
        }

        return $result;
    }
487141
public static function encode($data, $options = 0): string
    {
        $json = json_encode($data, $options);
        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new JsonEncodeException(json_last_error_msg());
        }

        return $json;
    }
1166615
public function provide($data = null, array $options = [])
    {
        $label = $options['label'];

        $combinedFields = $this->config->getProvider('combinedFields');
        $combinedFields = new $combinedFields($this->config);
        $combinedFields = $combinedFields->provide($data, $options);

        $view = $this->config->getView();

        $inputs = [];
        foreach ($combinedFields as $suffix => $preOptions) {
            // Skip individual inputs' label
            $options['label'] = false;
            $fieldName = $this->config->getField() . '_' . $suffix;

            $fieldData = $data;
            if (empty($fieldData) && !empty($options['entity'])) {
                $fieldData = $options['entity'];
            }

            $config = new $preOptions['config']($fieldName, $this->config->getTable(), $options);
            $config->setView($view);
            $handler = new FieldHandler($config);

            $inputs[$fieldName] = $handler->renderInput($fieldData, $options);
        }

        $params = [
            'field' => $this->config->getField(),
            'label' => $label,
            'required' => $options['fieldDefinitions']->getRequired(),
            'inputs' => $inputs
        ];

        $defaultElement = 'CsvMigrations.FieldHandlers/CombinedFieldHandler/input';
        $element = empty($options['element']) ? $defaultElement : $options['element'];

        return $this->renderElement($element, $params);
    }
1329070
public function render($options = array())
    {
        $string = $options['string'];
        $data = $options['data'];

        return $this->renderTpl($string, $data);
    }
916359
public function provide($data = null, array $options = [])
    {
        $template = $this->getBasicTemplate('text');
        $defaultOptions = $this->getDefaultOptions($data, $options);
        $defaultOptions['input'] = ['content' => $template];

        $result[$this->config->getField()] = $defaultOptions;

        $className = $this->config->getProvider('selectOptions');
        $provider = new $className($this->config);

        $selectOptions = $provider->provide($options['fieldDefinitions']->getLimit());

        $view = $this->config->getView();
        $content = $view->Form->select('{{name}}', $selectOptions, [
            'class' => 'form-control',
            'label' => false
        ]);

        foreach ($selectOptions as $key => $value) {
            $result[$this->config->getField()]['options'][] = ['value' => $key, 'label' => $value];
        }
        $result[$this->config->getField()]['input'] = ['content' => $content];

        return $result;
    }
273709
public function render($template, $data = [], array $options = []) {
		$defaults = ['context' => []];
		$options += $defaults;

		$this->_context = $options['context'] + $this->_context;
		$this->_data = (array) $data + $this->_vars;
		$this->_options = $options;
		$template__ = $template;
		unset($options, $template, $defaults, $data);

		if ($this->_config['extract']) {
			extract($this->_data, EXTR_OVERWRITE);
		} elseif ($this->_view) {
			extract((array) $this->_view->outputFilters, EXTR_OVERWRITE);
		}

		ob_start();
		include $template__;
		return ob_get_clean();
	}
1113258
public function body($data = null, $options = []) {
		$default = ['buffer' => null];
		$options += $default;
		$this->body = array_merge((array) $this->body, (array) $data);
		$body = join("\r\n", $this->body);
		return ($options['buffer']) ? str_split($body, $options['buffer']) : $body;
	}
168870
public function format($format, array $data, $options)
    {
        $adapter = $this->getAdapter($format);

        return $adapter->format($data, $options);
    }
799356
public function make($data, $options=array())
	{
		// Options
		$this->options = array_merge($this->options, $options);
		$options       = $this->options;

		// Capture output
		$out  = [];

		// @todo - Raise an exception instead ?
		// Would make more send and could be handled more gracefully
		//
		// Have any records actually been passed through ?
		if (empty($data)) {
			return $this->hasNoData($options);
		}

		// If a 'id' key has been specified use that as the table#id
		$tableId = null;

		if (!empty($options['id'])) {
			$tableId = "id='{$options['id']}'";
		}

		$out[] = "<div class=\"{$options['wrapperClass']}\">";
		$out[] = "\t<table class='{$options['containerClass']}' {$tableId}>";

		// Render headers
		if (true == $options['showHeaders']) {
			$headers = $this->extractHeaders($data);

			$out[] = "\t\t<thead>\r\t\t\t<tr class=\"{$options['headerClass']}\">";
			$count = 1;

			/**
			 * Create the <th> tag
			 */
			foreach ($headers as $index => $header)
			{
				$class = $this->getHeaderClass($header, $count);
				$count++;

				// Apply sort links to header
				if (isset($options['sort'][$header])) {

					$sortBy = $options['sort'][$header];
					$label  = $header;

					$header = $this->applyHeaderSort($label, $sortBy);
				}

				$out[] = "\t\t\t\t<th class=\"{$class}\">{$header}</th>";
			}

			$out[] = "\t\t\t</tr>\r\t\t</thead>";
		}

		$out[] = "\t\t<tbody>";

		// Render rows
		foreach ($data as $index => $row)
		{
			$rowClass = ($index % 2 == 0) ? $options['rowClass'] : $options['rowClassAlt'];

			if (isset($row['id'])) {
				$out[] = "\t\t\t<tr class='{$rowClass}' id='{$row['id']}-{$row['id']}'>";
			} else {
				$out[] = "\t\t\t<tr class='{$rowClass}'>";
			}

			foreach ($row as $field => $value) {
				$indent = "";
				if ($field == 'Title' && isset($options['type']) && $options['type'] == 'table-tree') {
					if (!empty($row['parent_id'])) {
						$indent = str_repeat($options['indent_style'], $row['depth']);
					}
				}

				if (in_array($field, $options['hiddenFields'], true)) {
					continue;
				}

				$fieldClass = $options['fieldClass'];

				if (is_array($value)) {
					//Log::info('@todo - Replace with logging interface');
					//$value = implode(',' $value);
					$value = 'Array';
				}

				$out[] = "\t\t\t\t<td class=\"{$fieldClass}\">{$value}</td>";

			}

			$out[] = "\t\t\t</tr>";
		}

		$out[] = "\t\t</tbody>";
		$out[] = "\t</table>";
		$out[] = "</div>";

		$this->output['table'] = implode(PHP_EOL, $out);

		return $this;
	}
305966
public function insert(&$data, array $options = array())
    {
        $document = new Document($data, $this);
        $insert = $document->insert($options);
        $data = $document->data;

        return $insert;
    }
899384
public function provide($data = null, array $options = [])
    {
        $selectListItems = $this->config->getProvider('selectOptions');
        $selectListItems = new $selectListItems($this->config);
        $listName = $options['fieldDefinitions']->getLimit();

        $selectOptions = $selectListItems->provide($listName, []);
        foreach ($selectOptions as $k => $v) {
            $selectOptions[$k] = sprintf(CountryValueRenderer::ICON_HTML, strtolower($k), $v);
        }

        $options['selectOptions'] = $selectOptions;
        $options['element'] = 'CsvMigrations.FieldHandlers/CountryFieldHandler/input';

        return parent::provide($data, $options);
    }
420157
public function provide($data = null, array $options = []) : array
    {
        $spacer = isset($options['spacer']) ? (string)$options['spacer'] : ' - ';
        $flatten = isset($options['flatten']) ? (bool)$options['flatten'] : true;

        list($module, $list) = false !== strpos($data, '.') ?
            explode('.', $data, 2) :
            [App::shortName(get_class($this->config->getTable()), 'Model/Table', 'Table'), $data];

        $result = [];
        try {
            $config = new ModuleConfig(ConfigType::LISTS(), $module, $list, ['flatten' => $flatten, 'filter' => true]);
            $config = $config->parse();
            if (! property_exists($config, 'items')) {
                return [];
            }

            $config = json_encode($config->items);
            if (false === $config) {
                return [];
            }

            $result = json_decode($config, true);
        } catch (InvalidArgumentException $e) {
            /* Do nothing.
             *
             * ModuleConfig checks for the file to exist and to be readable and so on, but here we do load lists
             * recursively (for sub-lists, etc), which might result in files not always being there.
             *
             * In this particular case, it's not the end of the world.
             */
            return [];
        }

        if (empty($result)) {
            return [];
        }

        if (! $flatten) {
            return $result;
        }

        foreach ($result as $key => $value) {
            $result[$key] = str_repeat($spacer, substr_count($key, '.')) . $value['label'];
        }

        return $result;
    }
240681
public function provide($data = null, array $options = [])
    {
        $result = (string)$data;

        if (empty($result)) {
            return $result;
        }

        // Sanitize
        $result = filter_var($result, FILTER_SANITIZE_EMAIL);
        if ($result === false) {
            // If you find a case where FILTER_SANITIZE_EMAIL fails, add
            // a unit test to EmailRendererTest and remove annotations here.
            // @codeCoverageIgnoreStart
            throw new InvalidArgumentException("Failed to sanitize email");
            // @codeCoverageIgnoreEnd
        }

        // Only link to valid emails, to avoid unpredictable behavior
        if (filter_var($result, FILTER_VALIDATE_EMAIL) === false) {
            return $result;
        }

        $view = $this->config->getView();
        $result = $view->Html->link($result, 'mailto:' . $result, ['target' => '_blank']);

        return $result;
    }
1190041
public function provide($data = null, array $options = [])
    {
        $result = parent::provide($data, $options);

        if (empty($result)) {
            return $result;
        }

        $config = [
            'html_input' => 'escape',
            'allow_unsafe_links' => false
        ];

        $converter = new CommonMarkConverter($config);

        return $converter->convertToHtml($result);
    }
1022216
public function provide($data = null, array $options = [])
    {
        $field = $this->config->getField();

        $template = $this->getBasicTemplate('text');

        $defaultOptions = $this->getDefaultOptions($data, $options);
        $defaultOptions['input'] = ['content' => $template];

        $result[$field] = $defaultOptions;

        $className = $this->config->getProvider('selectOptions');
        $provider = new $className($this->config);
        $selectOptions = [];
        foreach ($provider->provide($options['fieldDefinitions']->getLimit()) as $k => $v) {
            $selectOptions[$k] = sprintf(CountryValueRenderer::ICON_HTML, strtolower($k), $v);
        }

        $view = $this->config->getView();

        $attributes = [
            'class' => 'form-control',
            'label' => false,
            'data-class' => 'select2',
        ];

        $content = $view->Form->select('{{name}}', $selectOptions, $attributes);

        foreach ($selectOptions as $key => $value) {
            $result[$field]['options'][] = ['value' => $key, 'label' => $value];
        }

        $result[$field]['source'] = $options['fieldDefinitions']->getLimit();
        $result[$field]['input'] = [
            'content' => $content,
            'post' => [
                [
                    'type' => 'script',
                    'content' => [
                        'CsvMigrations.dom-observer',
                        'AdminLTE./bower_components/select2/dist/js/select2.full.min',
                        'CsvMigrations.select2.init'
                    ],
                    'block' => 'scriptBottom'
                ],
                [
                    'type' => 'css',
                    'content' => [
                        'AdminLTE./bower_components/select2/dist/css/select2.min',
                        'Qobo/Utils.select2-bootstrap.min',
                        'Qobo/Utils.select2-style',
                        'Qobo/Utils./img/icons/flags/css/flag-icon.css'
                    ],
                    'block' => 'css'
                ]
            ]
        ];

        return $result;
    }