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


PHP EmailTemplate::validate方法代码示例

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


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

示例1: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     if (!isset($_SESSION['filemanager'])) {
         $_SESSION['filemanager'] = TRUE;
     }
     $_SESSION['currentFolder'] = 'emailTemplate/';
     $model = new EmailTemplate('create');
     if (isset($_POST['EmailTemplate'])) {
         $model->attributes = $_POST['EmailTemplate'];
         if ($model->validate()) {
             if ($model->save()) {
                 Yii::app()->user->setFlash('success', Yii::t('emailTemplate', 'Add emailTemplate successfully.'));
             } else {
                 Yii::app()->user->setFlash('error', Yii::t('emailTemplate', 'Add emailTemplate failed. Please try it later.'));
             }
             $this->redirect(array('/' . backend . '/emailTemplate/admin'));
         }
     }
     $this->render(strtolower($this->action->Id), array('model' => $model));
 }
开发者ID:huuly188,项目名称:vietnamrealty,代码行数:24,代码来源:EmailTemplateController.php

示例2: testGetData

 public function testGetData()
 {
     $moduleClassName = Contact::getModuleClassName();
     $type = Report::TYPE_ROWS_AND_COLUMNS;
     $treeType = ComponentForReportForm::TYPE_FILTERS;
     $report = new Report();
     $report->setModuleClassName($moduleClassName);
     $report->setType($type);
     $reportToTreeAdapter = new MergeTagsReportRelationsAndAttributesToTreeAdapter($report, $treeType, 'EmailTemplate');
     $emailTemplate = new EmailTemplate();
     $emailTemplate->type = EmailTemplate::TYPE_CONTACT;
     $emailTemplate->subject = 'Another Test subject';
     $emailTemplate->name = 'Another Test Email Template';
     $emailTemplate->textContent = 'Text Content ';
     $emailTemplate->htmlContent = 'Html Content ';
     $emailTemplate->builtType = EmailTemplate::BUILT_TYPE_PASTED_HTML;
     $emailTemplate->modelClassName = 'Contact';
     // By testing the getData method we're actually testing that all Merge Tags are valid
     // and that we can save the EmailTemplate with each Merge Tag without having the error 'Invalid Merge Tag'.
     $data = $reportToTreeAdapter->getData('source');
     foreach ($data[1]['children'] as $child) {
         if (isset($child['dataValue']) && $child['dataValue']) {
             $emailTemplate->textContent .= ' ' . $child['dataValue'];
             $emailTemplate->htmlContent .= ' ' . $child['dataValue'];
         }
     }
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertTrue($emailTemplate->save());
     $data = $reportToTreeAdapter->getData('EmailTemplate_createdByUser');
     $emailTemplate->textContent = '';
     $emailTemplate->htmlContent = '';
     foreach ($data as $child) {
         if (isset($child['dataValue']) && $child['dataValue']) {
             $emailTemplate->textContent .= ' ' . $child['dataValue'];
             $emailTemplate->htmlContent .= ' ' . $child['dataValue'];
         }
     }
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertTrue($emailTemplate->save());
     $data = $reportToTreeAdapter->getData('EmailTemplate_owner');
     $emailTemplate->textContent = '';
     $emailTemplate->htmlContent = '';
     foreach ($data as $child) {
         if (isset($child['dataValue']) && $child['dataValue']) {
             $emailTemplate->textContent .= ' ' . $child['dataValue'];
             $emailTemplate->htmlContent .= ' ' . $child['dataValue'];
         }
     }
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertTrue($emailTemplate->save());
     $data = $reportToTreeAdapter->getData('EmailTemplate_owner___primaryEmail');
     $emailTemplate->textContent = '';
     $emailTemplate->htmlContent = '';
     foreach ($data as $child) {
         if (isset($child['dataValue']) && $child['dataValue']) {
             $emailTemplate->textContent .= ' ' . $child['dataValue'];
             $emailTemplate->htmlContent .= ' ' . $child['dataValue'];
         }
     }
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertTrue($emailTemplate->save());
     $data = $reportToTreeAdapter->getData('EmailTemplate_primaryAddress');
     $emailTemplate->textContent = '';
     $emailTemplate->htmlContent = '';
     foreach ($data as $child) {
         if (isset($child['dataValue']) && $child['dataValue']) {
             $emailTemplate->textContent .= ' ' . $child['dataValue'];
             $emailTemplate->htmlContent .= ' ' . $child['dataValue'];
         }
     }
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertTrue($emailTemplate->save());
     // Test against invalid Merge Tags
     $emailTemplate->textContent = 'Text Content [[TEXT__INVALID^MERGE^TAG]]';
     $emailTemplate->htmlContent = 'Html Content [[HTMLINVALIDMERGETAG]]';
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertFalse($validated);
     $errorMessages = $emailTemplate->getErrors();
     $this->assertEquals(2, count($errorMessages));
     $this->assertTrue(array_key_exists('textContent', $errorMessages));
     $this->assertTrue(array_key_exists('htmlContent', $errorMessages));
     $this->assertEquals(1, count($errorMessages['textContent']));
     $this->assertEquals(1, count($errorMessages['htmlContent']));
     $this->assertContains('TEXT__INVALID^MERGE^TAG', $errorMessages['textContent'][0]);
     $this->assertContains('HTMLINVALIDMERGETAG', $errorMessages['htmlContent'][0]);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:96,代码来源:MergeTagsReportRelationsAndAttributesToTreeAdapterTest.php

示例3: testDummyHtmlContentThrowsValidationErrorWhenTextContentIsEmpty

 /**
  * @depends testCreateAndGetEmailTemplateById
  */
 public function testDummyHtmlContentThrowsValidationErrorWhenTextContentIsEmpty()
 {
     $emailTemplate = new EmailTemplate();
     $emailTemplate->type = EmailTemplate::TYPE_CONTACT;
     $emailTemplate->builtType = EmailTemplate::BUILT_TYPE_PASTED_HTML;
     $emailTemplate->subject = 'Another Test subject';
     $emailTemplate->name = 'Another Test Email Template';
     $emailTemplate->textContent = '';
     $emailTemplate->htmlContent = "<html>\n<head>\n</head>\n<body>\n</body>\n</html>";
     $emailTemplate->modelClassName = 'Contact';
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertFalse($validated);
     $errorMessages = $emailTemplate->getErrors();
     $this->assertEquals(1, count($errorMessages));
     $this->assertTrue(array_key_exists('textContent', $errorMessages));
     $this->assertEquals(1, count($errorMessages['textContent']));
     $this->assertEquals('Please provide at least one of the contents field.', $errorMessages['textContent'][0]);
     $emailTemplate->textContent = 'Text Content';
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertTrue($emailTemplate->save());
     $this->assertEquals(6, EmailTemplate::getCount());
     $id = $emailTemplate->id;
     unset($emailTemplate);
     $emailTemplate = EmailTemplate::getById($id);
     $this->assertEquals(EmailTemplate::TYPE_CONTACT, $emailTemplate->type);
     $this->assertEquals('Another Test subject', $emailTemplate->subject);
     $this->assertEquals('Another Test Email Template', $emailTemplate->name);
     $this->assertEquals(null, $emailTemplate->htmlContent);
     $this->assertEquals('Text Content', $emailTemplate->textContent);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:34,代码来源:EmailTemplateTest.php


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