Create a friendship relationship object

@param DataObject $member
"me", as in the person who triggered the follow
@param DataObject $followed
"them", the person "me" is wanting to add
@return \Friendship
@throws PermissionDeniedException
777414
public function addFriendship(DataObject $member, DataObject $followed) {
		if (!$member || !$followed) {
			throw new PermissionDeniedException('Read', 'Cannot read those users');
		}

		if ($member->ID != $this->securityContext->getMember()->ID) {
			throw new PermissionDeniedException('Write', 'Cannot create a friendship for that user');
		}

		$existing = Friendship::get()->filter(array(
			'InitiatorID'		=> $member->ID,
			'OtherID'			=> $followed->ID,
		))->first();

		if ($existing) {
			return $existing;
		}
		
		// otherwise, we have a new one!
		$friendship = new Friendship;
		$friendship->InitiatorID = $member->ID;
		$friendship->OtherID = $followed->ID;
		
		// we add the initiator into the 
		
		// lets see if we have the reciprocal; if so, we can mark these as verified 
		$reciprocal = $friendship->reciprocal();

		// so we definitely add the 'member' to the 'followers' group of $followed
		$followers = $followed->getGroupFor(MicroBlogMember::FOLLOWERS);
		$followers->Members()->add($member);

		if ($reciprocal) {
			$reciprocal->Status = 'Approved';
			$reciprocal->write();
			
			$friendship->Status = 'Approved';
			
			// add to each other's friends groups
			$friends = $followed->getGroupFor(MicroBlogMember::FRIENDS);
			$friends->Members()->add($member);
			
			
			$friends = $member->getGroupFor(MicroBlogMember::FRIENDS);
			$friends->Members()->add($followed);
		}

		$friendship->write();
		return $friendship;
	}
740112
public function follow($data, $form) {
		if (!$this->securityContext->getMember()) {
			return Security::permissionFailure($this);
		}
		$otherID = (int) (isset($data['OtherID']) ? $data['OtherID'] : null);
		if ($otherID) {
			$other = DataObject::get_by_id('Member', $otherID);
			$this->microBlogService->addFollower($other, $this->securityContext->getMember());
		}
		$this->redirectBack();
	}
497123
public function sAdd($key, $member) {
        return $this->getHandler($this->judge(__FUNCTION__))->sAdd($key, $member);
    }
711836
public function canCreate($member = null)
    {
        if (!$member || !(is_a($member, 'Member')) || is_numeric($member)) {
            $member = Member::currentUser();
        }

        $results = $this->extend('canCreate', $member);

        if ($results && is_array($results)) {
            if (!min($results)) {
                return false;
            }
        }

        // Do early admin check
        if ($member &&
            Permission::checkMember($member, array('CMS_ACCESS_DMSDocumentAdmin'))
        ) {
            return true;
        }

        return $this->canEdit($member);
    }
1365217
public function sAdd($key, $member, ...$members) {
        return $this->send(array_merge(['sadd', $key], (array) $member, $members));
    }
897639
public function canCreate($member = null, $context = array())
    {
        return $this->Action()->WorkflowDef()->canCreate($member, $context);
    }
528214
public function rpush($key, $member) {
        try {
            return $this->getRedis()->rPush($key, $member);
        } catch (RedisException $ex) {
            throw new ConnectException();
        }
    }
1185447
public function canEdit($member)
    {
        // Override any default behaviour, to allow queuedjobs to complete
        if ($this->isPublishJobRunning()) {
            return true;
        }

        if ($active = $this->getWorkflowInstance()) {
            return $active->canEditTarget();
        }
    }
563504
public function addMember($member)
    {
        $member = ($member instanceof Model ? $member->getDn() : $member);

        if (is_null($member)) {
            throw new InvalidArgumentException(
                'Cannot add member to group. The members distinguished name cannot be null.'
            );
        }

        $mod = $this->newBatchModification(
            $this->schema->member(),
            LDAP_MODIFY_BATCH_ADD,
            [$member]
        );

        return $this->addModification($mod)->save();
    }
1007159
public Membership add(Address new_member) {
        synchronized(members) {
            if(new_member != null && !members.contains(new_member)) {
                members.add(new_member);
            }
        }
        return this;
    }
1264099
public function merge(NestedMember $member) : NestedMember
    {
        $parts = $this->parts;

        $isNullable = $this->getResultingType()->isNullable();
        foreach ($member->getParts() as $part) {
            $parts[] = $isNullable ? $part->asNullable() : $part;
        }

        return new self($parts);
    }
278880
def _add_member(self, member):
        
        if member.id in self.children:
            return None
        else:
            self.children[member.id] = member
380982
protected function createAssociation(ClassMetadataBuilder $builder, $relation, $entity)
    {
        return $this->builder->createManyToOne(
            $relation,
            $entity
        );
    }
1353659
protected function getAllowedRelations($class, $member = null)
    {
        $allowedRelations = [];
        $obj = singleton($class);
        $relations = (array)$obj->hasOne() + (array)$obj->hasMany() + (array)$obj->manyMany();
        if ($relations) {
            foreach ($relations as $relName => $relClass) {
                $relClass = static::parseRelationClass($relClass);

                //remove dot notation from relation names
                $parts = explode('.', $relClass);
                $relClass = array_shift($parts);
                if (Config::inst()->get($relClass, 'api_access')) {
                    $allowedRelations[] = $relName;
                }
            }
        }
        return $allowedRelations;
    }
1094791
public function setMember($member)
    {
        $member = is_string($member) ? [$member] : $member;
        $this->setParameter('MemberToDel_Account', $member);
        return $this;
    }
797672
public function moveMember($member)
    {
        $deferred = new Deferred();

        if ($this->getChannelType() != self::TYPE_VOICE) {
            $deferred->reject(new \Exception('You cannot move a member in a text channel.'));

            return $deferred->promise();
        }

        if ($member instanceof Member) {
            $member = $member->id;
        }

        $this->http->patch(
            "guilds/{$this->guild_id}/members/{$member}",
            [
                'channel_id' => $this->id,
            ]
        )->then(
            \React\Partial\bind_right($this->resolve, $deferred),
            \React\Partial\bind_right($this->reject, $deferred)
        );

        // At the moment we are unable to check if the member
        // was moved successfully.

        return $deferred->promise();
    }
799968
public function mapMemberExpression(NestedMember $member) : MemberMapping
    {
        try {
            $subclassMappings = $this->findSubclassMappings(
                $this->rootEntityMapper,
                $member
            );

            $nestedRelations = $this->mapMemberExpressionsToRelations(
                $this->rootEntityMapper,
                $member->getPartsExceptLast(),
                $finalMapper
            );

            return $this->mapFinalMember($finalMapper, $subclassMappings, $nestedRelations, $member->getLastPart());
        } catch (BaseException $inner) {
            if ($inner instanceof MemberExpressionMappingException && $inner->getPrevious()) {
                $inner = $inner->getPrevious();
            }

            throw new MemberExpressionMappingException(
                sprintf(
                    'Could not map member expression \'%s\' of entity type %s: %s',
                    $member->asString(), $this->rootEntityMapper->getObjectType(), $inner->getMessage()
                ),
                1,
                $inner
            );
        }
    }