Add attachments

@param string|array $attachments String with the filename or array with filenames
@return $this
@throws \InvalidArgumentException
@see \Cake\Mailer\Email::attachments()
166392
public function addAttachments($attachments)
    {
        $current = $this->_attachments;
        $this->setAttachments($attachments);
        $this->_attachments = array_merge($current, $this->_attachments);

        return $this;
    }
110334
public function setWidgets(array $widgets)
    {
        foreach ($widgets as $widgetIdent => $widgetStruct) {
            if (!is_array($widgetStruct)) {
                throw new InvalidArgumentException(sprintf(
                    'The attachment widget "%s" must be an array of widget settings',
                    $widgetIdent
                ));
            }

            if (isset($widgetStruct['ident'])) {
                $widgetIdent = $widgetStruct['ident'];
                unset($widgetStruct['ident']);
            }

            if (!is_string($widgetIdent)) {
                throw new InvalidArgumentException(
                    'The attachment widget identifier must be a string'
                );
            }

            $this->widgets[$widgetIdent] = $widgetStruct;
        }

        return $this;
    }
882466
public final function withUploadedFiles(
       array $uploadedFiles): ServerRequestInterface
   {
       foreach ($uploadedFiles as &$value) {
           if (!$value instanceof UploadedFileInterface) {
               throw new InvalidArgumentException(
                   "Can't get instance: "
                 . "must implement UploadedFileInterface");
           }
       }
       return $this->with("uploadedFiles", $uploadedFiles);
   }
162578
public function setAttachmentDefaults($defaults)
    {
        if ($this->attachmentDefaults != ($defaults = (array) $defaults)) {
            $this->attachmentDefaults = $defaults;

            $this->setAttachments($this->attachments);
        }

        return $this;
    }
654864
public function addAttachment($file, $name = null)
    {
        $this->_attachments[] = ['file' => $file, 'name' => $name ?: basename($file)];
        return $this;
    }
601080
public function attach($attachment)
    {

        // if string
        if (is_string($attachment)) {
            $attachment = [$attachment, ''];
        }

        // if array
        if (is_array($attachment)) {
            list($name, $type) = $attachment;
        }

        if ($attachment instanceof PhpMailerAttachmentInterface) {
            $filename = $attachment->getFile();
            $name = ($attachment->getNewName()) ? $attachment->getNewName() : $filename;
            $type = $attachment->getType();
        }


        $this->mailer->addAttachment($filename, $name, 'base64', $type);
        return $this;

    }
650107
public function addAttachment($attachment)
    {
        if ($attachment instanceof \SplFileObject && $attachment->isFile() && $attachment->isReadable()) {
            $file['filename'] = method_exists($attachment, 'getAttachmentFilename') ?
                $attachment->getAttachmentFilename() :
                $attachment->getBasename();

            $file['is_embedded'] = method_exists($attachment, 'getIsEmbedded') ? $attachment->getIsEmbedded() : false;
            $file['id'] = method_exists($attachment, 'getId') ? $attachment->getId() : null;

            if (method_exists($attachment, 'getMimeType')) {
                $file['mime_type'] = $attachment->getMimeType();
            } else {
                $resource = finfo_open(FILEINFO_MIME_TYPE);
                $file['mime_type'] = finfo_file($resource, $attachment->getRealPath());
            }

            $file['contents'] = '';
            while (!$attachment->eof()) {
                $file['contents'] .= $attachment->fgets();
            }
            $file['contents'] = base64_encode($file['contents']);

            $this->attachments[] = $file;
        } elseif (is_array($attachment)) {
            $this->attachments[] = $attachment;
        }

        return $this;
    }
929025
public function attachments()
    {
        $files = func_get_args();

        foreach ($files as $file) {
            if (is_string($file)) {
                $this->_attachments[] = ['file' => $file];
            } elseif (is_array($file)) {
                foreach ($file as $key => $value) {
                    $this->_attachments[] = ['name' => $key, 'file' => $value];
                }
            }
        }

        return $this;
    }
