Replaces the profiles associated to this user.

@param string[]|Profile[] $profiles Unique ids or Kuzzle\Security\Profile instances corresponding to the new associated profiles
@return $this
190984
public function setProfiles($profiles)
    {
        $profileIds = [];

        foreach ($profiles as $profile) {
            $profileIds[] = $this->extractProfileId($profile);
        }

        $this->content['profileIds'] = $profileIds;

        return $this;
    }
748555
protected function getGroupings($profile)
    {
        $compose = $this->getNamespacedProfile($profile);
        $profileNs = $compose['namespace'];
        $groupings = ($profileNs !== false) ? $this->getGroupings($compose['namespace']) : [];
        $profileKey = $compose['profile'];

        if (isset($this->profiles[$profileKey]['groupings'])) {
            $groupings = $this->profiles[$profileKey]['groupings'];
        }

        return $groupings;
    }
720245
public function updateProfile( CustomerVault\Profile $profile )
    {
        $profile->setRequiredFields(array('id'));
        $profile->checkRequiredFields();
        $profile->setRequiredFields(array(
            'merchantCustomerId',
            'locale'
        ));
        $profile->setOptionalFields(array(
            'firstName',
            'middleName',
            'lastName',
            'dateOfBirth',
            'ip',
            'gender',
            'nationality',
            'email',
            'phone',
            'cellPhone'
        ));

        $request = new Request(array(
            'method' => Request::PUT,
            'uri' => $this->prepareURI("/profiles/" . $profile->id),
            'body' => $profile
        ));
        $response = $this->client->processRequest($request);

        return new CustomerVault\Profile($response);
    }
882571
public function setSupportedServiceProfiles(array $serviceProfiles = null)
    {
        ValidationUtility::ensureNullOrArrayOfType(
            '$serviceProfiles', $serviceProfiles, '\Authlete\Types\ServiceProfile');

        $this->supportedServiceProfiles = $serviceProfiles;

        return $this;
    }
732902
public function setClients(array $clients = null)
    {
        ValidationUtility::ensureNullOrArrayOfType(
            '$clients', $clients, __NAMESPACE__ . '\Client');

        $this->clients = $clients;

        return $this;
    }
660025
protected function replaceAttributes(array $attributes)
    {
        foreach ($this->abbreviations as $abbreviation => $attribute) {
            if (isset($attributes[$abbreviation])) {
                $attributes[$attribute] = $attributes[$abbreviation];
                unset($attributes[$abbreviation]);
            }
        }

        return $attributes;
    }
390810
public function setPaths($paths)
    {
        if (!($paths instanceof \SplPriorityQueue)) {
            $priority = new \SplPriorityQueue();

            foreach ((array) $paths as $i => $path) {
                $priority->insert($path, 100 - ($i * 10));
            }

            $paths = $priority;
        }

        $this->paths = $paths;

        return $this;
    }
1087678
public function replaceKeys(array $keys): self
    {
        $values = \array_values($this->getArray());
        $result = \array_combine($keys, $values);

        return static::create(
            $result,
            $this->iteratorClass,
            false
        );
    }
699206
public function replaceAll($path, array $replacements) {
        foreach ($replacements as $key => $value) {
            $path = $this->replace($path, $key, $value);
        }

        return $path;
    }
1336977
public Governator addProfiles(String... profiles) {
        if (profiles != null) {
            this.profiles.addAll(Arrays.asList(profiles));
        }
        return this;
    }
1027709
public function setProfile($profileName)
    {
        if (!isset($this->profiles[$profileName])) {
            throw new \InvalidArgumentException('Profile "'. $profileName. '" does not exist');
        }

        $this->currentProfile = $profileName;
    }
969381
protected function loadProfileByKey($key)
    {
        if (isset($this->profiles['profiles'][$key])) {
            $profile = $this->profiles['profiles'][$key];

            if (is_array($profile)) {
                $this->mergeProfileWithConfig($profile);
            }
        }
    }
369547
public function assignProfiles($profiles) : void
    {
        $profiles = (array) $profiles;
        foreach ($profiles as $profile) {
            $electedProfile = Profile::where('code', $profile)->first();

            // Profile exists and not assigned to user?
            if (!is_null($electedProfile) && !$this->hasProfile($profile)) {
                // Assign both role and permissions defined for this user profile.
                // Into the Spatie Permissions.
                $this->assignRole(Role::find([$electedProfile->role_id])->first()->name);
                $this->givePermissionTo(Permission::find([$electedProfile->permission_id])->first()->name);

                // Assign user profile into the profiles table.
                $this->profiles()->save($electedProfile);
            }
        }
    }
653275
public function resolveProfilePath($path, $profile)
    {
        $path = $this->resolvePath($path);
        return preg_replace_callback('|\[\[([\w\_/]+)\]\]|', function ($matches) use ($profile) {
            $name = $matches[1];
            switch ($name) {
                case 'profile':
                    return $profile;
            }
            return '[[' . $name . ']]';
        }, $path);
    }
438031
public function setEditUsers( $users )
    {
        $this->editUsers = array_unique(
            is_array( $users ) ? $users : preg_split( '/[,\s]+/', $users )
        );

        return $this;
    }
1352806
public function searchProfiles(array $filters, array $options = [])
    {
        $data = [
            'body' => $filters
        ];

        $scrollId = null;

        $response = $this->kuzzle->query(
            $this->buildQueryArgs('searchProfiles'),
            $data,
            $options
        );

        $response['result']['hits'] = array_map(function ($profile) {
            return new Profile($this, $profile['_id'], $profile['_source'], $profile['_meta']);
        }, $response['result']['hits']);

        if (isset($response['result']['scrollId'])) {
            $scrollId = $response['result']['scrollId'];
        }

        return new ProfilesSearchResult($response['result']['total'], $response['result']['hits'], $scrollId);
    }
792008
public function replace($data, $statements = null)
    {
        $this->settings['type'] = 'REPLACE';
        $this->settings['data'] = $data;
        $this->settings['statements'] = $statements;

        return $this;
    }