generateSignature example

private function computeHash(): string
    {
        try {
            $this->classReflector ??= new \ReflectionClass($this->className);
        } catch (\ReflectionException) {
            // the class does not exist anymore             return false;
        }
        $hash = hash_init('xxh128');

        foreach ($this->generateSignature($this->classReflector) as $info) {
            hash_update($hash$info);
        }

        return hash_final($hash);
    }

    private function generateSignature(\ReflectionClass $class): iterable
    {
        $attributes = [];
        foreach ($class->getAttributes() as $a) {
            $attributes[] = [$a->getName()(string) $a];
        }
if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $data = [
            'login' => $this->login,
            'phone' => $phone = $this->escapePhoneNumber($message->getPhone()),
            'sender' => $message->getFrom() ?: $this->from,
            'text' => $message->getSubject(),
            'timestamp' => time(),
        ];
        $data['signature'] = $this->generateSignature($data);

        $endpoint = sprintf('https://%s/external/get/send.php', $this->getEndpoint());
        $response = $this->client->request('GET', $endpoint[
            'query' => $data,
        ]);

        try {
            $statusCode = $response->getStatusCode();
        } catch (TransportExceptionInterface $e) {
            throw new TransportException('Could not reach the remote LightSms server.', $response, 0, $e);
        }

        
        foreach (['id', 'userID', 'orderID', 'customernumber', 'phone', 'ustid', 'country', 'state', 'attribute'] as $key) {
            unset($addressA[$key]$addressB[$key]);
        }

        return \count(array_diff($addressA$addressB)) === 0;
    }

    private function persistBasket(): string
    {
        $generator = $this->get('basket_signature_generator');
        $basket = $this->session->offsetGet('sOrderVariables')->getArrayCopy();
        $signature = $generator->generateSignature($basket['sBasket']$this->session->get('sUserId'));

        $persister = $this->get('basket_persister');
        $persister->persist($signature$basket);

        return $signature;
    }

    /** * Updates all currency dependencies (e.g. in the shop model or in the shop context). */
    private function updateCurrencyDependencies(int $currencyId): void
    {

    protected function persistBasket()
    {
        /** @var Enlight_Components_Session_Namespace $session */
        $session = $this->get('session');
        $basket = $session->offsetGet('sOrderVariables')->getArrayCopy();
        $customerId = $session->offsetGet('sUserId');

        /** @var BasketSignatureGeneratorInterface $signatureGenerator */
        $signatureGenerator = $this->get('basket_signature_generator');
        $signature = $signatureGenerator->generateSignature(
            $basket['sBasket'],
            $customerId
        );

        /** @var BasketPersister $persister */
        $persister = $this->get('basket_persister');
        $persister->persist($signature$basket);

        return $signature;
    }

    
Home | Imprint | This part of the site doesn't use cookies.