<?php

/*
 * This file is part of the VitiCore 2.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CpCreation\VitiCore\Bridge\Symfony\Bundle\Form\Admin;

use Craue\FormFlowBundle\Form\FormFlow;
use Craue\FormFlowBundle\Form\FormFlowInterface;

final class SocialNetworkFlow extends FormFlow
{
    protected function loadStepsConfig(): array
    {
        return [
            [
                'label' => 'Network',
                'form_type' => 'CpCreation\VitiCore\Bridge\Symfony\Bundle\Form\Admin\SocialNetworkStep1Type',
                'form_options' => [
                    'validation_groups' => ['step1'],
                ],
                'skip' => function ($estimatedCurrentStepNumber, FormFlowInterface $flow) {
                    return null !== $flow->getFormData()->getNetwork();
                },
            ],
            [
                'label' => 'Config',
                'form_type' => 'CpCreation\VitiCore\Bridge\Symfony\Bundle\Form\Admin\SocialNetworkStep2Type',
                'form_options' => [
                    'validation_groups' => ['step2'],
                ],
            ],
            [
                'label' => 'Associer Facebook / Instagram',
                'form_type' => 'CpCreation\VitiCore\Bridge\Symfony\Bundle\Form\Admin\SocialNetworkStep3Type',
                'form_options' => [
                    'validation_groups' => ['step3'],
                ],
                'skip' => function ($estimatedCurrentStepNumber, FormFlowInterface $flow) {
                    if ('facebook_facebook' === $flow->getFormData()->getNetwork() || 'facebook_instagram' === $flow->getFormData()->getNetwork()) {
                        return false;
                    }

                    return true;
                },
            ],
        ];
    }
}
