<commit_before><?php
namespace DreamFactory\Core\Events;

use DreamFactory\Core\Contracts\ServiceRequestInterface;
use DreamFactory\Core\Models\EventScript;

class PreProcessApiEvent extends InterProcessApiEvent
{
    public $request;

    /**
     * Create a new event instance.
     *
     * @param string                  $path
     * @param ServiceRequestInterface $request
     * @param mixed                   $resource
     */
    public function __construct($path, &$request, $resource = null)
    {
        $this->request = $request;
        $name = strtolower($path . '.' . $request->getMethod()) . '.pre_process';
        parent::__construct($name, $resource);
    }

    /**
     * @param EventScript $script
     * @param             $result
     *
     * @return bool
     */
    protected function handleEventScriptResult($script, $result)
    {
        if ($script->allow_event_modification) {
            // request only
            $this->request->mergeFromArray((array)array_get($result, 'request'));
        }

        return parent::handleEventScriptResult($script, $result);
    }
}<commit_msg>Bug fix for preprocess data building.<commit_after><?php
namespace DreamFactory\Core\Events;

use DreamFactory\Core\Contracts\ServiceRequestInterface;
use DreamFactory\Core\Models\EventScript;

class PreProcessApiEvent extends InterProcessApiEvent
{
    public $request;

    /**
     * Create a new event instance.
     *
     * @param string                  $path
     * @param ServiceRequestInterface $request
     * @param mixed                   $resource
     */
    public function __construct($path, &$request, $resource = null)
    {
        $this->request = $request;
        $name = strtolower($path . '.' . $request->getMethod()) . '.pre_process';
        parent::__construct($name, $resource);
    }

    public function makeData()
    {
        return [
            'request'  => $this->request->toArray(),
            'resource' => $this->resource,
        ];
    }

    /**
     * @param EventScript $script
     * @param             $result
     *
     * @return bool
     */
    protected function handleEventScriptResult($script, $result)
    {
        if ($script->allow_event_modification) {
            // request only
            $this->request->mergeFromArray((array)array_get($result, 'request'));
        }

        return parent::handleEventScriptResult($script, $result);
    }
}
{'fraction_non_alphanumeric': 0.12376237623762376, 'fraction_numerical': 0.0, 'mean_word_length': 2.2948369565217392, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1666165', 'n_tokens_mistral': 657, 'n_tokens_neox': 643, 'n_words': 135}