src/Platform/ControlPanelBundle/Form/TenantEditType.php line 132

Open in your IDE?
  1. <?php
  2. namespace Platform\ControlPanelBundle\Form;
  3. use Cms\CoreBundle\Form\Type\SwitchType;
  4. use Cms\CoreBundle\Model\CustomDataInterface;
  5. use Cms\CoreBundle\Service\TeamworkPm;
  6. use Cms\TenantBundle\Entity\Tenant;
  7. use Cms\TenantBundle\Form\Type\AuthenticationTypesType;
  8. use Cms\TenantBundle\Form\Type\ProductsType;
  9. use Cms\TenantBundle\Form\Type\TenantTypeType;
  10. use Products\AdaBundle\Form\Type\AdaSettingsType;
  11. use Symfony\Component\Form\AbstractType;
  12. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  13. use Symfony\Component\Form\Extension\Core\Type\TextType;
  14. use Symfony\Component\Form\FormBuilderInterface;
  15. /**
  16.  * Class TenantEditType
  17.  * @package Platform\ControlPanelBundle\Form
  18.  */
  19. class TenantEditType extends AbstractType
  20. {
  21.     /**
  22.      * @var TeamworkPm
  23.      */
  24.     private TeamworkPm $teamworkPm;
  25.     /**
  26.      * TenantEditType constructor.
  27.      * @param TeamworkPm $teamworkPm
  28.      */
  29.     public function __construct(TeamworkPm $teamworkPm)
  30.     {
  31.         $this->teamworkPm $teamworkPm;
  32.     }
  33.     /**
  34.      * @inheritDoc
  35.      */
  36.     public function buildForm(FormBuilderInterface $builder, array $options)
  37.     {
  38.         /** @var Tenant $tenant */
  39.         $tenant $options['data'];
  40.         $builder
  41.             ->add('name'TextType::class, array(
  42.                 'categoryName' => 'Basic',
  43.                 'label' => 'Tenant Name',
  44.                 'helpText' => 'The display name of the tenant; please contact dev to change the slug if needed.',
  45.             ))
  46.             ->add('stage'ChoiceType::class, array(
  47.                 'categoryName' => 'Basic',
  48.                 'choices' => [
  49.                     'Provisioned' => Tenant::STAGE__PROVISIONED,
  50.                     'Build' => Tenant::STAGE__BUILD,
  51.                     'Live' => Tenant::STAGE__LIVE,
  52.                     'Defunct' => Tenant::STAGE__DEFUNCT,
  53.                 ],
  54.                 'label' => 'Production Stage',
  55.                 'helpText' => 'Describe what stage of production the client is in; this may affect different things that are available in the system.',
  56.             ))
  57.             ->add('type'TenantTypeType::class, array(
  58.                 'categoryName' => 'Basic',
  59.             ))
  60.             ->add('products'ProductsType::class, array(
  61.                 'categoryName' => 'Features',
  62.             ))
  63.             ->add('authenticationTypes'AuthenticationTypesType::class, array(
  64.                 'categoryName' => 'SSO',
  65.             ))
  66.             ->add('classlinkCustomerId'TextType::class, array(
  67.                 'categoryName' => 'SSO',
  68.                 'label' => 'ClassLink Customer ID',
  69.                 'required' => false,
  70.                 '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.',
  71.             ))
  72.             ->add('cleverCustomerId'TextType::class, array(
  73.                 'categoryName' => 'SSO',
  74.                 'label' => 'Clever Customer ID',
  75.                 'required' => false,
  76.                 '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.',
  77.             ))
  78.             ->add('gg4lCustomerId'TextType::class, array(
  79.                 'categoryName' => 'SSO',
  80.                 'label' => 'GG4L Customer ID',
  81.                 'required' => false,
  82.                 '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.',
  83.             ))
  84.             ->add('googleCustomerId'TextType::class, array(
  85.                 'categoryName' => 'SSO',
  86.                 'label' => 'Google Customer ID',
  87.                 'required' => false,
  88.                 'helpText' => 'Optional, but recommended. Used to ensure SSO logins are only allowed from their district.',
  89.             ))
  90.             ->add('microsoftCustomerId'TextType::class, array(
  91.                 'categoryName' => 'SSO',
  92.                 'label' => 'Microsoft Customer ID',
  93.                 'required' => false,
  94.                 'helpText' => 'Optional, but recommended. Used to ensure SSO logins are only allowed from their district.',
  95.             ))
  96.             ->add('redirects'SwitchType::class, array(
  97.                 'categoryName' => 'Features',
  98.                 'required' => false,
  99.                 'label' => 'Redirects',
  100.                 'helpText' => 'For performance, redirects are to be enabled only for the clients that wish to use them.',
  101.             ))
  102.             ->add('redirectCodes'SwitchType::class, array(
  103.                 'categoryName' => 'Features',
  104.                 'required' => false,
  105.                 'label' => 'Redirect Codes',
  106.                 'helpText' => 'Whether the system should honor customer-set redirect codes or force temporary redirects regardless.',
  107.             ))
  108.             ->add('adaSettings'AdaSettingsType::class, array(
  109.                 'categoryName' => 'ADA',
  110.             ))
  111.             ->add('teamworkTasklist'ChoiceType::class, array(
  112.                 'categoryName' => 'Teamwork',
  113.                 'placeholder' => '...',
  114.                 'empty_data' => null,
  115.                 'required' => false,
  116.                 'choices' => array_flip(array_map(
  117.                     function (array $tasklist) {
  118.                         return $tasklist['name'];
  119.                     },
  120.                     $this->teamworkPm->getTasklists()
  121.                 )),
  122.                 'label' => 'Teamwork Task List',
  123.                 'helpText' => 'The Teamwork project that powers the Process List tab in the CMS dashboard.',
  124.                 'choice_label' => function ($value$label) {
  125.                     return $label;
  126.                 },
  127.                 'choice_value' => function ($value) {
  128.                     if ($value === null) {
  129.                         return '';
  130.                     }
  131.                     return $value;
  132.                 },
  133.             ))
  134.             ->add('disqusId'TextType::class, array(
  135.                 'categoryName' => 'Miscellaneous',
  136.                 'required' => false,
  137.                 'label' => 'Disqus ID',
  138.                 'helpText' => 'If a client chooses to use Disqus commenting in the Blog module, place their Disqus account ID here.',
  139.             ))
  140.             ->add('weglotId'TextType::class, array(
  141.                 'categoryName' => 'Miscellaneous',
  142.                 'required' => false,
  143.                 'label' => 'Weglot ID',
  144.                 'helpText' => 'Weglot API key for use in injecting Weglot snippet into pages.',
  145.             ))
  146.             ->add('googleToken'TextType::class, array(
  147.                 'categoryName' => 'Miscellaneous',
  148.                 'required' => false,
  149.                 'label' => 'Google API Key',
  150.                 'helpText' => 'If a client chooses to use Google Maps, place their Google Maps API key here.',
  151.             ))
  152.             ->add('emailsDisplay'ChoiceType::class, array(
  153.                 'categoryName' => 'Miscellaneous',
  154.                 'label' => 'Emails Display',
  155.                 'empty_data' => Tenant::EMAILS__SHOW,
  156.                 'choices' => [
  157.                     'Show (default, show emails on pages)' => Tenant::EMAILS__SHOW,
  158.                     'Obfuscate (link to contact form)' => Tenant::EMAILS__OBFUSCATE,
  159.                     'Hide (no emails listed and no contact form)' => Tenant::EMAILS__HIDE,
  160.                 ],
  161.             ))
  162.             ->add('status'ChoiceType::class, array(
  163.                 'categoryName' => 'Basic',
  164.                 'choices' => [
  165.                     'OK (default for normally functioning sites)' => Tenant::STATUS__OK,
  166.                     'Suspended (for sites that may be temporarily disabled)' => Tenant::STATUS__SUSPENDED,
  167.                     'Inactive (for defunct sites that can be safely deleted)' => Tenant::STATUS__INACTIVE,
  168.                 ],
  169.                 'label' => 'Operational Status',
  170.                 'helpText' => 'NOTE: instances marked as "Inactive" are subject to complete deletion/removal at any time!',
  171.             ))
  172.         ;
  173.         for ($i 0$i CustomDataInterface::COUNT$i++) {
  174.             $formField strtolower(ltrim(CustomDataInterface::TEMPLATE'get')) . $i;
  175.             $builder->add($formFieldTextType::class, array(
  176.                 'categoryName' => 'Custom Module Fields',
  177.                 'required' => false,
  178.                 'label' => 'People Profile Custom Field ' . ($i 1),
  179.             ));
  180.         }
  181.     }
  182. }