Create the user and associate avatar, banner or video.

@param User $model
@param array $config
@return User
772458
public function create( $model, $config = [] ) {

		$avatar = isset( $config[ 'avatar' ] ) ? $config[ 'avatar' ] : null;
		$banner = isset( $config[ 'banner' ] ) ? $config[ 'banner' ] : null;
		$video	= isset( $config[ 'video' ] ) ? $config[ 'video' ] : null;

		// Set Attributes
		$model->registeredAt = DateUtil::getDateTime();

		if( empty( $model->status ) ) {

			$model->status = User::STATUS_NEW;
		}

		if( empty( $model->type ) ) {

			$model->type = CoreGlobal::TYPE_DEFAULT;
		}

		if( empty( $model->slug ) ) {

			$model->slug = $model->username;
		}

		// Generate Tokens
		$model->generateVerifyToken();
		$model->generateAuthKey();
		$model->generateOtp();

		// Save Files
		$this->fileService->saveFiles( $model, [ 'avatarId' => $avatar, 'bannerId' => $banner, 'videoId' => $video ] );

		return parent::create( $model, $config );
	}
113212
public function actionCreate()
    {
        $model = new UserAuthItem(null);
        $model->type = $this->type;
        if ($model->load(Yii::$app->getRequest()->post()) && $model->save()) {
            Yii::$app->getSession()->setFlash('success', Yii::t('yuncms','Create success.'));
            return $this->redirect(['view', 'id' => $model->name]);
        } else {
            return $this->render('create', ['model' => $model]);
        }
    }
927488
protected function show($user, string $modelName)
    {
        $method = "{$modelName}s";
        $methodTitle = ucfirst($method);

        if (! $user->$method) {
            $this->warn("User not use Has{$methodTitle}Trait!");
            return;
        }

        echo "{$methodTitle}:", PHP_EOL;

        $data = $this->prepareData($user->$method->toArray());

        if ($user->$method->count()) {
            $this->table(['ID', ucfirst($modelName), 'Created At', 'Updated At'], $data);
        } else {
            $this->warn("Not found any {$method}!");
        }
    }
1099209
protected function insert($user, $provider, $userProfile)
    {
        $zfcUserOptions = $this->getZfcUserOptions();

        // If user state is enabled, set the default state value
        if ($zfcUserOptions->getEnableUserState()) {
            if ($zfcUserOptions->getDefaultUserState()) {
                $user->setState($zfcUserOptions->getDefaultUserState());
            }
        }

        $options = array(
            'user'          => $user,
            'provider'      => $provider,
            'userProfile'   => $userProfile,
        );

        $this->getEventManager()->trigger('registerViaProvider', $this, $options);
        $result = $this->getZfcUserMapper()->insert($user);
        $this->getEventManager()->trigger('registerViaProvider.post', $this, $options);

        return $result;
    }
819807
protected function setCreatedBy(Model $model, $user)
    {
        $model->{$this->getColumn($model, 'created')} = $user->id;

        if ($model instanceof CreatorAware) {
            $model->setRelation('creator', $user);
        }

        return $model;
    }
148862
public function showProfileAction(DacorpUser $user)
    {
        $em = $this->getDoctrine()->getManager();

        if ($user instanceof DacorpUser)
            $chosenAvatarFilename = ($user->getCurrentAvatar()) ? $em->getRepository('DacorpExtraBundle:DacorpMedia')->find($user->getCurrentAvatar())->getFilename() : null;

        return $this->render('DacorpExtraBundle:User:showUserProfile.html.twig', array(
            'user' => $user,
            'avatar' => $chosenAvatarFilename
        ));
    }
768606
public function create( $model, $config = [] ) {

		$model = parent::create( $model, $config );

		$content = isset( $config[ 'content' ] ) ? $config[ 'content' ] : null;

		// Model content is required for all the tags to form tag page
		if( !isset( $content ) ) {

			$content = new ModelContent();
		}

		$config[ 'parent' ]		= $model;
		$config[ 'parentType' ]	= self::$parentType;

		$this->modelContentService->create( $content, $config );

		return $model;
	}
1300189
public function postUser(UserPostMessage $message): User
    {
        $path = sprintf('companies/%d/users', $message->getCompanyId());
        $data = ['api_user' => $message->build()];

        $response = $this->getClient()->sendRequest('POST', $path, $data);

        /** @var User $model */
        $model = $this->getModelFactory()->create(User::class, $response);

        return $model;
    }
