Skip to content

Commit

Permalink
Merge branch 'dev-5' into dev-#2773
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Oct 28, 2023
2 parents e90d4f6 + a76d8e5 commit b4a8217
Show file tree
Hide file tree
Showing 21 changed files with 172 additions and 184 deletions.
223 changes: 112 additions & 111 deletions composer.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions plugins/baser-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<a href="LICENSE" target="_blank">
<img alt="Software License" src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square">
</a>
<a href="https://github.com/baserproject/ucmitz/actions/workflows/test.yml" target="_blank">
<img alt="Build Status" src="https://github.com/baserproject/ucmitz/actions/workflows/test.yml/badge.svg?branch=dev">
<a href="https://github.com/baserproject/basercms/actions/workflows/test.yml" target="_blank">
<img alt="Build Status" src="https://github.com/baserproject/basercms/actions/workflows/test.yml/badge.svg?branch=dev-5">
</a>
</p>

Expand Down
22 changes: 11 additions & 11 deletions plugins/baser-core/src/Controller/Admin/SitesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
use BaserCore\Service\Admin\SitesAdminServiceInterface;
use BaserCore\Service\SiteConfigsServiceInterface;
use BaserCore\Service\SitesServiceInterface;
use BaserCore\Service\ThemesServiceInterface;
use BaserCore\Utility\BcSiteConfig;
use Cake\Core\Exception\Exception;
use BaserCore\Annotation\Note;
use BaserCore\Annotation\NoTodo;
use BaserCore\Annotation\Checked;
use BaserCore\Annotation\UnitTest;
use Cake\Http\Exception\NotFoundException;
use Cake\ORM\Exception\PersistenceFailedException;
use Psr\Http\Message\ResponseInterface;

