Import
in package
Table of Contents
Properties
- $bid : int
- $distPath : string
- $entryRepository : EntryRepository
- $entrySort : int
- $entryStatus : string
- $errors : array<string|int, mixed>
- $ids : array<string|int, mixed>
- $insertedEntryIds : array<string|int, int>
- INSERT に成功したエントリーの新しい ID
- $mediaFieldFix : array<string|int, mixed>
- $uid : int
- $userSort : int
- $yaml : array<string|int, mixed>
Methods
- __construct() : mixed
- Import constructor
- run() : array<string|int, mixed>
- import blog data
- columnFix() : mixed
- convertBlockEditorAuthoringHtml() : string
- 本文中の入稿用タグ(`<acms-block-editor-html-block>` / `<acms-block-editor-embed-block>`)を機能タグへ変換する
- entry_sub_categoryFix() : mixed
- entryFix() : mixed
- existsYaml() : bool
- check yaml data
- fieldFix() : mixed
- fix() : int|null
- fixBlockEditorMedia() : string
- generateFulltext() : void
- 取り込んだエントリーの全文検索インデックスを作る
- geoFix() : mixed
- This method is called dynamically via call_user_func_array().
- getNewID() : int|bool|string|void
- insertData() : void
- mediaFix() : mixed
- registerCategoryNewId() : void
- カテゴリーの新しいIDをマッピング
- registerModuleNewId() : mixed
- registerNewID() : void
- registerNewIDs() : void
- sortCategoriesByHierarchy() : array<string|int, mixed>
- カテゴリーを親から子の順(トポロジカル順)に並べ替える
Properties
$bid
protected
int
$bid
$distPath
protected
string
$distPath
$entryRepository
protected
EntryRepository
$entryRepository
$entrySort
protected
int
$entrySort
= 0
$entryStatus
protected
string
$entryStatus
= ''
$errors
protected
array<string|int, mixed>
$errors
$ids
protected
array<string|int, mixed>
$ids
$insertedEntryIds
INSERT に成功したエントリーの新しい ID
protected
array<string|int, int>
$insertedEntryIds
= []
$mediaFieldFix
protected
array<string|int, mixed>
$mediaFieldFix
= []
$uid
protected
int
$uid
$userSort
protected
int
$userSort
= 0
$yaml
protected
array<string|int, mixed>
$yaml
Methods
__construct()
Import constructor
public
__construct([int|null $userId = null ]) : mixed
Parameters
- $userId : int|null = null
-
省略時は SUID を使用する(テストから明示指定する場合に利用)
run()
import blog data
public
run(int $bid, string $yaml, string $distPath[, string $status = '' ]) : array<string|int, mixed>
Parameters
- $bid : int
- $yaml : string
- $distPath : string
- $status : string = ''
Return values
array<string|int, mixed>columnFix()
private
columnFix(string $field, string|null $value, array<string|int, mixed> $record) : mixed
Parameters
- $field : string
- $value : string|null
- $record : array<string|int, mixed>
convertBlockEditorAuthoringHtml()
本文中の入稿用タグ(`<acms-block-editor-html-block>` / `<acms-block-editor-embed-block>`)を機能タグへ変換する
private
convertBlockEditorAuthoringHtml(string $value) : string
埋め込みを解決できなかった URL は通常リンクの段落へ退避し、インポート自体は失敗させずにログへ残す。
Parameters
- $value : string
Return values
stringentry_sub_categoryFix()
private
entry_sub_categoryFix(string $field, string|null $value, array<string|int, mixed> $record) : mixed
Parameters
- $field : string
- $value : string|null
- $record : array<string|int, mixed>
entryFix()
private
entryFix(string $field, string|null $value, array<string|int, mixed> $record) : mixed
Parameters
- $field : string
- $value : string|null
- $record : array<string|int, mixed>
existsYaml()
check yaml data
private
existsYaml(mixed $table) : bool
Parameters
- $table : mixed
Return values
boolfieldFix()
private
fieldFix(string $field, string|null $value, array<string|int, mixed> $record) : mixed
Parameters
- $field : string
- $value : string|null
- $record : array<string|int, mixed>
fix()
private
fix(string $table, string $field, string|null $value) : int|null
Parameters
- $table : string
- $field : string
- $value : string|null
Return values
int|nullfixBlockEditorMedia()
private
fixBlockEditorMedia(string $value) : string
Parameters
- $value : string
Return values
stringgenerateFulltext()
取り込んだエントリーの全文検索インデックスを作る
private
generateFulltext() : void
Why not: entry 行の挿入直後に作ると、本文(column)とカスタムフィールド(field)がまだ入っておらず、 インデックスにタイトルとコードしか載らない(本文の語で検索してもヒットしない)。 loadEntryFulltext() は DB から読むため、関連するテーブルを入れ終えてから呼ぶ必要がある。 また $this->ids は INSERT 前に全件分を採番するため、それを回すと INSERT に失敗した行(DB に 存在しない eid)にも全文検索の行が作られる。INSERT に成功した ID だけを別に控えて使う。
geoFix()
This method is called dynamically via call_user_func_array().
private
geoFix(string $field, string|null $value, array<string|int, mixed> $record) : mixed
Parameters
- $field : string
- $value : string|null
- $record : array<string|int, mixed>
getNewID()
private
getNewID(string $table, int|string $id) : int|bool|string|void
Parameters
- $table : string
- $id : int|string
Return values
int|bool|string|voidinsertData()
private
insertData(string $table) : void
Parameters
- $table : string
mediaFix()
private
mediaFix(string $field, string|null $value, array<string|int, mixed> $record) : mixed
Parameters
- $field : string
- $value : string|null
- $record : array<string|int, mixed>
registerCategoryNewId()
カテゴリーの新しいIDをマッピング
private
registerCategoryNewId() : void
インポートするカテゴリーデータのIDを、既存のカテゴリーIDにマッピングする。 同じカテゴリーコードが異なる親カテゴリーに存在する可能性があるため、 カテゴリーコードと親カテゴリーIDの組み合わせで既存カテゴリーを検索する。
処理の流れ:
- YAMLデータからカテゴリーコードを収集
- 既存のカテゴリーをDBから検索(現在のブログ、グローバルスコープ、親ブログが対象)
- 既存カテゴリーを「カテゴリーコード:親ID」の形式でテーブル化
- YAMLのカテゴリーを親から子の順(トポロジカル順)に並べ替え
- 各カテゴリーについて、親IDをマッピング後のIDに変換し、既存カテゴリーとマッチング
registerModuleNewId()
private
registerModuleNewId() : mixed
registerNewID()
private
registerNewID(string $table) : void
Parameters
- $table : string
registerNewIDs()
private
registerNewIDs() : void
sortCategoriesByHierarchy()
カテゴリーを親から子の順(トポロジカル順)に並べ替える
private
sortCategoriesByHierarchy(array<string|int, mixed> $categories) : array<string|int, mixed>
子カテゴリーの親IDをマッピング済みIDに変換するには、親が先に処理されている必要がある。 旧親IDの昇順ソートでは、親のIDが子のIDより大きい場合(例: 親ID=10 の子が ID=5)に 順序が逆転して親を解決できないため、親子関係を実際に辿って並べ替える。 親がデータに含まれないカテゴリーはルート扱いで先に、循環参照は解決不能として末尾に回す。
Parameters
- $categories : array<string|int, mixed>