<?php
    /**
     * Repeater custom control
     * 
     * @package Blog Bee
     * @since 1.0.0
     */
    namespace BBE\Customizer\Controls;

    use BBE\Customizer\Base as Base;

    if( ! class_exists( __NAMESPACE__ . '\\Repeater' ) ) {
        /**
         * Repeater class
         */
        class Repeater extends Base {
            /**
             * Type of control
             * 
             * @since 1.0.0
             */
            public $type = 'bbe-repeater';

            /**
             * Should match one of the field keys to show as heading in each repeater item
             * 
             * @since 1.0.0
             */
            public $heading_key = '';

            /**
             * A static heading to show in case $heading_key is not provided
             * 
             * @since 1.0.0
             */
            public $heading = '#Item';

            /**
             * Fields to use in repeater control
             * 
             * @since 1.0.0
             */
            public $fields = [];

            /**
             * To json
             * 
             * @since 1.0.0
             * @override
             */
            public function to_json() {
                parent::to_json();
                $this->json[ 'fields' ] = $this->fields;
                $this->json[ 'heading_key' ] = $this->heading_key;
                $this->json[ 'heading' ] = $this->heading;
            }
        }
        Repeater::set_control_type( 'bbe-repeater' );
    }