@param array   $data
@param Message $message

@return Message
423823
public function deserialize($data, Message $message, array $options)
    {
        if (!in_array(Options::REFRESH_UUID, $options)) {
            $message->setUuid($data['id']);
        }

        $this->sipe('title', 'setTitle', $data, $message);
        $this->sipe('content', 'setContent', $data, $message);

        if (isset($data['workspace']['uuid'])) {
            $workspace = $this->workspaceRepo->findOneBy(['uuid' => $data['workspace']['uuid']]);

            if (!empty($workspace)) {
                $message->setWorkspace($workspace);
            }
        }

        return $message;
    }
351408
public function log($message, $data)
    {
        // TODO: Implement log() method.
        $this->logMessages->enqueue([
            'date'    => date('Y-m-d H:i:s'),
            'message' => $message,
            'data'    => $data
        ]);

        return $this;
    }
721645
private function updateMessageData(Message $message, $locale, $text, $updatedAt = null)
    {
        $message->setLocale($locale);
        $message->setStatus(Message::DIRTY);
        $message->setMessage($text);

        if ($updatedAt) {
            $message->setUpdatedAt($updatedAt);
        }

        return $message;
    }
177561
public static function text($message, $data = null)
    {
        if (!static::$on) {
            return;
        }

        echo "--------------------------------------------------------------------------------\n";
        static::indent();
        echo static::getTime() . " - " . $message . "\n";
        if (is_array($data)) {
            print_r($data);
        } elseif ($data) {
            static::indent();
            echo "    " . $data . "\n";
        }
    }
62276
public function aSuccess($message,$url='',$data=[])
    {
        $url=is_null($url) || $url=='' ? 'javascript:history.back(-1)' : $url;
        if(Request::isAjax() ){
            return $this->json(0,$message,array_merge($data,['url'=>url($url)]));
        }else{
            return $this->success($message,$url);
        }
    }
1290752
public function validate(array $data, array $rules, array $messages = [])
	{
		// Build the validator.
		$validator = $this->validationFactory->make($data, $rules, $messages);

		// Return the errors, if any.
		if($validator->fails())
		{
			return new Payload($validator->messages(), 'invalid');
		}

		return new Payload($data, 'valid');
	}
137128
public static function alert($name = '', $message = '', $data = array(), $other = array())
    {
        return self::write($name, 'ALERT', $message, $data, $other);
    }
125597
public function sendMessage(Message $message)
    {
        $this->currentId++;
        $messageData = $message->convertToRconData($this->currentId);
        $this->client->write($messageData);

        return $this->getResponseMessage();
    }
1297118
public static function makeError($errorCode, $message, $data = array())
	{
		$error = array();
		$error['flag'] = false;
		$error['message'] = $message;
		$error['code'] = $errorCode;
		if(!empty($data))
			$error['data'] = $data;

		return $error;
	}
1120476
protected function shouldSendMessage($message, $data = [])
    {
        if (! $this->events) {
            return true;
        }

        return $this->events->until(
            new Events\MessageSending($message, $data)
        ) !== false;
    }
241663
protected function isValidMessage($message): Message
    {
        if ($message instanceof Message) {
            return $message;
        }

        if (\is_string($message) || $message instanceof Attachment) {
            return Message::create($message);
        }

        throw new MessengerException(sprintf(
            'message must be a string or an instance of %s or %s.',
            Message::class,
            Attachment::class
        ));
    }
798610
public function success($message = null, $data = array(), $return = false)
    {
        if (!empty($data)) {
            foreach ($data as $key => $value) {
                $this->add($key, $value);
            }
        }
        $json = $this->jsonEncode(
            array(
                'success' => true,
                'message' => $message,
                'data' => $this->_data,
            )
        );
        if (!$return) {
            echo $json;
            Yii::app()->end();
        } else {
            return $json;
        }
    }
977036
public static function fromArray(array $data)
    {
        return new Messages(
            new Message(isset($data['right-message']) ? $data['right-message'] : ''),
            new Message(isset($data['error-message']) ? $data['error-message'] : '')
        );
    }
1025469
private function tags($message, $data)
    {
        return array_merge(
            array_keys($message->getTo() ?: []),
            array_keys($message->getCc() ?: []),
            array_keys($message->getBcc() ?: []),
            $data['__telescope'] ?? []
        );
    }
493655
public function deserialize($data, Message $message, array $options = [])
    {
        $this->sipe('object', 'setObject', $data, $message);
        $this->sipe('content', 'setContent', $data, $message);
        $currentUser = $this->tokenStorage->getToken()->getUser();

        if (isset($data['parent'])) {
            $parent = $this->om->getRepository(Message::class)->find($data['parent']['id']);
            $message->setParent($parent);
        }

        if ($currentUser instanceof User && in_array(Options::CRUD_CREATE, $options)) {
            $message->setSender($currentUser);
        }

        //build the "to" string here
        //; is the separator
        //{} for groups
        //[] for workspaces
        $receivers = [];

        if (isset($data['toGroups'])) {
            $receivers = array_merge(array_map(function ($group) {
                return '{'.$group['name'].'}';
            }, $data['toGroups']), $receivers);
        }

        if (isset($data['toUsers'])) {
            $receivers = array_merge(array_map(function ($user) {
                return $user['username'];
            }, $data['toUsers']), $receivers);
        }

        if (isset($data['toWorkspaces'])) {
            $receivers = array_merge(array_map(function ($workspace) {
                return '['.$workspace['code'].']';
            }, $data['toWorkspaces']), $receivers);
        }

        $receiversString = implode(';', $receivers);

        if ('' !== $receiversString && !$message->getTo()) {
            $message->setTo($receiversString);
        }

        return $message;
    }
1150623
public static function debug($name = '', $message = '', $data = array(), $other = array())
    {
        return self::write($name, 'DEBUG', $message, $data, $other);
    }
197306
public static function output($message, $data = null)
    {
        if (static::$mode == "html") {
            static::html($message, $data);
        } else {
            static::text($message, $data);
        }
    }