/**
Expand Down Expand Up @@ -66,11 +68,15 @@ public function index(SitesAdminServiceInterface $service)
* サイト追加
*
* @param SiteConfigsServiceInterface $service
* @return void|ResponseInterface
* @checked
* @unitTest
* @note(value="インストーラーを実装してからテーマの保有するプラグインをインストールする処理を追加する")
* @noTodo
*/
public function add(SitesAdminServiceInterface $service)
public function add(
SitesAdminServiceInterface $service,
ThemesServiceInterface $themesService
)
{
if ($this->request->is('post')) {

Expand All @@ -84,26 +90,20 @@ public function add(SitesAdminServiceInterface $service)

try {
$site = $service->create($this->request->getData());

// EVENT Sites.afterAdd
$this->dispatchLayerEvent('afterAdd', [
'data' => $site
]);

// TODO ucmitz 未実装のためコメントアウト
/* >>>
if (!empty($site->theme)) {
$this->BcManager->installThemesPlugins($site->theme);
}
<<< */

if ($site->theme) $themesService->installThemesPlugins($site->theme);
$this->BcMessage->setSuccess(sprintf(__d('baser_core', 'サイト「%s」を追加しました。'), $site->display_name));
return $this->redirect(['action' => 'edit', $site->id]);
} catch (\Cake\ORM\Exception\PersistenceFailedException $e) {
} catch (PersistenceFailedException $e) {
$site = $e->getEntity();
$this->BcMessage->setError(__d('baser_core', '入力エラーです。内容を修正してください。'));
}
}

$this->set($service->getViewVarsForAdd($site ?? $service->getNew()));
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/baser-core/src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ public function services(ContainerInterface $container): void
* @param CommandCollection $commands
* @return CommandCollection
* @checked
* @checked
* @noTodo
*/
public function console(CommandCollection $commands): CommandCollection
{
Expand Down
4 changes: 2 additions & 2 deletions plugins/baser-core/src/Service/ThemesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,11 @@ private function getThemesDefaultDataInfo(string $theme, array $info = [])
* @unitTest
* @noTodo
*/
private function installThemesPlugins(string $theme)
public function installThemesPlugins(string $theme)
{
/* @var PluginsService $pluginsService */
$pluginsService = $this->getService(PluginsServiceInterface::class);
$plugins = BcUtil::getCurrentThemesPlugins();
$plugins = BcUtil::getThemesPlugins($theme);
// テーマ梱包のプラグインをインストール
foreach($plugins as $plugin) {
$pluginsService->install($plugin);
Expand Down
16 changes: 8 additions & 8 deletions plugins/baser-core/src/Utility/BcAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace BaserCore\Utility;
use BaserCore\Annotation\Checked;
use BaserCore\Annotation\UnitTest;
use BaserCore\Annotation\NoTodo;

/**
* Class BcAgent
Expand Down Expand Up @@ -48,7 +49,7 @@ class BcAgent extends BcAbstractDetector
*
* @checked
* @unitTest
* @noTodo
*/
protected function _setConfig(array $config)
{
Expand All @@ -58,11 +59,11 @@ protected function _setConfig(array $config)

/**
* デフォルトの設定値を取得
* @checked
* @unitTest
*
* @return array
* @checked
* @unitTest
* @noTodo
*/
protected function _getDefaultConfig()
{
Expand All @@ -75,10 +76,10 @@ protected function _getDefaultConfig()
/**
* ユーザーエージェントの判定用正規表現を取得
*
* @return string
* @checked
* @unitTest
*
* @return string
* @noTodo
*/
public function getDetectorRegex()
{
Expand All @@ -89,10 +90,9 @@ public function getDetectorRegex()
/**
* ユーザーエージェントがキーワードを含むかどうかを判定
*
* @return bool
* @checked
* @unitTest
*
* @return bool
*/
public function isMatchDecisionKey()
{
Expand Down
3 changes: 2 additions & 1 deletion plugins/baser-core/src/Utility/BcUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ static public function includePluginClass($pluginName)
* @return void
* @checked
* @unitTest
* @note(value="viewキャッシュ/dataキャッシュ実装時に対応")
* @noTodo
*/
public static function clearAllCache(): void
{
Expand Down Expand Up @@ -1074,6 +1074,7 @@ public static function getContentsItem(): array
* baserCMSのインストールが完了しているかチェックする
* @return boolean
* @checked
* @noTodo
*/
public static function isInstalled()
{
Expand Down
1 change: 1 addition & 0 deletions plugins/baser-core/src/View/BcFrontEmailView.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class BcFrontEmailView extends View
*
* @checked
* @unitTest
* @noTodo
*/
public function initialize(): void
{
Expand Down
5 changes: 3 additions & 2 deletions plugins/baser-core/src/View/Helper/BcBaserHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ public function contentsName($detail = false, $options = [])
* @return string
* @checked
* @unitTest
* @noTodo
* @doc
*/
public function getContentsName($detail = false, $options = [])
Expand Down Expand Up @@ -794,7 +795,7 @@ public function getContentsName($detail = false, $options = [])
* @return string URL
* @checked
* @unitTest
* @note(value="$sessionId について実装検討要")
* @noTodo
*/
public function getUrl($url = null, $full = false)
{
Expand Down Expand Up @@ -2025,10 +2026,10 @@ public function isCategoryTop()
* - `recursive` : 固定ページ読み込みを再帰的に読み込むかどうか(初期値 : true)
* - `checkExists` : 固定ページの存在判定をするかどうか(初期値 : true)
* @return void
* @todo ucmitz loadHelpersが利用されていないのをなんとかする
*/
public function page($url, $params = [], $options = [])
{
// TODO ucmitz loadHelpersが利用されていないのをなんとかする
if (!empty($this->_View->get('pageRecursive')) && !$this->_View->get('pageRecursive')) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/baser-core/src/View/Helper/BcFormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class BcFormHelper extends FormHelper
* @param string $type フォームのタイプ タイプごとにイベントの登録ができる
* @return string 行データ
* @checked
* @note(value="フォームの最後のフィールドの後に発動するイベント")
* @noTodo
*/
public function dispatchAfterForm($type = ''): string
{
Expand Down
1 change: 0 additions & 1 deletion plugins/baser-core/tests/Fixture/ContentsFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ public function init(): void
'description' => '',
'eyecatch' => '00000006_eyecatch.gif',
'author_id' => 1,
// NOTE ucmitz: layout templateテスト用
'layout_template' => 'serviceTemplate',
'status' => true,
'publish_begin' => null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,11 @@ public function testGetCurrentLoginUrl()
/**
* Test getCurrentUserPrefixes
* @return void
* @todo ucmitz getCurrentUserPrefixSettings() の実装が完了したら別パターンのテストを追加する
* @
*/
public function testGetCurrentUserPrefixes()
{
// TODO getCurrentUserPrefixSettings() の実装が完了したら別パターンのテストを追加する
$this->loginAdmin($this->getRequest('/baser/admin'));
$result = $this->BcAuth->getCurrentUserPrefixes();
$this->assertEquals(['Admin', 'Api/Admin'], $result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function initialize(): void
* @return void|ResponseInterface
* @checked
* @unitTest
* @noTodo
*/
public function edit(BlogContentsAdminServiceInterface $service, int $id)
{
Expand Down
15 changes: 13 additions & 2 deletions plugins/bc-blog/src/View/Helper/BlogHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Datasource\EntityInterface;
use Cake\Datasource\Exception\RecordNotFoundException;
use Cake\Datasource\ResultSetInterface;
use Cake\Filesystem\Folder;
use Cake\ORM\TableRegistry;
Expand Down Expand Up @@ -141,18 +142,28 @@ public function setContent($blogContentId = null)

if($blogContentId) {
if(!$this->BlogContentsService) return;
$this->currentBlogContent = $this->BlogContentsService->get($blogContentId);
try {
$this->currentBlogContent = $this->BlogContentsService->get($blogContentId);
} catch(RecordNotFoundException) {
$this->currentBlogContent = null;
$this->currentContent = null;
return;
} catch(\Throwable $e) {
throw $e;
}
$contentTable = TableRegistry::getTableLocator()->get('BaserCore.Contents');
// 現在のサイトにエイリアスが存在するのであればそちらを優先する
$site = $this->_View->getRequest()->getAttribute('currentSite');
$content = null;
if (!empty($site->id)) {
$content = $contentTable->find()->where([
'Contents.entity_id' => $this->currentBlogContent->id,
'Contents.type' => 'BlogContent',
'Contents.alias_id IS NOT' => null,
'Contents.site_id' => $site->id
])->first();
} else {
}
if(!$content) {
$content = $contentTable->find()->where([
'Contents.entity_id' => $this->currentBlogContent->id,
'Contents.type' => 'BlogContent',
Expand Down
42 changes: 2 additions & 40 deletions plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,46 +83,6 @@ public function test__construct()
$this->assertEquals(1, $this->Blog->currentContent->id);
}

/**
* ブログコンテンツデータをセットする
*
* @param int $blogContentId ブログコンテンツID
* @param bool $viewVars viewVarsを設定
* @dataProvider setContentDataProvider
*/
public function testSetContent($blogContentId, $viewVars, $expected)
{
$this->markTestIncomplete('こちらのテストはまだ未確認です');
// if ($viewVars) {
// $View = new View();
// $View->viewVars = ['blogContent' => [
// 'BlogContent' => [
// 'id' => 3,
// 'name' => 'test',
// ]
// ]];
// $View->request = $this->_getRequest('/');
// $View->request->params['Content']['type'] = 'BlogContent';
// $this->Blog = new BlogHelper($View);
// }
// $this->Blog->blogContent = null;
// $this->Blog->setContent($blogContentId);
// $result = null;
// if (!empty($this->Blog->blogContent['id'])) {
// $result = $this->Blog->blogContent['id'];
// }
// $this->assertEquals($result, $expected, 'ブログコンテンツデータを正しくセットできません');
}

public function setContentDataProvider()
{
return [
[null, false, null],
[2, false, 2],
[null, true, 3],
];
}

/**
* ブログIDを取得する
*/
Expand Down Expand Up @@ -226,6 +186,7 @@ public function testGetPostLinkUrl($blogContentId, $baseUrl, $useBase, $expects)
{
$this->truncateTable('contents');
$this->truncateTable('blog_contents');
$this->truncateTable('blog_posts');

// データ生成
$this->loadFixtureScenario(MultiSiteBlogPostScenario::class);
Expand Down Expand Up @@ -431,6 +392,7 @@ public function testGetCategoryUrl($blogCategoryId, $base, $useBase, $expected)
{
$this->truncateTable('contents');
$this->truncateTable('blog_contents');
$this->truncateTable('blog_categories');
$this->loadFixtureScenario(MultiSiteBlogScenario::class);

$blogContent = BlogContentFactory::get(6);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class CustomContentsTable extends AppTable
* @param array $config テーブル設定
* @checked
* @unitTest
* @noTodo
*/
public function initialize(array $config): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use BaserCore\Annotation\UnitTest;
use BaserCore\Annotation\NoTodo;
use BaserCore\Annotation\Checked;
use Psr\Http\Message\ResponseInterface;

/**
* Class InstallationsController
Expand All @@ -46,6 +47,7 @@ class InstallationsController extends BcAdminAppController
*
* @return void
* @checked
* @noTodo
*/
public function beforeFilter(EventInterface $event)
{
Expand Down Expand Up @@ -138,8 +140,9 @@ public function step3(InstallationsAdminServiceInterface $service)
* Step 4: データベース生成/管理者ユーザー作成
*
* @param InstallationsAdminService $service
* @return void
* @return void|ResponseInterface
* @checked
* @noTodo
*/
public function step4(InstallationsAdminServiceInterface $service)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public function getDefaultValuesStep4(ServerRequest $request): array
* @param array $data
* @return void
* @checked
* @noTodo
*/
public function writeDbSettingToSession(ServerRequest $request, array $data): void
{
Expand Down Expand Up @@ -330,6 +331,7 @@ public function login(ServerRequest $request, Response $response): void
*
* @param ServerRequest $request
* @checked
* @noTodo
*/
public function initDb(ServerRequest $request): void
{
Expand Down
Loading

0 comments on commit b4a8217

Please sign in to comment.