当前位置: 首页>>代码示例>>PHP>>正文


PHP Attachment::setType方法代码示例

本文整理汇总了PHP中Attachment::setType方法的典型用法代码示例。如果您正苦于以下问题:PHP Attachment::setType方法的具体用法?PHP Attachment::setType怎么用?PHP Attachment::setType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Attachment的用法示例。


在下文中一共展示了Attachment::setType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: body

 protected function body()
 {
     $inputs = array('lecture' => 'isIndex', 'name' => array('isName', 'isNotEmpty'), 'type' => array('isEnum' => array('text', 'code', 'image')));
     if (!$this->isInputValid($inputs)) {
         return false;
     }
     $lectureId = $this->getParams('lecture');
     /** @var \Lecture $lecture */
     $lecture = Repositories::findEntity(Repositories::Lecture, $lectureId);
     $name = $this->getParams('name');
     $type = $this->getParams('type');
     $id = $this->getParams('id');
     $isIdSet = $id !== null && $id !== '';
     $originalName = $this->getUploadedFileName('file');
     if (!$originalName) {
         return false;
     }
     $extensionStart = strrpos($originalName, '.');
     $extension = $extensionStart === false ? '' : substr($originalName, strrpos($originalName, '.'));
     $attachmentFolder = Config::get('paths', 'attachments');
     $filename = $id . '_' . $name . $extension;
     if (!$this->checkTestGenerationPrivileges($lecture)) {
         return $this->death(StringID::InsufficientPrivileges);
     }
     /**
      * @var $attachment \Attachment
      */
     $attachment = null;
     if (!$this->saveUploadedFile('file', $attachmentFolder . $filename)) {
         return $this->death(StringID::InsufficientPrivileges);
     }
     /** @var \Attachment[] $attachmentsWithThisName */
     $attachmentsWithThisName = Repositories::getRepository(Repositories::Attachment)->findBy(['lecture' => $lectureId, 'name' => $name]);
     if ($isIdSet) {
         $attachment = Repositories::findEntity(Repositories::Attachment, $id);
         if (count($attachmentsWithThisName) > 0) {
             if ($attachmentsWithThisName[0]->getId() !== $attachment->getId()) {
                 return $this->death(StringID::AttachmentExists);
             }
         }
     } else {
         if (count($attachmentsWithThisName) > 0) {
             return $this->death(StringID::AttachmentExists);
         }
         $attachment = new \Attachment();
     }
     $attachment->setType($type);
     $attachment->setLecture($lecture);
     $attachment->setName($name);
     $attachment->setFile($filename);
     Repositories::persistAndFlush($attachment);
     return true;
 }
开发者ID:pombredanne,项目名称:xmlcheck-public,代码行数:53,代码来源:EditAttachment.php

