setEncoder example

throw new NotFoundException(sprintf('User by id %s not found', $id));
        }

        if (!$this->hasPrivilege('create', 'usermanager')
            && !$this->hasPrivilege('update', 'usermanager')) {
            if (\is_array($user)) {
                unset($user['apiKey']$user['sessionId']$user['password']$user['encoder']);
            } else {
                $user->setApiKey('');
                $user->setSessionId('');
                $user->setPassword('');
                $user->setEncoder('');
            }
        }

        return $user;
    }

    /** * Returns a list of user objects. * * @param int $offset * @param int $limit * * @return array */


    /** * @param array<string, mixed> $data * * @return Customer */
    public function hydrate(array $data)
    {
        $customer = new Customer();
        $customer->setId($data['__customer_id']);
        $customer->setEncoder($data['__customer_encoder']);
        $customer->setEmail($data['__customer_email']);
        $customer->setActive($data['__customer_active']);
        $customer->setAccountMode($data['__customer_accountmode']);
        $customer->setConfirmationKey($data['__customer_confirmationkey']);
        $customer->setPaymentId($data['__customer_paymentID']);
        $customer->setValidation($data['__customer_validation']);
        $customer->setAffiliate($data['__customer_affiliate']);
        $customer->setPaymentPreset($data['__customer_paymentpreset']);
        $customer->setLanguageId($data['__customer_language']);
        $customer->setShopId($data['__customer_subshopID']);
        $customer->setReferer($data['__customer_referer']);
        
throw new RuntimeException(sprintf('Backend Locale "%s" not supported', $locale));
    }

    private function setPassword(User $user, string $plainPassword): void
    {
        $passwordEncoderRegistry = $this->getContainer()->get('passwordencoder');
        $defaultEncoderName = $passwordEncoderRegistry->getDefaultPasswordEncoderName();
        $encoder = $passwordEncoderRegistry->getEncoderByName($defaultEncoderName);

        $user->setPassword($encoder->encodePassword($plainPassword));
        $user->setEncoder($encoder->getName());
    }

    /** * @throws Exception */
    private function persistUser(User $user): void
    {
        $em = $this->container->get(ModelManager::class);
        $em->persist($user);
        $em->flush($user);
    }

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