本文整理汇总了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;
}
}
}