Skip to content

Commit

Permalink
mailFormLinkメソッド修正 (#3985)
Browse files Browse the repository at this point in the history
  • Loading branch information
CUkomori authored Nov 6, 2024
1 parent 1a533f3 commit 323b788
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/bc-blog/src/View/Helper/BlogHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
use BaserCore\Annotation\NoTodo;
use BaserCore\Annotation\Checked;
use BaserCore\Annotation\UnitTest;
use BcMail\View\Helper\MailHelper;

/**
* ブログヘルパー
Expand Down Expand Up @@ -1296,7 +1297,6 @@ public function getEyeCatch($post, $options = [])
*/
public function mailFormLink($title, $contentsName, $datas = [], $options = [])
{
App::uses('MailHelper', 'BcMail.View/Helper');
$MailHelper = new MailHelper($this->_View);
$MailHelper->link($title, $contentsName, $datas, $options);
}
Expand Down
21 changes: 19 additions & 2 deletions plugins/bc-mail/src/View/Helper/MailHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public function descriptionExists()

/**
* メールフォームへのリンクを生成する
* $contentsNameはコンテンツ管理上の1階層のみ対応
*
* @param string $title リンクのタイトル
* @param string $contentsName メールフォームのコンテンツ名
Expand All @@ -212,10 +213,26 @@ public function link($title, $contentsName, $datas = [], $options = [])
{
if ($datas && is_array($datas)) {
foreach ($datas as $key => $data) {
$datas[$key] = base64UrlsafeEncode($data);
$datas[$key] = BcUtil::base64UrlsafeEncode($data);
}
}
$link = array_merge(['plugin' => '', 'controller' => $contentsName, 'action' => 'index'], $datas);

$contentsTable = TableRegistry::getTableLocator()->get('BaserCore.Contents');
$content = $contentsTable->find('all')
->where([
'Contents.name' => $contentsName,
'Contents.plugin' => 'BcMail',
'Contents.type' => 'MailContent',
])
->first();

$link = [
'plugin' => 'BcMail',
'controller' => 'Mail',
'action' => 'index',
'entityId' => $content->entity_id,
'?' => $datas,
];
$this->BcBaser->link($title, $link, $options);
}

Expand Down

0 comments on commit 323b788

Please sign in to comment.