/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakedc/auth/src/Social/Mapper
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakedc/auth/src/Social/Mapper/AbstractMapper.php (3214B)
'id',
'username' => 'username',
'full_name' => 'name',
'first_name' => 'first_name',
'last_name' => 'last_name',
'email' => 'email',
'avatar' => 'avatar',
'gender' => 'gender',
'link' => 'link',
'bio' => 'bio',
'locale' => 'locale',
'validated' => 'validated',
];
/**
* Constructor
*
* @param mixed $mapFields map fields
*/
public function __construct($mapFields = null)
{
if (!is_null($mapFields)) {
$this->_mapFields = $mapFields;
}
$this->_mapFields = array_merge($this->_defaultMapFields, $this->_mapFields);
}
/**
* Invoke method
*
* @param mixed $rawData raw data
* @return mixed
*/
public function __invoke($rawData)
{
return $this->_map($rawData);
}
/**
* If email is present the user is validated
*
* @param mixed $rawData raw data
* @return bool
*/
protected function _validated($rawData)
{
$email = Hash::get($rawData, $this->_mapFields['email']);
return !empty($email);
}
/**
* Maps raw data using mapFields
*
* @param mixed $rawData raw data
* @return mixed
*/
protected function _map($rawData)
{
$result = [];
collection($this->_mapFields)->each(function (string $mappedField, string $field) use (&$result, $rawData): void {
$value = Hash::get($rawData, $mappedField);
$function = '_' . Inflector::camelize($field);
if (method_exists($this, $function)) {
$value = $this->{$function}($rawData);
}
$result[$field] = $value;
});
$token = $rawData['token'] ?? null;
if (empty($token) || !is_array($token) && !$token instanceof \League\OAuth2\Client\Token\AccessToken) {
return false;
}
$result['credentials'] = [
'token' => is_array($token) ? ($token['accessToken'] ?? null) : $token->getToken(),
'secret' => is_array($token) ? ($token['tokenSecret'] ?? null) : null,
'expires' => is_array($token) ? ($token['expires'] ?? null) : $token->getExpires(),
];
$result['raw'] = $rawData;
return $result;
}
}