Attach an node to the current object.

@param  AttachableInterface|ModelInterface $attachment An attachment or object.
@param  string                             $group      Attachment group, defaults to contents.
@return boolean|self
325670
public function addAttachment($attachment, $group = 'contents')
    {
        if (!$attachment instanceof AttachableInterface && !$attachment instanceof ModelInterface) {
            return false;
        }

        $join = $this->modelFactory()->create(Join::class);

        $objId   = $this->id();
        $objType = $this->objType();
        $attId   = $attachment->id();

        $join->setAttachmentId($attId);
        $join->setObjectId($objId);
        $join->setGroup($group);
        $join->setObjectType($objType);

        $join->save();

        return $this;
    }
899305
public function assignTo($group): void
    {
        $group = $this->resolveGroup($group);

        $this->groups()->attach($group);
    }
1150000
public function inline($asset, $content, $group = null)
    {
        $this->parent->inline($asset, $content, $this->mergePassedGroup($asset, $group));

        return $this;
    }
1033833
public function attach($returnType, $definition = null)
    {
        if (!$returnType instanceof TypeInterface) {
            $wrong = \is_object($returnType) ? 'instance of '.\get_class($returnType) : \gettype($returnType);

            throw new InvalidArgumentException(
                sprintf('Expecting an instance of %s, got %s', TypeInterface::class, $wrong)
            );
        }

        parent::attach($returnType, $definition);

        return $this;
    }
921089
public function attach($attach)
    {
        if (is_array($attach)) {
            $this->attach = $attach;
        } else {
            $this->attach = (array) $attach;
        }

        return $this;
    }
883667
public function attach($file)
    {
        if (empty($file)) {
            throw new MailerException('a file is required to use attach!');
        } elseif (!file_exists($file)) {
            throw new MailerException("$file does not exist!");
        }

        $this->_mailer->addAttachment($file);

        return $this;
    }
819536
public function attach($object)
    {
        $this->checkType($object);

        if (gettype($object) !== 'object') {
            $msg = "You can only attach 'objects' into an AbstractCollection, '" . gettype($object) . "' given";
            throw new InvalidArgumentException($msg);
        } elseif (!$this->contains($object)) {
            $this->offsetSet(null, $object);
        }
    }
262625
public function setGroup($group, $feature)
    {
        if (!isset($this->_aGroup[$group])) {
            $this->_aGroup[$group] = array();
        }
        if (!in_array($feature, $this->_aGroup[$group])) {
            $this->_aGroup[$group][] = $feature;
        }
        return $this;
    }
1133036
public function withAttachments($attachments)
    {
        if (! is_array($attachments)) {
            $attachments = [$attachments];
        }

        foreach ($attachments as $attachment) {
            $this->withAttachment($attachment);
        }

        return $this;
    }
1003572
public function setGroup(Group $group = null): FamilyPermission
    {
        $this->group = $group;
        if ($group && !$group->getFamilyPermissions()->contains($this)) {
            $group->getFamilyPermissions()->add($this);
        }

        return $this;
    }
850661
public function sendCreateGroupMail( $group ) {

		$fromEmail	= $this->mailProperties->getSenderEmail();
		$fromName	= $this->mailProperties->getSenderName();

		$email = Yii::$app->factory->get( 'groupService' )->getEmail( $group );

		if( !empty( $email ) ) {

			// Send Mail
			$this->getMailer()->compose( self::MAIL_GROUP_CREATE, [ 'coreProperties' => $this->coreProperties, 'group' => $group, 'email' => $email ] )
				->setTo( $email )
				->setFrom( [ $fromEmail => $fromName ] )
				->setSubject( "Group Registration | " . $this->coreProperties->getSiteName() )
				//->setTextBody( "text" )
				->send();
		}
	}
1008611
public function setGroup($groupName)
    {
        $tagGroup = TagGroup::where('slug', $this->taggingUtility->slug($groupName))->first();

        if ($tagGroup) {
            $this->group()->associate($tagGroup);
            $this->save();

            return $this;
        } else {
            throw new \RuntimeException('No Tag Group found: '. $groupName);
        }
    }
1281749
public function set_group( Field $group ) {
		$this->group = $group;

		$this->form    = $this->group->get_form();
		$this->storage = $this->group->get_storage();

		return $this;
	}
876533
public function inGroup(GroupInterface $group)
	{
		foreach ($this->getGroups() as $_group)
		{
			if ($_group->getId() == $group->getId())
			{
				return true;
			}
		}

		return false;
	}
972667
public function removeGroup(GroupInterface $group)
	{
		if ($this->inGroup($group))
		{
			$this->groups()->detach($group);
			$this->invalidateUserGroupsCache();
			$this->invalidateMergedPermissionsCache();
		}

		return true;
	}
1280001
public static function removeGroupContent(NodeInterface $node, Group $group) {
    // Try to load group content from entity.
    if ($group_contents = GroupContent::loadByEntity($node)) {
      /* @var @param \Drupal\group\Entity\GroupContent $group_content */
      foreach ($group_contents as $group_content) {
        if ($group->id() === $group_content->getGroup()->id()) {
          $group_content->delete();
        }
      }
    }
  }
186084
public function addGroup(Group $group)
    {
        if ($this->hasGroup($group)) {
            throw new \InvalidArgumentException(sprintf('Group "%s" is allready defined.', $group->getName()));
        }

        $this->groups[$group->getName()] = $group;

        return $this;
    }