695123
public function attach($attachment)
    {
        if ($attachment instanceof Attachment) {
            $this->attachments[] = $attachment;

            return $this;
        } elseif (is_array($attachment)) {
            $attachmentObject = new Attachment($attachment);

            if (! isset($attachment['mrkdwn_in'])) {
                $attachmentObject->setMarkdownFields($this->getMarkdownInAttachments());
            }

            $this->attachments[] = $attachmentObject;

            return $this;
        }

        throw new InvalidArgumentException('Attachment must be an instance of Maknz\\Slack\\Attachment or a keyed array');
    }
114274
public function setFileData(array $files)
    {
        $files = $this->deflateFilesArray($files);

        $this->fileUploads = [];

        foreach ($files as $key => $fileData) {
            $uploadObj = FileUpload::createFromFileArray($fileData);

            if (!empty($uploadObj)) {
                $this->fileUploads[$key] = $uploadObj;
            }
        }

        return $this;
    }
1083936
public function setAttachables(array $attachables)
    {
        foreach ($attachables as $attType => $attStruct) {
            if (!is_array($attStruct)) {
                throw new InvalidArgumentException(sprintf(
                    'The attachment structure for "%s" must be an array',
                    $attType
                ));
            }

            if (isset($attStruct['attachment_type'])) {
                $attType = $attStruct['attachment_type'];
            } else {
                $attStruct['attachment_type'] = $attType;
            }

            if (!is_string($attType)) {
                throw new InvalidArgumentException(
                    'The attachment type must be a string'
                );
            }

            $this->attachables[$attType] = $attStruct;
        }

        return $this;
    }
240386
public function setLinks(array $links)
    {
        $this->links = new ArrayIterator();

        foreach ($links as $linkIdent => $link) {
            $this->addLink($linkIdent, $link);
        }

        return $this;
    }
1287034
protected function prepareAttachment(array $files) {
    $attachments = NULL;

    foreach ($files as $file) {
      $description = '';

      // If it is an array, this means we also have a description.
      if (is_array($file)) {
        $uuid = key($file);
        $description = current($file);
      }
      else {
        $uuid = $file;
      }

      $object = $this->fileStorage->loadByProperties([
        'uuid' => $uuid,
      ]);

      if ($object) {
        $properties = [
          'target_id' => current($object)->id(),
          'description' => $description,
        ];

        $attachments[] = $properties;
      }
    }

    return $attachments;
  }
16884
private function setAttachments()
    {
        $attachments = $this->mailable->get('_attachments');

        if (!is_null($attachments)) {
            foreach ($attachments as $attachment) {
                if (in_array('name')) {
                    $this->message->attach(Attachment::fromPath($attachment['file'])->setFilename($attachment['name']));
                } else {
                    $this->message->attach(Attachment::fromPath($attachment['file']));
                }
            }
        }
    }
1144220
public function attach(array $files)
    {
        foreach ($files as $key => $file) {
            if (is_array($file)) {
                $file = new UploadedFile($file['path'], basename($file['path']), $file['mime'], $file['size']);
            } elseif (is_string($file)) {
                $finfo = finfo_open(FILEINFO_MIME_TYPE);

                $file = new UploadedFile($file, basename($file), finfo_file($finfo, $file), $this->files->size($file));
            } elseif (! $file instanceof UploadedFile) {
                continue;
            }

            $this->uploads[$key] = $file;
        }

        return $this;
    }
774860
public function add($nodes) {
    if ($nodes instanceof Node) {
      $this->nodes[] = $nodes;
    }
    elseif ($nodes instanceof NodeCollection) {
      $this->nodes = array_merge($this->nodes, $nodes->nodes);
    }
    elseif (is_array($nodes)) {
      $this->nodes = array_merge($this->nodes, $nodes);
    }
    else {
      throw new \InvalidArgumentException();
    }
    $this->nodes = static::sortUnique($this->nodes);
    return $this;
  }
1139159
function setAttachment(string $attachment, string $filename = '') {
        $this->attachment = $attachment;
        $this->filename = $filename;
        return $this;
    }