Prepares a single result
@param mixed $data
@param array $options
347423
protected function prepareResult(&$data, array $options)
    {
        if (!empty($options['unserialize']) && !empty($data)) {
            foreach ((array) $options['unserialize'] as $field) {
                $data[$field] = empty($data[$field]) ? array() : unserialize($data[$field]);
            }
        }
    }
873208
public function attachData($data, $name, array $options = array())
    {
        $attachment = $this->createAttachmentFromData($data, $name);

        return $this->prepAttachment($attachment, $options);
    }
1217753
public function provide($data = null, array $options = [])
    {
        $valueLabels = [
            0 => __('Off'),
            1 => __('On'),
        ];

        if (empty($options['valueLabels'])) {
            $options['valueLabels'] = $valueLabels;
        }
        $result = parent::provide($data, $options);

        return $result;
    }
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;
    }
657650
public function write($data, array $options = [])
    {
        $message_array = ['message' => $this->_serializeMessage($data)];
        if (array_key_exists('flags', $options)) {
            $message_array['flags'] = $options['flags'];
        }
        $this->call->startBatch([
            OP_SEND_MESSAGE => $message_array,
        ]);
    }
177641
public function provide($data = null, array $options = [])
    {
        $result = parent::provide($data, $options);

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

        // Auto-paragraph
        $view = $this->config->getView();
        $result = $view->Text->autoParagraph($result);

        return $result;
    }
528826
protected function buildResponse($data, $headers = [], $options = 0)
    {   
        $headers = array_merge($headers, $this->headers);

        $response = $data instanceof JsonResource
            ? $data->toResponse($this->request)
            : new JsonResponse($data, $this->getStatusCode(), $headers, $options);

        $response->setStatusCode($this->getStatusCode());

        return $response;
    }
1249843
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;

        return $result;
    }
147337
public function prepareSearchEntity(array $options = array())
    {
        $alias = $options['alias'];

        /**
         * @var Entity $search_entity
         */
        $search_entity = $this->controller->{$alias}->newEntity();

        $search_entity->setAccess('*', true);
        $this->controller->{$alias}->patchEntity($search_entity, $this->controller->request->getData());
        $this->controller->set(compact('search_entity'));
    }
1268853
public function createFromArrayWithContext($data, $options)
    {
        $_edgeClass = $this->_edgeClass;

        return $_edgeClass::createFromArray($data, $options);
    }
787442
public function attachData($data, $name, array $options = [])
    {
        return $this->laravelMessage->attachData($data, $name, $options);
    }
550829
public function add(array $data, array $options = array())
    {
        $result = array();
        $this->hook->attach('order.submit.before', $data, $options, $result, $this);

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

        $data['order_id'] = $this->order->add($data);

        if (empty($data['order_id'])) {
            return $this->getResultError();
        }

        $order = $this->order->get($data['order_id']);
        $this->setBundledProducts($order, $data);

        if (empty($options['admin'])) {
            $this->setPriceRules($order);
            $this->updateCart($order, $data['cart']);
            $this->notifyCreated($order);
            $result = $this->getResultAdded($order);
        } else {
            $this->cloneCart($order, $data['cart']);
            $result = $this->getResultAddedAdmin($order);
        }

        $this->hook->attach('order.submit.after', $data, $options, $result, $this);
        return (array) $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;
    }
1182003
public function setJsonBody(array $data, int $options=JSON_PRETTY_PRINT|JSON_NUMERIC_CHECK)
  {
    $this->setContentType('application/json')
         ->setBody( json_encode($data,$options) );

    return $this;
  }
337152
public function prepare($sql, $options = null)
    {

        $md5 = md5($sql);

        if (isset($this->prepared_sql[$md5])) {
            return $this->prepared_sql[$md5];
        }

        //$this->writeToLog("Preparing: ".$sql);
        $stmt = parent::prepare($sql);
        $this->prepared_sql[$md5] = $stmt;
        return $stmt;
    }
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;
	}
1366815
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;

        $relatedProperties = $this->_getRelatedProperties($options['fieldDefinitions']->getLimit(), '');

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

        $content = sprintf(
            static::HTML_INPUT,
            $this->_getInputIcon($relatedProperties),
            $view->Form->control($field, [
                'label' => false,
                'name' => '{{name}}',
                'id' => $field,
                'type' => 'select',
                'data-type' => 'select2',
                'data-display-field' => $relatedProperties['displayField'],
                'data-magic-value' => isset($options['magic-value']) ?
                    (bool)$options['magic-value'] :
                    'Users' === $options['fieldDefinitions']->getLimit(),
                'escape' => false,
                'autocomplete' => 'off',
                'multiple' => isset($options['multiple']) ?
                    ((bool)$options['multiple'] ? 'multiple' : false) :
                    'multiple',
                'data-url' => $view->Url->build([
                    'prefix' => 'api',
                    'plugin' => $relatedProperties['plugin'],
                    'controller' => $relatedProperties['controller'],
                    'action' => 'lookup.json'
                ])
            ])
        );

        $result[$field]['display_field'] = $relatedProperties['displayField'];
        $result[$field]['source'] = Inflector::tableize($relatedProperties['controller']);
        $result[$field]['url'] = $view->Url->build([
            'prefix' => 'api',
            'plugin' => $relatedProperties['plugin'],
            'controller' => $relatedProperties['controller'],
            'action' => 'lookup.json'
        ]);
        $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' => 'scriptBlock',
                    'content' => 'csv_migrations_select2.setup(' . json_encode(
                        array_merge(
                            Configure::read('CsvMigrations.select2'),
                            Configure::read('CsvMigrations.api')
                        )
                    ) . ');',
                    'block' => 'scriptBottom'
                ],
                [
                    'type' => 'css',
                    'content' => [
                        'AdminLTE./bower_components/select2/dist/css/select2.min',
                        'Qobo/Utils.select2-bootstrap.min',
                        'Qobo/Utils.select2-style'
                    ],
                    'block' => 'css'
                ]
            ]
        ];

        return $result;
    }