{{Entity}}.class.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. {"label":"Entité","syntax":"php","sort":2}
  2. <?php
  3. /**
  4. * Define a {{EntityLabel}}
  5. * @author {{user.fullname}}
  6. * @category Plugin
  7. * @license MIT
  8. */
  9. class {{Entity}} extends Entity{
  10. public $id;{{#fields}}
  11. public ${{key}}; //{{label}} ({{type.label}}){{/fields}}
  12. protected $TABLE_NAME = '{{plugin_table_deduplicate}}';
  13. public $entityLabel = '{{EntityLabel}}';
  14. public $fields = array(
  15. 'id' => array('type'=>'key', 'label' => 'Identifiant'),{{#fields}}{{^isImage}}{{^isFile}}
  16. '{{key}}' => array('type'=>'{{type.slug}}','label' => '{{label_escaped}}'{{#entityRelativePath}},'link'=>'{{entityRelativePath}}'{{/entityRelativePath}}){{;}},{{/;}}{{/isFile}}{{/isImage}}{{/fields}}
  17. );
  18. //Colonnes indexées
  19. public $indexes = array();
  20. {{#fields}}{{#isList}}
  21. //liste des {{label}} possibles
  22. public static function {{key}}s($key=null){
  23. $items = array(
  24. '{{key}}-1' => array('label'=>'{{label}} 1')
  25. );
  26. if(!isset($key)) return $items;
  27. return isset($items[$key]) ? $items[$key] : array('label'=>'Non définis');
  28. }{{/isList}}{{#isChoice}}
  29. //liste des {{label}} possibles
  30. public static function {{key}}s($key=null){
  31. $items = array(
  32. '{{key}}-1' => array('label'=>'{{label}} 1')
  33. );
  34. if(!isset($key)) return $items;
  35. return isset($items[$key]) ? $items[$key] : array('label'=>'Non définis');
  36. }{{/isChoice}}{{/fields}}
  37. }
  38. ?>