Skip to content

Commit

Permalink
マーキング漏れを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Oct 10, 2023
1 parent 494eead commit e3e2cd2
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ public function list(CustomLinksServiceInterface $service, int $id)
*
* @param CustomLinksServiceInterface $service
* @param int $tableId
* @checked
* @noTodo
* @unitTest
*/
public function get_parent_list(CustomLinksServiceInterface $service, int $tableId)
Expand Down
2 changes: 2 additions & 0 deletions plugins/bc-custom-content/src/Model/Entity/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class CustomField extends Entity
* フィールドタイプの表示名を取得する
*
* @return string
* @checked
* @noTodo
*/
public function getTypeTitle(): string
{
Expand Down
2 changes: 2 additions & 0 deletions plugins/bc-custom-content/src/Model/Entity/CustomLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class CustomLink extends Entity
* 自身が group の場合は、選択できない
*
* @return bool
* @checked
* @noTodo
*/
public function isGroupSelectable(): bool
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public function initialize(array $config): void
*
* @param Validator $validator
* @return Validator
* @checked
* @noTodo
*/
public function validationWithTable(Validator $validator): Validator
{
Expand Down
52 changes: 43 additions & 9 deletions plugins/bc-custom-content/src/Model/Table/CustomEntriesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function createSearchIndex(CustomEntry $entry)
->contain(['Contents'])
->first();
/** @var Content $content */
if(!$customContent) return false;
if (!$customContent) return false;
$content = $customContent->content;
return [
'type' => __d('baser_core', 'カスタムコンテンツ'),
Expand Down Expand Up @@ -123,13 +123,13 @@ public function createSearchIndex(CustomEntry $entry)
public function createSearchDetail(CustomEntry $entity): string
{
$detail = $entity->name?: '';
if(!$this->links) return $detail;
if (!$this->links) return $detail;
foreach($this->links as $link) {
/** @var CustomLink $link */
if(!$link->status) continue;
if (!$link->status) continue;
$controlType = Configure::read('BcCustomContent.fieldTypes.' . $link->custom_field->type . '.controlType');
if(!in_array($controlType, ['text', 'textarea'])) continue;
if($detail) $detail .= ',';
if (!in_array($controlType, ['text', 'textarea'])) continue;
if ($detail) $detail .= ',';
$detail .= $entity->{$link->name};
}
return $detail;
Expand Down Expand Up @@ -217,6 +217,8 @@ public function setLinks(int $tableId)
* バリデーションを設定する
*
* @var array $postData
* @checked
* @noTodo
*/
public function setupValidate(array $postData = [])
{
Expand Down Expand Up @@ -257,10 +259,12 @@ public function setupValidate(array $postData = [])
* @param CustomLink $link
* @param array $postData
* @return Validator
* @checked
* @noTodo
*/
public function setValidateMaxFileSize(Validator $validator, CustomLink $link, array $postData)
{
if(empty($link->custom_field->meta['BcCustomContent']['max_file_size'])) return $validator;
if (empty($link->custom_field->meta['BcCustomContent']['max_file_size'])) return $validator;
$maxFileSize = $link->custom_field->meta['BcCustomContent']['max_file_size'];
if (isset($postData[$link->name]['error']) && $postData[$link->name]['error'] !== UPLOAD_ERR_NO_FILE) {
$validator->add($link->name, [
Expand All @@ -281,10 +285,12 @@ public function setValidateMaxFileSize(Validator $validator, CustomLink $link, a
* @param CustomLink $link
* @param array $postData
* @return Validator
* @checked
* @noTodo
*/
public function setValidateFileExt(Validator $validator, CustomLink $link)
{
if(empty($link->custom_field->meta['BcCustomContent']['file_ext'])) return $validator;
if (empty($link->custom_field->meta['BcCustomContent']['file_ext'])) return $validator;
$fileExt = explode(',', $link->custom_field->meta['BcCustomContent']['file_ext']);
$validator->add($link->name, [
'fileExt' => [
Expand All @@ -302,6 +308,8 @@ public function setValidateFileExt(Validator $validator, CustomLink $link)
* @param Validator $validator
* @param CustomLink $link
* @return Validator
* @checked
* @noTodo
*/
public function setValidateEmailConfirm(Validator $validator, CustomLink $link): Validator
{
Expand All @@ -327,6 +335,8 @@ public function setValidateEmailConfirm(Validator $validator, CustomLink $link):
* @param Validator $validator
* @param CustomLink $link
* @return Validator
* @checked
* @noTodo
*/
public function setValidateRegex(Validator $validator, CustomLink $link): Validator
{
Expand All @@ -349,6 +359,8 @@ public function setValidateRegex(Validator $validator, CustomLink $link): Valida
* @param Validator $validator
* @param CustomLink $link
* @return Validator
* @checked
* @noTodo
*/
public function setValidateEmail(Validator $validator, CustomLink $link): Validator
{
Expand All @@ -370,6 +382,8 @@ public function setValidateEmail(Validator $validator, CustomLink $link): Valida
* @param Validator $validator
* @param CustomLink $link
* @return Validator
* @checked
* @noTodo
*/
public function setValidateNumber(Validator $validator, CustomLink $link): Validator
{
Expand All @@ -391,6 +405,8 @@ public function setValidateNumber(Validator $validator, CustomLink $link): Valid
* @param Validator $validator
* @param CustomLink $link
* @return Validator
* @checked
* @noTodo
*/
public function setValidateHankaku(Validator $validator, CustomLink $link): Validator
{
Expand All @@ -412,6 +428,8 @@ public function setValidateHankaku(Validator $validator, CustomLink $link): Vali
* @param Validator $validator
* @param CustomLink $link
* @return Validator
* @checked
* @noTodo
*/
public function setValidateZenkakuKatakana(Validator $validator, CustomLink $link): Validator
{
Expand All @@ -434,6 +452,8 @@ public function setValidateZenkakuKatakana(Validator $validator, CustomLink $lin
* @param Validator $validator
* @param CustomLink $link
* @return Validator
* @checked
* @noTodo
*/
public function setValidateZenkakuHiragana(Validator $validator, CustomLink $link): Validator
{
Expand All @@ -456,6 +476,8 @@ public function setValidateZenkakuHiragana(Validator $validator, CustomLink $lin
* @param Validator $validator
* @param CustomLink $link
* @return Validator
* @checked
* @noTodo
*/
public function setValidateDatetime(Validator $validator, CustomLink $link, array $postData): Validator
{
Expand Down Expand Up @@ -488,6 +510,8 @@ public function setValidateDatetime(Validator $validator, CustomLink $link, arra
*
* @param Validator $validator
* @return Validator
* @checked
* @noTodo
*/
public function validationDefault(Validator $validator): Validator
{
Expand All @@ -506,6 +530,8 @@ public function validationDefault(Validator $validator): Validator
* @param EventInterface $event
* @param ArrayObject $content
* @param ArrayObject $options
* @checked
* @noTodo
*/
public function beforeMarshal(EventInterface $event, ArrayObject $content, ArrayObject $options)
{
Expand All @@ -518,6 +544,8 @@ public function beforeMarshal(EventInterface $event, ArrayObject $content, Array
*
* @param ArrayObject $content
* @return ArrayObject
* @checked
* @noTodo
*/
public function autoConvert(ArrayObject $content)
{
Expand All @@ -526,7 +554,7 @@ public function autoConvert(ArrayObject $content)
foreach($this->links as $link) {
if ($link->name === $key) break;
}
if(empty($link)) continue;
if (empty($link)) continue;
$controlType = CustomContentUtil::getPluginSetting($link->custom_field->type, 'controlType');
if ($controlType === 'file') continue;
if (is_array($value)) {
Expand All @@ -545,12 +573,14 @@ public function autoConvert(ArrayObject $content)
* @param Query $query
* @param array $options
* @return Query
* @checked
* @noTodo
*/
public function findAll(Query $query, array $options = []): Query
{
return $query->formatResults(function(\Cake\Collection\CollectionInterface $results) {
return $results->map(function($row) {
if(!is_object($row) || !method_exists($row, 'toArray')) return $row;
if (!is_object($row) || !method_exists($row, 'toArray')) return $row;
return $this->decodeRow($row);
});
});
Expand All @@ -561,6 +591,8 @@ public function findAll(Query $query, array $options = []): Query
*
* @param EntityInterface $row
* @return EntityInterface
* @checked
* @noTodo
*/
public function decodeRow(EntityInterface $row)
{
Expand All @@ -578,6 +610,8 @@ public function decodeRow(EntityInterface $row)
*
* @param string $string
* @return bool
* @checked
* @noTodo
*/
function isJson(string $string)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
use BcCustomContent\Test\Factory\CustomFieldFactory;
use BcCustomContent\Test\Factory\CustomLinkFactory;
use BcCustomContent\Test\Scenario\CustomContentsScenario;
use BcCustomContent\Test\Scenario\CustomFieldsScenario;
use BcCustomContent\Service\CustomEntriesService;
use BcCustomContent\Service\CustomEntriesServiceInterface;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;

/**
Expand Down

0 comments on commit e3e2cd2

Please sign in to comment.