src/Ox/HoardBundle/Form/SearchType.php line 424

Open in your IDE?
  1. <?php
  2. namespace App\Ox\HoardBundle\Form;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\FormBuilderInterface;
  5. use Symfony\Component\OptionsResolver\OptionsResolver;
  6. use Symfony\Component\Form\Extension\Core\Type\ButtonType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextType;
  8. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  9. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  10. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  11. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  12. use App\Ox\HoardBundle\Form\DataTransformer\FileToHoardImageTransformer;
  13. use App\Ox\HoardBundle\Form\HoardImageType;
  14. use App\Ox\HoardBundle\Form\HoardReferenceType;
  15. class SearchType extends AbstractType
  16. {
  17.     /**
  18.      * @param FormBuilderInterface $builder
  19.      * @param array $options
  20.      */
  21.     public function buildForm(FormBuilderInterface $builder, array $options)
  22.     {
  23.         $builder
  24.             ->add('hoardFindSpotName'TextType::class, array(
  25.                 'required' => false,
  26.             ))
  27.             ->add('hoardAddress'TextType::class, array(
  28.                 'required' => false
  29.             ))
  30.             ->add('hoardCity'TextType::class, array(
  31.                 'required' => false
  32.             ))
  33.             ->add('hoardCounty'TextType::class, array(
  34.                 'required' => false
  35.             ))
  36.             ->add('hoardRegion'TextType::class, array(
  37.                 'required' => false
  38.             ))
  39.             ->add('hoardReference'EntityType::class, array(
  40.                 'class' => 'OxHoardBundle:Reference',
  41.                 'required' => false,
  42.                 'multiple' => true,
  43.                 'query_builder' => function($repository) {
  44.                     $qb $repository->createQueryBuilder('r');
  45.                     $qb->orderBy('r.sortValue''DESC')
  46.                     ->addOrderBy('r.title''ASC');
  47.                     return $qb;
  48.                 }
  49.             ))
  50.             ->add('hoardFindSpotRating'EntityType::class, array(
  51.                 'class' => 'OxHoardBundle:Rating',
  52.                 'required' => false,
  53.                 'query_builder' => function($repository) {
  54.                     $qb $repository->createQueryBuilder('h');
  55.                     $qb->orderBy('h.sortValue''DESC')
  56.                     ->addOrderBy('h.rating''ASC');
  57.                     return $qb;
  58.                 }
  59.             ))
  60.             ->add('hoardCoinLevelData'EntityType::class, array(
  61.                 'class' => 'OxHoardBundle:CoinLevelData',
  62.                 'required' => false,
  63.                 'query_builder' => function($repository) {
  64.                     return $repository->createQueryBuilder('h');
  65.                 }
  66.             ))
  67.             ->add('hoardType'EntityType::class, array(
  68.                 'class' => 'OxHoardBundle:HoardType',
  69.                 'required' => false,
  70.                 'query_builder' => function($repository) {
  71.                     $qb $repository->createQueryBuilder('h');
  72.                     $qb->orderBy('h.sortValue''DESC')
  73.                     ->addOrderBy('h.hoardType''ASC');
  74.                     return $qb;
  75.                 }
  76.             ))
  77.             ->add('hoardCountries'EntityType::class, array(
  78.                 'class' => 'OxHoardBundle:Country',
  79.                 'multiple' => true,
  80.                 'required' => false,
  81.                 'query_builder' => function($repository) {
  82.                     $qb $repository->createQueryBuilder('c');
  83.                     $qb->orderBy('c.country''ASC');
  84.                     return $qb;
  85.                 }
  86.             ))
  87.             ->add('hoardProvince'EntityType::class, array(
  88.                 'class' => 'OxHoardBundle:Province',
  89.                 'required' => false,
  90.                 'disabled' => true,
  91.                 'query_builder' => function($repository) {
  92.                     $qb $repository->createQueryBuilder('p');
  93.                     $qb->orderBy('p.province''ASC');
  94.                     return $qb;
  95.                 }
  96.             ))
  97.             ->add('hoardAncientPlace'EntityType::class, array(
  98.                 'class' => 'App\Ox\HoardBundle\Entity\AncientPlace',
  99.                 'required' => false,
  100.                 'query_builder' => function($repository) {
  101.                     $qb $repository->createQueryBuilder('p');
  102.                     $qb->orderBy('p.ancientPlace''ASC');
  103.                     return $qb;
  104.                 }
  105.             ))
  106.             // ->add('hoardFindSpotLocationDetail', EntityType::class, array(
  107.             //     'class' => 'App\Ox\HoardBundle\Entity\FindSpotLocationDetail',
  108.             //     'required' => false,
  109.             //     'query_builder' => function($repository) {
  110.             //         $qb = $repository->createQueryBuilder('p');
  111.             //         $qb->orderBy('p.findSpotLocationDetail', 'ASC');
  112.             //         return $qb;
  113.             //     }
  114.             // ))
  115.             // ->add('hoardDiscoveryMethod', EntityType::class, array(
  116.             //     'class' => 'OxHoardBundle:DiscoveryMethod',
  117.             //     'required' => false,
  118.             //     'query_builder' => function($repository) {
  119.             //         $qb = $repository->createQueryBuilder('h');
  120.             //         $qb->orderBy('h.discoveryMethod', 'ASC');
  121.             //         return $qb;
  122.             //     }
  123.             // ))
  124.             // ->add('hoardDiscoveryLandUse', EntityType::class, array(
  125.             //     'class' => 'OxHoardBundle:DiscoveryLandUse',
  126.             //     'required' => false,
  127.             //     'query_builder' => function($repository) {
  128.             //         $qb = $repository->createQueryBuilder('h');
  129.             //         $qb->orderBy('h.discoveryLandUse', 'ASC');
  130.             //         return $qb;
  131.             //     }
  132.             // ))
  133.             // ->add('hoardFindSpotComment', TextType::class, array(
  134.             //     'required' => false,
  135.             // ))
  136.             ->add('hoardInternalNote'TextType::class, array(
  137.                 'required' => false,
  138.             ))
  139.             // ->add('hoardOwner', TextType::class, array(
  140.             //     'required' => false,
  141.             // ))
  142.             // ->add('hoardFinder', TextType::class, array(
  143.             //     'required' => false,
  144.             // ))
  145.             ->add('hoardClosingReign1'EntityType::class, array(
  146.                 'class' => 'OxHoardBundle:Reign',
  147.                 'required' => false,
  148.                 'query_builder' => function($repository) {
  149.                     $qb $repository->createQueryBuilder('r');
  150.                     $qb->orderBy('r.startDate, r.endDate''ASC');
  151.                     return $qb;
  152.                 }
  153.             ))
  154.             ->add('hoardClosingReign2'EntityType::class, array(
  155.                 'class' => 'OxHoardBundle:Reign',
  156.                 'required' => false,
  157.                 'query_builder' => function($repository) {
  158.                     $qb $repository->createQueryBuilder('r');
  159.                     $qb->orderBy('r.startDate, r.endDate''ASC');
  160.                     return $qb;
  161.                 }
  162.             ))
  163.             ->add('hoardRating'EntityType::class, array(
  164.                 'class' => 'OxHoardBundle:Rating',
  165.                 'required' => false,
  166.                 'query_builder' => function($repository) {
  167.                     $qb $repository->createQueryBuilder('h');
  168.                     $qb->orderBy('h.sortValue''DESC')
  169.                     ->addOrderBy('h.rating''ASC');
  170.                     return $qb;
  171.                 }
  172.             ))
  173.             ->add('hoardContextualRating'EntityType::class, array(
  174.                 'class' => 'OxHoardBundle:Rating',
  175.                 'required' => false,
  176.                 'query_builder' => function($repository) {
  177.                     $qb $repository->createQueryBuilder('h');
  178.                     $qb->orderBy('h.sortValue''DESC')
  179.                     ->addOrderBy('h.rating''ASC');
  180.                     return $qb;
  181.                 }
  182.             ))
  183.             // ->add('hoardArchaeologyNaturalFeatures', TextType::class, array(
  184.             //     'required' => false,
  185.             // ))
  186.             // ->add('hoardArchaeologySiteComment', TextType::class, array(
  187.             //     'required' => false,
  188.             // ))
  189.             // ->add('hoardArchaeologyAssociatedFeatures', TextType::class, array(
  190.             //     'required' => false,
  191.             // ))
  192.             // ->add('hoardArchaeologyRecoveryMethod', EntityType::class, array(
  193.             //     'class' => 'OxHoardBundle:ArchaeologyRecoveryMethod',
  194.             //     'multiple' => true,
  195.             //     'required' => false,
  196.             //     'query_builder' => function($repository) {
  197.             //         $qb = $repository->createQueryBuilder('h');
  198.             //         $qb->orderBy('h.archaeologyRecoveryMethod', 'ASC');
  199.             //         return $qb;
  200.             //     }
  201.             // ))
  202.             ->add('hoardArchaeologySiteContext'EntityType::class, array(
  203.                 'class' => 'OxHoardBundle:ArchaeologySiteContext',
  204.                 'multiple' => true,
  205.                 'required' => false,
  206.                 'query_builder' => function($repository) {
  207.                     $qb $repository->createQueryBuilder('h');
  208.                     $qb->orderBy('h.sortValue''DESC')
  209.                     ->addOrderBy('h.archaeologySiteContext''ASC');
  210.                     return $qb;
  211.                 }
  212.             ))
  213.             ->add('hoardArchaeologyContextNatures'EntityType::class, array(
  214.                 'class' => 'OxHoardBundle:ArchaeologyContextNature',
  215.                 'multiple' => true,
  216.                 'required' => false,
  217.                 'query_builder' => function($repository) {
  218.                     $qb $repository->createQueryBuilder('h');
  219.                     $qb->orderBy('h.title''ASC');
  220.                     return $qb;
  221.                 }
  222.             ))
  223.             ->add('hoardArchaeologySiteContextDetails'EntityType::class, array(
  224.                 'class' => 'OxHoardBundle:ArchaeologySiteContextDetail',
  225.                 'multiple' => true,
  226.                 'required' => false,
  227.                 'query_builder' => function($repository) {
  228.                     $qb $repository->createQueryBuilder('c');
  229.                     $qb->orderBy('c.archaeologySiteContextDetail''ASC');
  230.                     return $qb;
  231.                 }
  232.             ))
  233.             // ->add('hoardArchaeologyPeriod', EntityType::class, array(
  234.             //     'class' => 'OxHoardBundle:ArchaeologyPeriod',
  235.             //     'required' => false,
  236.             //     'query_builder' => function($repository) {
  237.             //         $qb = $repository->createQueryBuilder('h');
  238.             //         $qb->orderBy('h.archaeologyPeriod', 'ASC');
  239.             //         return $qb;
  240.             //     }
  241.             // ))
  242.             // ->add('hoardArchaeologyEndPeriod', EntityType::class, array(
  243.             //     'class' => 'OxHoardBundle:ArchaeologyPeriod',
  244.             //     'required' => false,
  245.             //     'query_builder' => function($repository) {
  246.             //         $qb = $repository->createQueryBuilder('h');
  247.             //         $qb->orderBy('h.archaeologyPeriod', 'ASC');
  248.             //         return $qb;
  249.             //     }
  250.             // ))
  251.             ->add('hoardHasImage'CheckboxType::class, array(
  252.                 'required' => false,
  253.             ))
  254.             // ->add('hoardHideWhat', EntityType::class, array(
  255.             //     'class' => 'OxHoardBundle:HideWhat',
  256.             //     'required' => false,
  257.             //     'query_builder' => function($repository) {
  258.             //         $qb = $repository->createQueryBuilder('h')->orderBy('h.hideWhat', 'ASC');
  259.             //         return $qb;
  260.             //     }
  261.             // ))
  262.             // ->add('hoardHideFrom', EntityType::class, array(
  263.             //     'class' => 'OxHoardBundle:HideFrom',
  264.             //     'required' => false,
  265.             //     'query_builder' => function($repository) {
  266.             //         $qb = $repository->createQueryBuilder('h')->orderBy('h.hideFrom', 'ASC');
  267.             //         return $qb;
  268.             //     }
  269.             // ))
  270.             ->add('hoardCredit'TextType::class, array(
  271.                 'required' => false
  272.             ))
  273.             ->add('hoardComment'TextType::class, array(
  274.                 'required' => false
  275.             ))
  276.             ->add('hoardReference_string'TextType::class, array(
  277.                 'required' => false
  278.             ))
  279.             ->add('coinPeriod'EntityType::class, array(
  280.                 'class' => 'OxHoardBundle:Period',
  281.                 'required' => false,
  282.                 'multiple' => true,
  283.                 'query_builder' => function($repository) {
  284.                     $qb $repository->createQueryBuilder('p');
  285.                     $qb->orderBy('p.sortValue''DESC')
  286.                     ->addOrderBy('p.period''ASC');
  287.                     return $qb;
  288.                 }
  289.             ))
  290.             ->add('coinPersons'EntityType::class, array(
  291.                 'class' => 'OxHoardBundle:Person',
  292.                 'required' => false,
  293.                 'multiple' => true,
  294.                 'query_builder' => function($repository) {
  295.                     $qb $repository->createQueryBuilder('p');
  296.                     $qb->orderBy('p.person''ASC');
  297.                     return $qb;
  298.                 }
  299.             ))
  300.             ->add('coinReigns'EntityType::class, array(
  301.                 'class' => 'OxHoardBundle:Reign',
  302.                 'required' => false,
  303.                 'multiple' => true,
  304.                 'query_builder' => function($repository) {
  305.                     $qb $repository->createQueryBuilder('r');
  306.                     $qb->orderBy('r.startDate, r.endDate''ASC');
  307.                     return $qb;
  308.                 }
  309.             ))
  310.             ->add('coinDenominations'EntityType::class, array(
  311.                 'class' => 'OxHoardBundle:Denomination',
  312.                 'required' => false,
  313.                 'multiple' => true,
  314.                 'query_builder' => function($repository) {
  315.                     $qb $repository->createQueryBuilder('d');
  316.                     $qb->orderBy('d.denomination''ASC');
  317.                     return $qb;
  318.                 }
  319.             ))
  320.             ->add('coinMaterials'ChoiceType::class, array(
  321.                 'choices'  => array("Gold" => "23""Silver" => "22,31""Bronze" => "7,49,53"),
  322.                 'required' => false
  323.             ))
  324.             ->add('coinMints'EntityType::class, array(
  325.                 'class' => 'OxHoardBundle:Mint',
  326.                 'required' => false,
  327.                 'multiple' => true,
  328.                 'query_builder' => function($repository) {
  329.                     $qb $repository->createQueryBuilder('m');
  330.                     $qb->orderBy('m.mint''ASC');
  331.                     return $qb;
  332.                 }
  333.             ))
  334.             // ->add('coinIssue', NumberType::class, array(
  335.             //     'required' => false,
  336.             //     'attr' => array (
  337.             //         'float' => false,    //force it to use number type in our field template
  338.             //         'step' => 1,
  339.             //         'min' => 0
  340.             //     )
  341.             // ))
  342.             ->add('coinAspects'EntityType::class, array(
  343.                 'class' => 'OxHoardBundle:Aspect',
  344.                 'required' => false,
  345.                 'multiple' => true,
  346.                 'query_builder' => function($repository) {
  347.                     $qb $repository->createQueryBuilder('a');
  348.                     $qb->orderBy('a.sortValue''DESC')
  349.                     ->addOrderBy('a.aspect''ASC');
  350.                     return $qb;
  351.                 }
  352.             ))
  353.             ->add('coinCondition'EntityType::class, array(
  354.                 'class' => 'OxHoardBundle:Condition',
  355.                 'required' => false,
  356.                 'multiple' => true,
  357.                 'query_builder' => function($repository) {
  358.                     $qb $repository->createQueryBuilder('c');
  359.                     $qb->orderBy('c.sortValue''DESC')
  360.                     ->addOrderBy('c.condition''ASC');
  361.                     return $qb;
  362.                 }
  363.             ))
  364.             ->add('coinReference'EntityType::class, array(
  365.                 'class' => 'OxHoardBundle:Reference',
  366.                 'required' => false,
  367.                 'multiple' => true,
  368.                 'query_builder' => function($repository) {
  369.                     $qb $repository->createQueryBuilder('r');
  370.                     $qb->orderBy('r.sortValue''DESC')
  371.                     ->addOrderBy('r.abbreviation''DESC')
  372.                     ->addOrderBy('r.title''ASC');
  373.                     return $qb;
  374.                 }
  375.             ))
  376.             ->add('coinReferenceString'TextType::class, array(
  377.                 'required' => false
  378.             ))
  379.             ->add('coinImitation'CheckboxType::class, array(
  380.                 'required' => false
  381.             ))
  382.             ->add('coinHasImage'CheckboxType::class, array(
  383.                 'required' => false
  384.             ))
  385.             ->add('coinToCheck'CheckboxType::class, array(
  386.                 'required' => false
  387.             ))
  388.             // ->add('hoardContainerString', TextType::class, array(
  389.             //     'required' => false
  390.             // ))
  391.             // ->add('hoardContainerComment', TextType::class, array(
  392.             //     'required' => false
  393.             // ))
  394.             ->add('hoardHasContainer'CheckboxType::class, array(
  395.                 'required' => false
  396.             ))
  397.             ->add('hoardContainerMaterials'EntityType::class, array(
  398.                 'class' => 'OxHoardBundle:Material',
  399.                 'multiple' => true,
  400.                 'required' => false,
  401.                 'query_builder' => function($repository) {
  402.                     $qb $repository->createQueryBuilder('m');
  403.                     $qb->orderBy('m.sortValue''DESC')
  404.                     ->addOrderBy('m.material''ASC');
  405.                     return $qb;
  406.                 }
  407.             ))
  408.             ->add('hoardContainerHasImage'CheckboxType::class, array(
  409.                 'required' => false
  410.             ))
  411.             ->add('hoardContainerForms'EntityType::class, array(
  412.                 'class' => 'OxHoardBundle:ContainerForm',
  413.                 'multiple' => true,
  414.                 'required' => false,
  415.                 'query_builder' => function($repository) {
  416.                     $qb $repository->createQueryBuilder('h');
  417.                     $qb->orderBy('h.sortValue''DESC')
  418.                     ->addOrderBy('h.containerForm''ASC');
  419.                     return $qb;
  420.                 }
  421.             ))
  422.             // ->add('hoardObjectComment', TextType::class, array(
  423.             //     'required' => false
  424.             // ))
  425.             ->add('hoardHasObject'CheckboxType::class, array(
  426.                 'required' => false
  427.             ))
  428.             ->add('hoardHasObjectWithImage'CheckboxType::class, array(
  429.                 'required' => false
  430.             ))
  431.             ->add('hoardObjectMaterials'EntityType::class, array(
  432.                 'class' => 'OxHoardBundle:Material',
  433.                 'multiple' => true,
  434.                 'required' => false,
  435.                 'query_builder' => function($repository) {
  436.                     $qb $repository->createQueryBuilder('m');
  437.                     $qb->orderBy('m.sortValue''DESC')
  438.                     ->addOrderBy('m.material''ASC');
  439.                     return $qb;
  440.                 }
  441.             ))
  442.             ->add('hoardObjectType'TextType::class, array(
  443.                 'required' => false
  444.             ))
  445.         ;
  446.     }
  447.     /**
  448.      * @param ResolverInterface $resolver
  449.      */
  450.     public function configureOptions(OptionsResolver $resolver)
  451.     {
  452.         $resolver->setDefaults(array(
  453.             'data_class' => null
  454.         ));
  455.     }
  456.     /**
  457.      * @return string
  458.      */
  459.     public function getBlockPrefix()
  460.     {
  461.         return 'ox_hs';
  462.     }
  463. }