*/ final class SurveyTemplateMapper extends DataMapperFactory { /** * Columns. * * @var array * @since 1.0.0 */ public const COLUMNS = [ 'survey_template_id' => ['name' => 'survey_template_id', 'type' => 'int', 'internal' => 'id'], 'survey_template_status' => ['name' => 'survey_template_status', 'type' => 'int', 'internal' => 'status'], 'survey_template_public_result' => ['name' => 'survey_template_public_result', 'type' => 'bool', 'internal' => 'hasPublicResult'], 'survey_template_start' => ['name' => 'survey_template_start', 'type' => 'DateTime', 'internal' => 'start'], 'survey_template_end' => ['name' => 'survey_template_end', 'type' => 'DateTime', 'internal' => 'end'], 'survey_template_virtual' => ['name' => 'survey_template_virtual', 'type' => 'string', 'internal' => 'virtualPath'], 'survey_template_created_by' => ['name' => 'survey_template_created_by', 'type' => 'int', 'internal' => 'createdBy'], 'survey_template_created_at' => ['name' => 'survey_template_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt'], ]; /** * Has many relation. * * @var array * @since 1.0.0 */ public const HAS_MANY = [ 'elements' => [ 'mapper' => SurveyTemplateElementMapper::class, 'table' => 'survey_template_element', 'self' => 'survey_template_element_template', 'external' => null, ], 'l11n' => [ 'mapper' => SurveyTemplateL11nMapper::class, 'table' => 'survey_template_l11n', 'self' => 'survey_template_l11n_template', 'conditional' => true, 'external' => null, ], 'tags' => [ 'mapper' => TagMapper::class, 'table' => 'survey_template_tag', 'self' => 'survey_template_tag_dst', 'external' => 'survey_template_tag_src', ], 'files' => [ 'mapper' => MediaMapper::class, 'table' => 'survey_template_media', 'external' => 'survey_template_media_dst', 'self' => 'survey_template_media_src', ], ]; /** * Belongs to. * * @var array * @since 1.0.0 */ public const BELONGS_TO = [ 'createdBy' => [ 'mapper' => AccountMapper::class, 'external' => 'survey_template_created_by', ], ]; /** * Primary table. * * @var string * @since 1.0.0 */ public const TABLE = 'survey_template'; /** * Created at. * * @var string * @since 1.0.0 */ public const CREATED_AT = 'survey_template_created_at'; /** * Primary field name. * * @var string * @since 1.0.0 */ public const PRIMARYFIELD = 'survey_template_id'; /** * Get editor doc based on virtual path. * * @param string $virtualPath Virtual path * * @return ReadMapper * * @since 1.0.0 */ public static function getByVirtualPath(string $virtualPath = '/') : ReadMapper { return self::getAll() ->with('createdBy') ->with('l11n') ->with('tags') ->with('tags/title') ->where('virtualPath', $virtualPath); } }