MishkaCmsMigration.Targets.CmsSetting (Mishka CMS Migration v0.0.1)

Copy Markdown View Source

The "setting" items of a source, the site's own name and pictures, written to the run's site's settings (MishkaCmsCore.Runtime.Setting) through the :set the Settings page's save runs (MishkaCmsCore.Settings.put_as/4), as the admin who pressed Import: the admin needs what writing the setting takes (MishkaCmsCore.Settings.write_permission/1, admin:dashboard:setting for these), and the core's own rules decide the rest.

An item is one setting, by its source id:

  • "title" — the site's name, its site.title;
  • "logo" — its logo, site.logo, and "icon" — its icon, site.favicon: the item's "value" is the source id of a file, and the setting is the Media address of the file the same run, or an earlier one, wrote for it (MishkaCmsMigration.Targets.CmsMedia.addresses/2). An import whose file was not written, such as an SVG, skips it as "file_missing"; a dry run, which writes no file, does not;
  • "tagline" — the CMS has no setting for a tagline, so it is skipped as "no_setting", in the dry run too, and so is any other.

The site's own

A setting the site already holds a value of its own for is never written over on the import's own say: read before anything is written, in the dry run too (existing/2), from the core's settings cache, so with no query, it waits for an admin's decision as "site_has_own" (MishkaCmsMigration.MigrationItem's Decide…). Keep the site's own skips it as "site_own_kept"; Use the WordPress one writes it over through the same :set, and the report says so (note/2, "site_own_replaced"). A value the site takes from the installation's global settings, or an empty one, is not the site's own, and is written over by the site's own.

A re-run is held to the rules every target is: a setting the source did not change is "unchanged", and one an admin changed or removed in the CMS since is kept as the admin left it (MishkaCmsMigration.Workers.Helpers.Decision). One the source changed is written again through the same :set, which writes over the site's row and keeps its id.

Summary

Functions

Returns a specification to start this module under a supervisor.

Callback implementation for MishkaInstaller.Event.Hook.enable/0.

Callback implementation for MishkaInstaller.Event.Hook.get/0.

Optional. See MishkaInstaller.Event.Hook.health_check/0. Override to report health.

Callback implementation for MishkaInstaller.Event.Hook.register/0.

Callback implementation for MishkaInstaller.Event.Hook.restart/0.

Callback implementation for MishkaInstaller.Event.Hook.start/0.

Callback implementation for MishkaInstaller.Event.Hook.stop/0.

Types

error_return()

@type error_return() ::
  {:error, [%{action: atom(), field: atom(), message: String.t()}]}

okey_return()

@type okey_return() :: {:ok, struct() | map() | module() | [any()]}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

config()

@spec config() :: keyword()

config(key)

@spec config(atom()) :: any()

enable()

@spec enable() :: okey_return() | error_return()

Callback implementation for MishkaInstaller.Event.Hook.enable/0.

get()

@spec get() :: keyword()

Callback implementation for MishkaInstaller.Event.Hook.get/0.

health_check()

@spec health_check() :: :ok | {:degraded, term()} | {:error, term()}

Optional. See MishkaInstaller.Event.Hook.health_check/0. Override to report health.

on_dependency_error(error)

@spec on_dependency_error(term()) :: term()

Optional. See MishkaInstaller.Event.Hook.on_dependency_error/1. Override to react.

register()

@spec register() :: okey_return() | error_return()

Callback implementation for MishkaInstaller.Event.Hook.register/0.

restart()

@spec restart() :: okey_return() | error_return()

Callback implementation for MishkaInstaller.Event.Hook.restart/0.

start()

@spec start() :: okey_return() | error_return()

Callback implementation for MishkaInstaller.Event.Hook.start/0.

start_link(args \\ [])

stop()

@spec stop() :: okey_return() | error_return()

Callback implementation for MishkaInstaller.Event.Hook.stop/0.

unregister()

@spec unregister() :: okey_return() | error_return()

Callback implementation for MishkaInstaller.Event.Hook.unregister/0.