Get a clone with special logic

@param string $createdByUserId
@param string $createdReason

@return static
547845
public function newInstance(
        string $createdByUserId,
        string $createdReason = Tracking::UNKNOWN_REASON
    ) {
        /** @var static $new */
        $new = parent::newInstance(
            $createdByUserId,
            $createdReason
        );

        // if no id, then it has not been save and can be returned
        if (empty($new->pageId)) {
            return $new;
        }

        $new->pageId = null;
        $new->name = null;
        $new->parent = null;

        return $new;
    }
1317406
public static function fromSourceWithClone( $src, $clone )
	{
		$result = new BufferedNodeIterator();
		$result->src = $clone ? $src->CloneInstance() : $src;
		$result->buffer = array();
		return $result;
	}
1040282
public function getInstance($id = null)
	{
		$current = $this->getCurrentUser();

		// Does the ID match to the current user?
		// If so, we already have that info and can just return it
		if (is_null($id))
		{
			return $current;
		}

		if (is_numeric($id))
		{
			// Cast as an integer so we can do an exact (===) comparison below
			$id = (int)$id;
		}

		if ($id === (int)$current->get('id')
		 || $id === (string)$current->get('username'))
		{
			return $current;
		}

		// Is the ID numeric?
		// If not, let's try to resolve by username or email address.
		if (!is_numeric($id))
		{
			$user = $this->resolveUser($id);
			$id   = $user->get('id', 0);

			if ($id)
			{
				$this->users[$id] = $user;
			}
		}

		// If the $id is zero, just return an empty User.
		// Note: don't cache this user because it'll have a new ID on save!
		if ($id === 0)
		{
			return new User;
		}

		// If the given user has not been created before, we will create the instance
		// here and cache it so we can return it next time very quickly. If there is
		// already a user created for this ID, we'll just return that instance.
		if (!isset($this->users[$id]))
		{
			$this->users[$id] = $this->resolveUser($id);
		}

		return $this->users[$id];
	}
936827
private static function create($decoded, Json $json)
    {
        $json->validate(
            $json->decodeFile(PHAR_UPDATE_MANIFEST_SCHEMA),
            $decoded
        );

        $updates = array();

        foreach ($decoded as $update) {
            $updates[] = new Update(
                $update->name,
                $update->sha1,
                $update->url,
                Parser::toVersion($update->version),
                isset($update->publicKey) ? $update->publicKey : null
            );
        }

        usort(
            $updates,
            function (Update $a, Update $b) {
                return Comparator::isGreaterThan(
                    $a->getVersion(),
                    $b->getVersion()
                );
            }
        );

        return new static($updates);
    }
506857
public function create($data, $userId = null)
    {
        if (isset($userId)) {
            return $this->client()->put($data, 'users/{userId}', ['userId' => $userId]);
        }

        return $this->client()->post($data, 'users');
    }
959459
protected function getUser($userId = null)
    {
        if ($userId === null) {
            /** @var Token $sessionAuth */
            if ($this->session()->isStarted() && $sessionAuth = $this->session()->get('authentication')) {
                return $sessionAuth->getUser();
            }

            return false;
        }
        /** @var Repository\UsersRepository $repo */
        $repo = $this->storage()->getRepository(Entity\Users::class);

        return $repo->getUser($userId);
    }
512086
function cloneVersion( $newVersionNumber, $userID, $contentObjectID = false, $status = eZContentObjectVersion::STATUS_DRAFT )
    {
        $time = time();
        $clonedVersion = clone $this;
        $clonedVersion->setAttribute( 'id', null );
        if ( $contentObjectID !== false )
            $clonedVersion->setAttribute( 'contentobject_id', $contentObjectID );
        $clonedVersion->setAttribute( 'version', $newVersionNumber );
        $clonedVersion->setAttribute( 'created', $time );
        $clonedVersion->setAttribute( 'modified', $time );
        $clonedVersion->setAttribute( 'creator_id', $userID );
        if ( $status !== false )
            $clonedVersion->setAttribute( 'status', $status );
        return $clonedVersion;
    }
