Import
in package
uses
ImportTrait
単一 bin → 単一 blog への yaml 投入を実行する。
用途: ACMS_POST_Backup_BlogImport 等、単発でブログをインポートする呼び出し。 (複数 bin の同時投入は MultiBlogImport を使う)
共通処理は ImportTrait に集約。本クラスの責務は:
- 入力 yaml 1 本から ID マップを採番する
prepareIds()の実装 - 公開メソッド
run($bid, $yaml)の薄いラッパー
Table of Contents
Properties
- $blogId : int
- $errors : array<string|int, mixed>
- $ids : array<string|int, mixed>
- $mediaFieldFix : array<string|int, mixed>
- $userId : int
- $yaml : array<string|int, mixed>
- $categoryIdConfigKeys : array<string|int, string>
- カテゴリーIDを値として保持する config キー。 管理画面のカテゴリー選択UI(js-admin-category-select)に紐づくキーが対象。
- $mediaIdConfigKeys : array<string|int, string>
- メディアIDを値として保持する config キー。
Methods
- run() : array<string|int, mixed>
- dropData() : void
- 投入先 blog の既存データを削除する (破壊リプレース用)。
- executeImport() : array<string|int, mixed>
- yaml を実際に投入する。
- prepareIds() : void
- 単発 import では「入力 yaml 1 本のみ」から ID を採番する。
- rewriteBlogIdInYaml() : string
- yaml 内の各テーブルの `<table>_blog_id` を指定 blog_id で書き換える。
- categoryFix() : mixed
- clearTable() : void
- columnFix() : mixed
- configFix() : mixed
- entry_sub_categoryFix() : mixed
- This method is called dynamically via call_user_func_array().
- entryFix() : mixed
- existsYaml() : bool
- fieldFix() : mixed
- fix() : mixed
- 旧IDを新IDに解決する共通の fix。フィールド名のサフィックスを見て、対応するテーブルの ID マップを引く。
- fixBlockEditorMedia() : string
- fulltextFix() : mixed
- generateFulltext() : void
- geoFix() : mixed
- This method is called dynamically via call_user_func_array().
- getNewID() : int|string
- 旧IDを新IDに解決する。マッピングが存在しない場合は元の値をそのまま返す。 unit_delimiter で区切られた複数IDのケースにも対応。
- insertData() : void
- layout_gridFix() : mixed
- moduleFix() : mixed
- recordExists() : bool
- yaml レコードが持つ旧 <table>_id を新 ID にマッピングし、 同じ新 ID のレコードが既に DB に存在するか確認する。
- registerCategoryNewId() : void
- カテゴリーIDの新規マッピング。同名コードが既存ブログに存在する場合は再利用、 無い場合のみ nextval で新規採番する (旧 setup/lib/import.php と同じセマンティクス)。
- registerNewIDsForTable() : void
- ruleFix() : mixed
- updateBlogConfigSet() : void
- yaml の各 blog レコードに含まれる config_set / theme_set / editor_set 系 ID を、 対応する blog テーブルレコードに UPDATE で反映する。
- updateOneBlogConfigSet() : void
Properties
$blogId
protected
int
$blogId
$errors
protected
array<string|int, mixed>
$errors
$ids
protected
array<string|int, mixed>
$ids
$mediaFieldFix
protected
array<string|int, mixed>
$mediaFieldFix
= []
$userId
protected
int
$userId
$yaml
protected
array<string|int, mixed>
$yaml
$categoryIdConfigKeys
カテゴリーIDを値として保持する config キー。 管理画面のカテゴリー選択UI(js-admin-category-select)に紐づくキーが対象。
private
static array<string|int, string>
$categoryIdConfigKeys
= ['entry_edit_category_default', 'entry_edit_category_filter', 'entry_edit_sub_category_filter', 'static_page_cid', 'static_archive_cid']
(PHP 8.1 互換維持のため trait const ではなく static プロパティで保持する)
$mediaIdConfigKeys
メディアIDを値として保持する config キー。
private
static array<string|int, string>
$mediaIdConfigKeys
= ['media_banner_mid', 'navigation_media']
Methods
run()
public
run(string $yaml, int $blogId, int $userId) : array<string|int, mixed>
Parameters
- $yaml : string
-
投入する yaml 文字列
- $blogId : int
-
投入対象 blog_id
- $userId : int
-
entry_last_update_user_id 等で使う実行者 user_id
Return values
array<string|int, mixed> —エラーメッセージの一覧
dropData()
投入先 blog の既存データを削除する (破壊リプレース用)。
protected
dropData() : void
呼び出し前に $this->blogId を投入先 blog_id にセットしておく必要がある。
executeImport()
yaml を実際に投入する。
protected
executeImport(string $yaml, int $blogId, int $userId) : array<string|int, mixed>
前提:
- yaml 内の