<?php
namespace Platform\ControlPanelBundle\Form;
use Cms\CoreBundle\Form\Type\SwitchType;
use Cms\CoreBundle\Model\CustomDataInterface;
use Cms\CoreBundle\Service\TeamworkPm;
use Cms\TenantBundle\Entity\Tenant;
use Cms\TenantBundle\Form\Type\AuthenticationTypesType;
use Cms\TenantBundle\Form\Type\ProductsType;
use Cms\TenantBundle\Form\Type\TenantTypeType;
use Products\AdaBundle\Form\Type\AdaSettingsType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
/**
* Class TenantEditType
* @package Platform\ControlPanelBundle\Form
*/
class TenantEditType extends AbstractType
{
/**
* @var TeamworkPm
*/
private TeamworkPm $teamworkPm;
/**
* TenantEditType constructor.
* @param TeamworkPm $teamworkPm
*/
public function __construct(TeamworkPm $teamworkPm)
{
$this->teamworkPm = $teamworkPm;
}
/**
* @inheritDoc
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
/** @var Tenant $tenant */
$tenant = $options['data'];
$builder
->add('name', TextType::class, array(
'categoryName' => 'Basic',
'label' => 'Tenant Name',
'helpText' => 'The display name of the tenant; please contact dev to change the slug if needed.',
))
->add('stage', ChoiceType::class, array(
'categoryName' => 'Basic',
'choices' => [
'Provisioned' => Tenant::STAGE__PROVISIONED,
'Build' => Tenant::STAGE__BUILD,
'Live' => Tenant::STAGE__LIVE,
'Defunct' => Tenant::STAGE__DEFUNCT,
],
'label' => 'Production Stage',
'helpText' => 'Describe what stage of production the client is in; this may affect different things that are available in the system.',
))
->add('type', TenantTypeType::class, array(
'categoryName' => 'Basic',
))
->add('products', ProductsType::class, array(
'categoryName' => 'Features',
))
->add('authenticationTypes', AuthenticationTypesType::class, array(
'categoryName' => 'SSO',
))
->add('classlinkCustomerId', TextType::class, array(
'categoryName' => 'SSO',
'label' => 'ClassLink Customer ID',
'required' => false,
'helpText' => 'Optional, but recommended; required if "instant logins" are to be used. Used to jump users to the exact third-party login screen and ensures SSO logins are only allowed from their district.',
))
->add('cleverCustomerId', TextType::class, array(
'categoryName' => 'SSO',
'label' => 'Clever Customer ID',
'required' => false,
'helpText' => 'Optional, but recommended; required if "instant logins" are to be used. Used to jump users to the exact third-party login screen and ensures SSO logins are only allowed from their district.',
))
->add('gg4lCustomerId', TextType::class, array(
'categoryName' => 'SSO',
'label' => 'GG4L Customer ID',
'required' => false,
'helpText' => 'Optional, but recommended; required if "instant logins" are to be used. Used to jump users to the exact third-party login screen and ensures SSO logins are only allowed from their district.',
))
->add('googleCustomerId', TextType::class, array(
'categoryName' => 'SSO',
'label' => 'Google Customer ID',
'required' => false,
'helpText' => 'Optional, but recommended. Used to ensure SSO logins are only allowed from their district.',
))
->add('microsoftCustomerId', TextType::class, array(
'categoryName' => 'SSO',
'label' => 'Microsoft Customer ID',
'required' => false,
'helpText' => 'Optional, but recommended. Used to ensure SSO logins are only allowed from their district.',
))
->add('redirects', SwitchType::class, array(
'categoryName' => 'Features',
'required' => false,
'label' => 'Redirects',
'helpText' => 'For performance, redirects are to be enabled only for the clients that wish to use them.',
))
->add('redirectCodes', SwitchType::class, array(
'categoryName' => 'Features',
'required' => false,
'label' => 'Redirect Codes',
'helpText' => 'Whether the system should honor customer-set redirect codes or force temporary redirects regardless.',
))
->add('adaSettings', AdaSettingsType::class, array(
'categoryName' => 'ADA',
))
->add('teamworkTasklist', ChoiceType::class, array(
'categoryName' => 'Teamwork',
'placeholder' => '...',
'empty_data' => null,
'required' => false,
'choices' => array_flip(array_map(
function (array $tasklist) {
return $tasklist['name'];
},
$this->teamworkPm->getTasklists()
)),
'label' => 'Teamwork Task List',
'helpText' => 'The Teamwork project that powers the Process List tab in the CMS dashboard.',
'choice_label' => function ($value, $label) {
return $label;
},
'choice_value' => function ($value) {
if ($value === null) {
return '';
}
return $value;
},
))
->add('disqusId', TextType::class, array(
'categoryName' => 'Miscellaneous',
'required' => false,
'label' => 'Disqus ID',
'helpText' => 'If a client chooses to use Disqus commenting in the Blog module, place their Disqus account ID here.',
))
->add('weglotId', TextType::class, array(
'categoryName' => 'Miscellaneous',
'required' => false,
'label' => 'Weglot ID',
'helpText' => 'Weglot API key for use in injecting Weglot snippet into pages.',
))
->add('googleToken', TextType::class, array(
'categoryName' => 'Miscellaneous',
'required' => false,
'label' => 'Google API Key',
'helpText' => 'If a client chooses to use Google Maps, place their Google Maps API key here.',
))
->add('emailsDisplay', ChoiceType::class, array(
'categoryName' => 'Miscellaneous',
'label' => 'Emails Display',
'empty_data' => Tenant::EMAILS__SHOW,
'choices' => [
'Show (default, show emails on pages)' => Tenant::EMAILS__SHOW,
'Obfuscate (link to contact form)' => Tenant::EMAILS__OBFUSCATE,
'Hide (no emails listed and no contact form)' => Tenant::EMAILS__HIDE,
],
))
->add('status', ChoiceType::class, array(
'categoryName' => 'Basic',
'choices' => [
'OK (default for normally functioning sites)' => Tenant::STATUS__OK,
'Suspended (for sites that may be temporarily disabled)' => Tenant::STATUS__SUSPENDED,
'Inactive (for defunct sites that can be safely deleted)' => Tenant::STATUS__INACTIVE,
],
'label' => 'Operational Status',
'helpText' => 'NOTE: instances marked as "Inactive" are subject to complete deletion/removal at any time!',
))
;
for ($i = 0; $i < CustomDataInterface::COUNT; $i++) {
$formField = strtolower(ltrim(CustomDataInterface::TEMPLATE, 'get')) . $i;
$builder->add($formField, TextType::class, array(
'categoryName' => 'Custom Module Fields',
'required' => false,
'label' => 'People Profile Custom Field ' . ($i + 1),
));
}
}
}