示例2: testKitchenSinkExample

 public function testKitchenSinkExample()
 {
     $mail = new Mail();
     $email = new Email("DX", "test@example.com");
     $mail->setFrom($email);
     $mail->setSubject("Hello World from the SendGrid PHP Library");
     $personalization = new Personalization();
     $email = new Email("Example User", "test@example.com");
     $personalization->addTo($email);
     $email = new Email("Example User", "test@example.com");
     $personalization->addTo($email);
     $email = new Email("Example User", "test@example.com");
     $personalization->addCc($email);
     $email = new Email("Example User", "test@example.com");
     $personalization->addCc($email);
     $email = new Email("Example User", "test@example.com");
     $personalization->addBcc($email);
     $email = new Email("Example User", "test@example.com");
     $personalization->addBcc($email);
     $personalization->setSubject("Hello World from the SendGrid PHP Library");
     $personalization->addHeader("X-Test", "test");
     $personalization->addHeader("X-Mock", "true");
     $personalization->addSubstitution("%name%", "Example User");
     $personalization->addSubstitution("%city%", "Denver");
     $personalization->addCustomArg("user_id", "343");
     $personalization->addCustomArg("type", "marketing");
     $personalization->setSendAt(1443636843);
     $mail->addPersonalization($personalization);
     $personalization2 = new Personalization();
     $email = new Email("Example User", "test@example.com");
     $personalization2->addTo($email);
     $email = new Email("Example User", "test@example.com");
     $personalization2->addTo($email);
     $email = new Email("Example User", "test@example.com");
     $personalization2->addCc($email);
     $email = new Email("Example User", "test@example.com");
     $personalization2->addCc($email);
     $email = new Email("Example User", "test@example.com");
     $personalization2->addBcc($email);
     $email = new Email("Example User", "test@example.com");
     $personalization2->addBcc($email);
     $personalization2->setSubject("Hello World from the SendGrid PHP Library");
     $personalization2->addHeader("X-Test", "test");
     $personalization2->addHeader("X-Mock", "true");
     $personalization2->addSubstitution("%name%", "Example User");
     $personalization2->addSubstitution("%city%", "Denver");
     $personalization2->addCustomArg("user_id", "343");
     $personalization2->addCustomArg("type", "marketing");
     $personalization2->setSendAt(1443636843);
     $mail->addPersonalization($personalization2);
     $content = new Content("text/plain", "some text here");
     $mail->addContent($content);
     $content = new Content("text/html", "<html><body>some text here</body></html>");
     $mail->addContent($content);
     $attachment = new Attachment();
     $attachment->setContent("TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12");
     $attachment->setType("application/pdf");
     $attachment->setFilename("balance_001.pdf");
     $attachment->setDisposition("attachment");
     $attachment->setContentId("Balance Sheet");
     $mail->addAttachment($attachment);
     $attachment2 = new Attachment();
     $attachment2->setContent("BwdW");
     $attachment2->setType("image/png");
     $attachment2->setFilename("banner.png");
     $attachment2->setDisposition("inline");
     $attachment2->setContentId("Banner");
     $mail->addAttachment($attachment2);
     $mail->setTemplateId("439b6d66-4408-4ead-83de-5c83c2ee313a");
     $mail->addSection("%section1%", "Substitution Text for Section 1");
     $mail->addSection("%section2%", "Substitution Text for Section 2");
     $mail->addHeader("X-Test1", "1");
     $mail->addHeader("X-Test2", "2");
     $mail->addCategory("May");
     $mail->addCategory("2016");
     $mail->addCustomArg("campaign", "welcome");
     $mail->addCustomArg("weekday", "morning");
     $mail->setSendAt(1443636842);
     $asm = new ASM();
     $asm->setGroupId(99);
     $asm->setGroupsToDisplay([4, 5, 6, 7, 8]);
     $mail->setASM($asm);
     $mail->setIpPoolName("23");
     $mail_settings = new MailSettings();
     $bcc_settings = new BccSettings();
     $bcc_settings->setEnable(True);
     $bcc_settings->setEmail("test@example.com");
     $mail_settings->setBccSettings($bcc_settings);
     $sandbox_mode = new SandBoxMode();
     $sandbox_mode->setEnable(True);
     $mail_settings->setSandboxMode($sandbox_mode);
     $bypass_list_management = new BypassListManagement();
     $bypass_list_management->setEnable(True);
     $mail_settings->setBypassListManagement($bypass_list_management);
     $footer = new Footer();
     $footer->setEnable(true);
     $footer->setText("Footer Text");
     $footer->setHtml("<html><body>Footer Text</body></html>");
     $mail_settings->setFooter($footer);
     $spam_check = new SpamCheck();
//.........这里部分代码省略.........
开发者ID:jrdncchr,项目名称:merlinleads,代码行数:101,代码来源:MailTest.php

示例3: kitchenSink

function kitchenSink()
{
    $mail = new Mail();
    $email = new Email("DX", "test@example.com");
    $mail->setFrom($email);
    $mail->setSubject("Hello World from the SendGrid PHP Library");
    $personalization = new Personalization();
    $email = new Email("Example User", "test1@example.com");
    $personalization->addTo($email);
    $email = new Email("Example User", "test2@example.com");
    $personalization->addTo($email);
    $email = new Email("Example User", "test3@example.com");
    $personalization->addCc($email);
    $email = new Email("Example User", "test4@example.com");
    $personalization->addCc($email);
    $email = new Email("Example User", "test5@example.com");
    $personalization->addBcc($email);
    $email = new Email("Example User", "test6@example.com");
    $personalization->addBcc($email);
    $personalization->setSubject("Hello World from the SendGrid PHP Library");
    $personalization->addHeader("X-Test", "test");
    $personalization->addHeader("X-Mock", "true");
    $personalization->addSubstitution("%name%", "Example User");
    $personalization->addSubstitution("%city%", "Denver");
    $personalization->addCustomArg("user_id", "343");
    $personalization->addCustomArg("type", "marketing");
    $personalization->setSendAt(1443636843);
    $mail->addPersonalization($personalization);
    $personalization2 = new Personalization();
    $email = new Email("Example User", "test1@example.com");
    $personalization2->addTo($email);
    $email = new Email("Example User", "test2@example.com");
    $personalization2->addTo($email);
    $email = new Email("Example User", "test3@example.com");
    $personalization2->addCc($email);
    $email = new Email("Example User", "test4@example.com");
    $personalization2->addCc($email);
    $email = new Email("Example User", "test5@example.com");
    $personalization2->addBcc($email);
    $email = new Email("Example User", "test6@example.com");
    $personalization2->addBcc($email);
    $personalization2->setSubject("Hello World from the SendGrid PHP Library");
    $personalization2->addHeader("X-Test", "test");
    $personalization2->addHeader("X-Mock", "true");
    $personalization2->addSubstitution("%name%", "Example User");
    $personalization2->addSubstitution("%city%", "Denver");
    $personalization2->addCustomArg("user_id", "343");
    $personalization2->addCustomArg("type", "marketing");
    $personalization2->setSendAt(1443636843);
    $mail->addPersonalization($personalization2);
    $content = new Content("text/plain", "some text here");
    $mail->addContent($content);
    $content = new Content("text/html", "<html><body>some text here</body></html>");
    $mail->addContent($content);
    $attachment = new Attachment();
    $attachment->setContent("TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12");
    $attachment->setType("application/pdf");
    $attachment->setFilename("balance_001.pdf");
    $attachment->setDisposition("attachment");
    $attachment->setContentId("Balance Sheet");
    $mail->addAttachment($attachment);
    $attachment2 = new Attachment();
    $attachment2->setContent("BwdW");
    $attachment2->setType("image/png");
    $attachment2->setFilename("banner.png");
    $attachment2->setDisposition("inline");
    $attachment2->setContentId("Banner");
    $mail->addAttachment($attachment2);
    $mail->setTemplateId("439b6d66-4408-4ead-83de-5c83c2ee313a");
    # This must be a valid [batch ID](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html) to work
    # $mail->setBatchID("sengrid_batch_id");
    $mail->addSection("%section1%", "Substitution Text for Section 1");
    $mail->addSection("%section2%", "Substitution Text for Section 2");
    $mail->addHeader("X-Test1", "1");
    $mail->addHeader("X-Test2", "2");
    $mail->addCategory("May");
    $mail->addCategory("2016");
    $mail->addCustomArg("campaign", "welcome");
    $mail->addCustomArg("weekday", "morning");
    $mail->setSendAt(1443636842);
    $asm = new ASM();
    $asm->setGroupId(99);
    $asm->setGroupsToDisplay([4, 5, 6, 7, 8]);
    $mail->setASM($asm);
    $mail->setIpPoolName("23");
    $mail_settings = new MailSettings();
    $bcc_settings = new BccSettings();
    $bcc_settings->setEnable(true);
    $bcc_settings->setEmail("test@example.com");
    $mail_settings->setBccSettings($bcc_settings);
    $sandbox_mode = new SandBoxMode();
    $sandbox_mode->setEnable(true);
    $mail_settings->setSandboxMode($sandbox_mode);
    $bypass_list_management = new BypassListManagement();
    $bypass_list_management->setEnable(true);
    $mail_settings->setBypassListManagement($bypass_list_management);
    $footer = new Footer();
    $footer->setEnable(true);
    $footer->setText("Footer Text");
    $footer->setHtml("<html><body>Footer Text</body></html>");
//.........这里部分代码省略.........
开发者ID:ATCS-BCA,项目名称:bca-apps,代码行数:101,代码来源:example.php

示例4: Email

<?php

// If you are using Composer
namespace SendGrid;

require 'vendor/autoload.php';
$uid = $argv[1];
$receiver = $argv[2];
$str = file_get_contents('/var/www/config.json');
$jsonData = json_decode($str, true);
echo $jsonData['api'];
$from = new Email(null, $jsonData['sender']);
$subject = "Hello World from the SendGrid PHP Library!";
$to = new Email(null, $argv[2]);
$content = new Content("text/plain", $jsonData['body'] . $uid);
$mail = new Mail($from, $subject, $to, $content);
$attachment = new Attachment();
$attachment->setContent(base64_encode("/var/www/html/release" . $uid . "/releaseapk.apk"));
$attachment->setFilename("balance_001.apk");
$attachment->setDisposition("attachment");
$attachment->setType("application/vnd.android.package-archive");
$attachment->setContentId("app");
$mail->addAttachment($attachment);
$apiKey = $jsonData['api'];
$sg = new \SendGrid($apiKey);
$response = $sg->client->mail()->send()->post($mail);
echo $response->statusCode();
echo $response->headers();
echo $response->body();
开发者ID:sch00lb0y,项目名称:open-event-android,代码行数:29,代码来源:email.php


注:本文中的Attachment::setType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。