1

I'm in the progress of converting a Doctrine2 project to Symfony2. I have a model class which represents SI Prefixes, as well as a default set of SI Prefixes.

  • How and where would I store a default set of SI Prefixes? I currently have a YAML file, but I'm not sure where to put it. Would <MyBundle>/Resources/data/siprefixes.yaml be an appropriate place?

  • How would I import the data for unit tests? Is doctrine-fixtures the way to go, by manually parsing the data and creating/persisting the entities?

  • How would I import the data during a setup procedure of any kind?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Drachenkatze
  • 847
  • 1
  • 9
  • 18
  • See http://stackoverflow.com/questions/9999806/symfony-2-where-should-i-put-a-utility-class http://stackoverflow.com/questions/14978156/how-to-create-custom-or-helper-function-in-symfony2-like-codeigniter-and-where http://stackoverflow.com/questions/9759096/symfony2-where-to-place-custom-helper-classes http://stackoverflow.com/questions/12732664/where-to-put-model-helper-functions-in-symfony2 – A.L Dec 17 '13 at 10:22
  • 1
    Those questions are about where to place custom functions. My question is about where to put data. – Drachenkatze Dec 17 '13 at 13:30
  • You can store the data as properties of your SI class. These units are not supposed to change, why use a configuration file? – A.L Dec 17 '13 at 13:57
  • The question was where to save data, not if it makes sense to store the data in a class. – Drachenkatze Dec 17 '13 at 18:00
  • But it doesn't prevent asking questions. Loading and parsing a YAML file with SI prefixes (which can be seen as constants) at every page display may be a waste of time. – A.L Dec 17 '13 at 23:40
  • It's not loaded every time, it's loaded and put into database during setup. Yes, it needs to live in the database. Yes, there will be new additions to the database, see https://github.com/partkeepr/PartKeepr/issues/356. No, I don't want it hardcoded in the class for various reasons. – Drachenkatze Dec 18 '13 at 04:02

0 Answers0