/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/data/generator/sfDoctrineFormFilter/default/template/sfDoctrineFormFilterGeneratedTemplate.php

https://github.com/frhumanes/PLM · PHP · 78 lines · 59 code · 11 blank · 8 comment · 4 complexity · 667aca41a30dfa409bf4769ad0533d37 MD5 · raw file

  1. [?php
  2. /**
  3. * <?php echo $this->table->getOption('name') ?> filter form base class.
  4. *
  5. * @package ##PROJECT_NAME##
  6. * @subpackage filter
  7. * @author ##AUTHOR_NAME##
  8. * @version SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
  9. */
  10. abstract class Base<?php echo $this->table->getOption('name') ?>FormFilter extends <?php echo $this->getFormClassToExtend() . "\n" ?>
  11. {
  12. public function setup()
  13. {
  14. $this->setWidgets(array(
  15. <?php foreach ($this->getColumns() as $column): ?>
  16. <?php if ($column->isPrimaryKey()) continue ?>
  17. '<?php echo $column->getFieldName() ?>'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($column->getFieldName())) ?> => new <?php echo $this->getWidgetClassForColumn($column) ?>(<?php echo $this->getWidgetOptionsForColumn($column) ?>),
  18. <?php endforeach; ?>
  19. <?php foreach ($this->getManyToManyRelations() as $relation): ?>
  20. '<?php echo $this->underscore($relation['alias']) ?>_list'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($this->underscore($relation['alias']).'_list')) ?> => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => '<?php echo $relation['table']->getOption('name') ?>')),
  21. <?php endforeach; ?>
  22. ));
  23. $this->setValidators(array(
  24. <?php foreach ($this->getColumns() as $column): ?>
  25. <?php if ($column->isPrimaryKey()) continue ?>
  26. '<?php echo $column->getFieldName() ?>'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($column->getFieldName())) ?> => <?php echo $this->getValidatorForColumn($column) ?>,
  27. <?php endforeach; ?>
  28. <?php foreach ($this->getManyToManyRelations() as $relation): ?>
  29. '<?php echo $this->underscore($relation['alias']) ?>_list'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($this->underscore($relation['alias']).'_list')) ?> => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => '<?php echo $relation['table']->getOption('name') ?>', 'required' => false)),
  30. <?php endforeach; ?>
  31. ));
  32. $this->widgetSchema->setNameFormat('<?php echo $this->underscore($this->modelName) ?>_filters[%s]');
  33. $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
  34. $this->setupInheritance();
  35. parent::setup();
  36. }
  37. <?php foreach ($this->getManyToManyRelations() as $relation): ?>
  38. public function add<?php echo sfInflector::camelize($relation['alias']) ?>ListColumnQuery(Doctrine_Query $query, $field, $values)
  39. {
  40. if (!is_array($values))
  41. {
  42. $values = array($values);
  43. }
  44. if (!count($values))
  45. {
  46. return;
  47. }
  48. $query->leftJoin('r.<?php echo $relation['refTable']->getOption('name') ?> <?php echo $relation['refTable']->getOption('name') ?>')
  49. ->andWhereIn('<?php echo $relation['refTable']->getOption('name') ?>.<?php echo $relation->getForeignFieldName() ?>', $values);
  50. }
  51. <?php endforeach; ?>
  52. public function getModelName()
  53. {
  54. return '<?php echo $this->modelName ?>';
  55. }
  56. public function getFields()
  57. {
  58. return array(
  59. <?php foreach ($this->getColumns() as $column): ?>
  60. '<?php echo $column->getFieldName() ?>'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($column->getFieldName())) ?> => '<?php echo $this->getType($column) ?>',
  61. <?php endforeach; ?>
  62. <?php foreach ($this->getManyToManyRelations() as $relation): ?>
  63. '<?php echo $this->underscore($relation['alias']) ?>_list'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($this->underscore($relation['alias']).'_list')) ?> => 'ManyKey',
  64. <?php endforeach; ?>
  65. );
  66. }
  67. }