427401
public function getDefaultSitePageSettings(
        array $defaultSiteSettings,
        string $author,
        string $createdByUserId,
        string $createdReason
    ) {
        $pagesData = (array_key_exists('pages', $defaultSiteSettings) ? $defaultSiteSettings['pages'] : []);

        // Set the author for each
        foreach ($pagesData as $key => $pageData) {
            $pagesData[$key]['createdByUserId'] = $createdByUserId;
            $pagesData[$key]['createdReason']
                = 'Default page creation in ' . get_class($this) . ' for: ' . $createdReason;
            $pagesData[$key]['author'] = $author;
        }

        return $pagesData;
    }
1061594
public function store(CreateUserRequest $request)
    {
        $input = $request->all();

        $user = $this->repository->create($input);
        $user->load($request->getWith());

        return $this->sendResponse($user, 'User saved successfully.');
    }
766239
public function createReference($userId)
    {
        $myUserId = $userId;
        if(is_array($userId) && array_key_exists('id', $userId)){
            $myUserId = $userId['id'];
        }
        return 'SU:' . $myUserId;
    }
1164445
public function create(UserInterface $user)
    {
        $entity = static::ENTITY_CLASSNAME;

        $activation = new $entity($user);

        $this->save($activation);

        return $activation;
    }
797583
public function newInstanceIfHasRevision(
        string $createdByUserId,
        string $createdReason = Tracking::UNKNOWN_REASON
    ) {
        /** @var ContainerInterface|ContainerAbstract $new */
        $new = parent::newInstance(
            $createdByUserId,
            $createdReason
        );

        $publishedRevision = $new->getPublishedRevision();

        if (empty($publishedRevision)) {
            return null;
        }

        $new->lastPublished = new \DateTime();

        $new->revisions = new ArrayCollection();
        $new->stagedRevision = null;
        $new->stagedRevisionId = null;

        $new->setPublishedRevision(
            $publishedRevision->newInstance(
                $createdByUserId,
                $createdReason
            )
        );

        return $new;
    }
904576
def created_by(self):
        
        if self.api and self.created_by_id:
            return self.api._get_user(self.created_by_id)
781719
public static function createForUser(string $userToken)
    {
        $httpClientConfigurator = new HttpClientConfigurator();
        $httpClientConfigurator
            ->setApiUserToken($userToken);

        return static::configure($httpClientConfigurator);
    }
492561
public function add($userId, array $data=null, $getOrCreate=null)
    {
        $endpoint = 'user/';
        $payload = [
            'id' => $userId,
        ];
        if( $data !== null ){
            $payload['data'] = $data;
        }
        if($getOrCreate){
            $endpoint .= '?get_or_create=true';
        }
        $response = $this->doRequest('POST', $endpoint, $payload);
        $body = $response->getBody()->getContents();
        return json_decode($body, true);
    }
1082199
public function getUser(string $userid)
    {
        $cl = $this->getUserClass();
        $user = new $cl;
        return $user->obtainByUserID($userid);
    }
853048
public function createPluginInstance(
        $pluginData,
        SiteEntity $site,
        string $createdByUserId,
        string $createdReason = Tracking::UNKNOWN_REASON,
        $oldPluginInstance = null,
        $doFlush = true
    ) {
        $pluginInstance = new PluginInstanceEntity(
            $createdByUserId,
            $createdReason
        );
        $pluginInstance->populate($pluginData);

        // @deprecated <deprecated-site-wide-plugin>
        $this->updateSiteSitewide(
            $pluginInstance,
            $site,
            $oldPluginInstance
        );

        $this->_em->persist($pluginInstance);

        if ($doFlush) {
            $this->_em->flush($pluginInstance);
        }

        return $pluginInstance;
    }