protected function persist(ImportMapperInterface $userMapper)
    {
        if (!$userMapper instanceof UserMapperInterface) {
            throw new \Exception('Mapper should be a UserMapper');
        }

        $plainPassword = $userMapper->getPlainPassword();
        $properties    = $userMapper->getProperties();

        $class = $this->getUserClass($properties);

        $results = $class->searchInstances(
            [
                UserRdf::PROPERTY_LOGIN => $properties[UserRdf::PROPERTY_LOGIN]
            ],
            [
                'like' => false,
                'recursive' => true
            ]
        );

        if(count($results) > 0){
            $resource = $this->mergeUserProperties(current($results), $properties);
        } else {
            $resource = $class->createInstanceWithProperties($properties);
        }

        $this->triggerUserUpdated($resource, $properties, $plainPassword);

        return $resource;
    }
protected function persist(ImportMapperInterface $userMapper)
    {
        if (!$userMapper instanceof UserMapperInterface) {
            throw new \Exception('Mapper should be a UserMapper');
        }

        $plainPassword = $userMapper->getPlainPassword();
        $properties    = $userMapper->getProperties();

        $class = $this->getUserClass($properties);

        $results = $class->searchInstances(
            [
                UserRdf::PROPERTY_LOGIN => $properties[UserRdf::PROPERTY_LOGIN]
            ],
            [
                'like' => false,
                'recursive' => true
            ]
        );

        if(count($results) > 0){
            $resource = $this->mergeUserProperties(current($results), $properties);
        } else {
            $resource = $class->createInstanceWithProperties($properties);
        }

        $this->triggerUserUpdated($resource, $properties, $plainPassword);

        return $resource;
    }
protected function persist ( ImportMapperInterface $ userMapper ) { if ( ! $ userMapper instanceof UserMapperInterface ) { throw new \ Exception ( 'Mapper should be a UserMapper' ) ; } $ plainPassword = $ userMapper -> getPlainPassword ( ) ; $ properties = $ userMapper -> getProperties ( ) ; $ class = $ this -> getUserClass ( $ properties ) ; $ results = $ class -> searchInstances ( [ UserRdf :: PROPERTY_LOGIN => $ properties [ UserRdf :: PROPERTY_LOGIN ] ] , [ 'like' => false , 'recursive' => true ] ) ; if ( count ( $ results ) > 0 ) { $ resource = $ this -> mergeUserProperties ( current ( $ results ) , $ properties ) ; } else { $ resource = $ class -> createInstanceWithProperties ( $ properties ) ; } $ this -> triggerUserUpdated ( $ resource , $ properties , $ plainPassword ) ; return $ resource ; }
Persist a user, create or update

@param ImportMapperInterface $userMapper
@return \core_kernel_classes_Resource
@throws \Exception
Persist a user create or update