@param FamilyPermission $familyPermission

@return $this
328601
public function removeFamilyPermission(FamilyPermission $familyPermission)
    {
        $this->familyPermissions->removeElement($familyPermission);
        $familyPermission->setUser(null);

        return $this;
    }
831502
public function addPermission(AbstractCompanyUserPermission $permission): bool
    {
        if (!empty($this->permissions)) {
            $this->permissions = array_merge($this->permissions, [$permission]);
        } else {
            $this->permissions = [$permission];
        }
        return $this->updateModel();
    }
406111
public function setPermissionRelatedByParentId(ChildPermission $v = null)
    {
        if ($v === null) {
            $this->setParentId(NULL);
        } else {
            $this->setParentId($v->getId());
        }

        $this->aPermissionRelatedByParentId = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the ChildPermission object, it will not be re-added.
        if ($v !== null) {
            $v->addPermissionRelatedById($this);
        }


        return $this;
    }
443310
public function getByParent(FamilyInterface $family)
    {
        $families = [];
        foreach ($this->families as $subFamily) {
            if ($subFamily->getParent() && $subFamily->getParent()->getCode() === $family->getCode()) {
                $families[$subFamily->getCode()] = $subFamily;
            }
        }

        return $families;
    }
1299244
private function addFamilyToCart(Family $family): void
    {
        $this->addRecordToCart($family);

        foreach ($family->spouses() as $spouse) {
            $this->addRecordToCart($spouse);
        }
    }
419065
public function listAction(Request $request, FamilyInterface $family)
    {
        $this->setFamily($family);
        $dataGrid = $this->getDataGrid();

        $this->bindDataGridRequest($dataGrid, $request);

        // Handle quick export directly in datagrid
        $form = $dataGrid->getForm();
        if ($form->isSubmitted() && $form->isValid()) {
            $button = $form->getClickedButton();
            if ($button && 'export' === $button->getName()) {
                return $this->redirectToExport($dataGrid, $request->getSession());
            }
        }

        return $this->renderAction(
            array_merge(
                $this->getViewParameters($request),
                ['datagrid' => $dataGrid]
            )
        );
    }
600138
public function setParent(ModelInterface $childModel, ModelInterface $parentModel)
    {
        $this->relationshipManager->setParent($childModel, $parentModel);

        return $this;
    }
882734
def _set_family_view(self, session):
        """"""
        if self._family_view == FEDERATED:
            try:
                session.use_federated_family_view()
            except AttributeError:
                pass
        else:
            try:
                session.use_isolated_family_view()
            except AttributeError:
                pass
214228
public function changeFamilyMembers(ServerRequestInterface $request, Tree $tree): ResponseInterface
    {
        $xref   = $request->get('xref', '');
        $family = Family::getInstance($xref, $tree);
        Auth::checkFamilyAccess($family, true);

        $title = I18N::translate('Change family members') . ' – ' . $family->fullName();

        return $this->viewResponse('edit/change-family-members', [
            'tree'     => $tree,
            'title'    => $title,
            'family'   => $family,
            'father'   => $family->husband(),
            'mother'   => $family->wife(),
            'children' => $family->children(),
        ]);
    }
1081550
protected function allowSingleGroupPermission($permission, $object, $group)
	{
		// check to see if the permission exists
		$permObject = $this->permission->findByPermissionAndObject($permission, $object);
		
		// if it doesn't, try to create it
		if(!$permObject)
		{
			$listOfPermissions = $object->getPermissions();
			
			// make sure the requested permission is valid on the model
			if(!isset($listOfPermissions[$permission]))
			{
				throw new \Exception("Permission ".$permission." doesn't exist on the ".get_class($object)." object.");
			}
			
			// create the permission
			$permObject = $this->permission->create(array(
				'name'			=> $listOfPermissions[$permission],
				'object_type'	=> get_class($object),
				'codename'		=> $permission,
			));
			
		}
		
		// check to see if the group already has permission on the object
		$gop = $this->groupObjectPermission->findPermission($group, $object, $permObject);
		
		// if it doesn't, give it permission
		if(!$gop)
		{
			$gop = $this->groupObjectPermission->create(array(
				'group_id'		=> $group->id,
				'object_type'	=> get_class($object),
				'object_id'		=> $object->id,
				'permission_id'	=> $permObject->id,
			));
		}
	}
529088
public function withFamilyFriendly($familyFriendly)
    {
        Assertion::same($familyFriendly, VideoInterface::FAMILY_FRIENDLY_NO);

        $instance = clone $this;

        $instance->familyFriendly = $familyFriendly;

        return $instance;
    }
1171852
public function getFamily(): FamilyInterface
    {
        $familyCode = $this->getConfiguration()->getOption('family');
        if (null === $familyCode) {
            throw new UnexpectedValueException(
                "Missing 'family' configuration option for {$this->getConfiguration()->getCode()}"
            );
        }

        return $this->familyRegistry->getFamily($familyCode);
    }
215045
public function syncPermissions($permissions)
    {
        $mappedPermissions = [];

        foreach ($permissions as $permission) {
            $mappedPermissions[] = Helper::getIdFor($permission, 'permission');
        }

        $changes = $this->permissions()->sync($mappedPermissions);
        $this->flushCache();
        $this->fireLaratrustEvent("permission.synced", [$this, $changes]);

        return $this;
    }
721743
public function grantPermission($accessEntityUuid, $accessEntityClass, $accessLevel, $grantedBy)
    {
        return $this->permissionsDataSource->grantPermission($accessEntityUuid, $accessEntityClass, $accessLevel, $grantedBy);
    }
217614
public function grant($perm, DataObject $to, $grant = 'GRANT')
    {
        return singleton('PermissionService')->grant($this->owner, $perm, $to, $grant);
    }
724260
public function setFamily(\Librinfo\VarietiesBundle\Entity\Family $family = null)
    {
        $this->family = $family;

        return $this;
    }
626157
public function detachPermission($permission)
    {
        $permission = Helper::getIdFor($permission, 'permission');

        $this->permissions()->detach($permission);
        $this->flushCache();
        $this->fireLaratrustEvent("permission.detached", [$this, $permission]);

        return $this;
    }