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


PHP CakeEmail::addAttachments方法代码示例

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


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

示例1: _rotate

 protected function _rotate($config)
 {
     // do rotation
     $path = $config['path'];
     for ($i = $config['keep']; $i >= 0; $i--) {
         switch (true) {
             case $i == $config['keep']:
                 $SrcFile = $this->_getFile($path, $i);
                 if (!$SrcFile->exists()) {
                     continue;
                 }
                 // send report mail
                 if ($config['email_to']) {
                     try {
                         //TODO use dependency injection
                         //TODO use backend-wide email report settings
                         $email = new CakeEmail(array('transport' => 'Mail', 'from' => 'report@' . gethostname(), 'to' => $config['email_to'], 'subject' => 'Log report', 'emailFormat' => 'text', 'template' => false, 'layout' => false));
                         $email->addAttachments($SrcFile->path);
                         $email->send('Log file attached');
                     } catch (Exception $e) {
                         CakeLog::warning('LogRotation::rotate() - ' . $e->getMessage(), 'backend');
                     }
                 }
                 break;
             case $i > 0:
                 $SrcFile = $this->_getFile($path, $i);
                 if (!$SrcFile->exists()) {
                     continue;
                 }
                 if (!$config['rotate_empty'] && $SrcFile->size() < 1) {
                     #if (!$SrcFile->delete())
                     #	$this->log[] = "Failed to delete file";
                     continue;
                 }
                 $NewFile = $this->_getFile($path, $i + 1, true);
                 if (!$NewFile->write($SrcFile->read())) {
                     throw new Exception("Failed to copy log {$path}.'.'.{$i}");
                 }
                 if ($i == 1 && !$config['compress'] && $config['compress_delay']) {
                     $this->_compress($NewFile);
                 }
                 break;
             case $i == 0:
                 $SrcFile = $this->_getFile($path);
                 if (!$config['rotate_empty'] && $SrcFile->size() < 1) {
                     continue;
                 }
                 $NewFile = $this->_getFile($path, $i + 1, true);
                 if (!$NewFile->write($SrcFile->read())) {
                     throw new Exception("Failed to copy log {$path}");
                 }
                 if ($config['compress']) {
                     $this->_compress($NewFile);
                 }
                 if (!$SrcFile->write("")) {
                     throw new Exception("Failed to create empty log {$path}");
                 }
                 break;
             default:
                 throw new Exception("Fatal Error");
                 break;
         }
     }
 }
开发者ID:fm-labs,项目名称:cakephp-backend,代码行数:64,代码来源:LogRotation.php


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