662628
public function uploadImage(User $entity)
    {

        /* the file property can be empty if the field is not required */
        if (null === $entity->getFile()) {
            return $entity;
        }

        $uploadBaseDir = $this->container->getParameter("user_avatar_basedir");
        $uploadDir = $this->container->getParameter("user_avatar_dir");

        /* set the path property to the filename where you've saved the file */
        $filename = $entity->getFile()->getClientOriginalName();
        $extension = $entity->getFile()->getClientOriginalExtension();

        $imageName = md5($filename . time()) . '.' . $extension;

        $entity->setAvatar($uploadDir . $imageName);
        $entity->getFile()->move($uploadBaseDir . $uploadDir, $imageName);

        $entity->setFile(null);

        return $entity;
    }
480949
protected function createUsersBroker(array $config)
    {
        return new VerificationBroker(
            $this->createTokenRepository($this->app['config']['verification.repositories.'.$config['repository']]),
            $this->app['auth']->createUserProvider($config['provider']),
            $this->app['mailer'],
            $config['email']
        );
    }
792418
protected function insert($user, $provider, $userProfile)
    {
        $zfcUserOptions = $this->getZfcUserOptions();

        // If user state is enabled, set the default state value
        if ($zfcUserOptions->getEnableUserState()) {
            if ($zfcUserOptions->getDefaultUserState()) {
                $user->setState((int) $zfcUserOptions->getDefaultUserState());
            }
        }

        $roleMapper          = $this->getRoleMapper();
        $defaultRegisterRole = $this->getOptions()->getDefaultRegisterRole();
        $role = $roleMapper->findByRoleId($defaultRegisterRole);
        $user->addRole($role);

        $options = array(
            'user'          => $user,
            'provider'      => $provider,
            'userProfile'   => $userProfile,
        );

        $this->getEventManager()->trigger('registerViaProvider', $this, $options);
        $result = $this->getZfcUserMapper()->insert($user);
        $this->getEventManager()->trigger('registerViaProvider.post', $this, $options);

        return $result;
    }
1170582
public function create( $user, $config = [] ) {

		$snsUser		= $config[ 'snsUser' ];
		$accessToken	= $config[ 'accessToken' ];

		$snsProfileToSave = $this->getModelObject();

		$snsProfileToSave->userId	= $user->id;
		$snsProfileToSave->type		= SnsConnectGlobal::SNS_TYPE_TWITTER;
		$snsProfileToSave->snsId	= strval( $snsUser->id );
		$snsProfileToSave->token	= $accessToken;
		$snsProfileToSave->secret	= $snsUser->secret;
		$snsProfileToSave->data		= json_encode( $snsUser );

		// Create SnsProfile
		$snsProfileToSave->save();

		// Return SnsProfile
		return $snsProfileToSave;
	}
414659
public function create( $model, $config = [] ) {

		if( empty( $model->label ) ) {

			$model->label = $model->name;
		}

		if( !isset( $model->valueType ) ) {

			$model->valueType = Meta::VALUE_TYPE_TEXT;
		}

		return parent::create( $model );
	}
1170473
public function create( $model, $config = [] ) {

		$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;

		$model->agent	= Yii::$app->request->userAgent;
		$model->ip		= Yii::$app->request->userIP;
		$model->siteId	= $siteId;

		return parent::create( $model, $config );
	}
334140
public function update( $model, $config = [] ) {

		$admin = isset( $config[ 'admin' ] ) ? $config[ 'admin' ] : false;

		$attributes = isset( $config[ 'attributes' ] ) ? $config[ 'attributes' ] : [];

		if( $admin ) {

			$attributes	= ArrayHelper::merge( $attributes, [ 'status' ] );
		}

		return parent::update( $model, [
			'attributes' => $attributes
		]);
	}
33038
public function create( $model, $config = [] ) {

		if( empty( $model->type ) ) {

			$model->type = CoreGlobal::TYPE_DEFAULT;
		}

		return parent::create( $model, $config );
	}
887057
public function create(ModelInterface $model)
    {
        $user = $this->container->make(UserSingularity::class);

        $user
            ->setModel($model)
            ->boot();

        return $user;
    }