Development

/plugins/sfDoctrineActAsSerializablePlugin/trunk/README

You must first sign up to be able to contribute.

root/plugins/sfDoctrineActAsSerializablePlugin/trunk/README

Revision 33325, 2.5 kB (checked in by tkoomzaaskz, 3 years ago)

[sfDoctrineActAsSerializablePlugin] adding initial release

Line 
1 sfDoctrineActAsSerializablePlugin
2 =============================
3
4 The `sfDoctrineActAsSerializablePlugin` plugin automates the handling of
5 serializable columns. Each time a __Serializable__ object is read from
6 the database, the appropriate columns are unserialized, each time it is
7 saved - the column values are seralized back.
8
9 Instalation
10 ===========
11
12 Install the plugin via the subversion repository by executing the following
13 command from the project root directory:
14
15     $ svn co http://svn.symfony-project.com/plugins/sfDoctrineActAsSerializablePlugin/trunk plugins/sfDoctrineActAsSerializablePlugin
16
17 or by using the default symfony plugin install command:
18
19     $ ./symfony plugin:install sfDoctrineActAsSerializablePlugin
20
21
22 Usage
23 =====
24
25 You don't have to worry about (un)serializing data when reading the data from
26 and saving it to the database. Everything will be done automatically from now
27 on. It's extremely useful when you want to keep array values in the database.
28
29     # Using global behavior will make no changes.
30
31     Xxx:
32       actAs:
33         Serializable:
34           fields: [ features, attributes ]
35           column_suffix: _srlzd
36
37 Set the fields that are going to be serializable. Doctrine will create new
38 columns with their names concatenated with the `column_suffix`. In the above
39 example, the `Xxx` model woud have `features_srlzd` and `attributes_srlzd`
40 columns.
41
42 no postConstruct
43 ----------------
44
45 The problem with Doctrine is that there can be no postConstuct hook called after
46 a new record is created. [The topic](http://groups.google.com/group/doctrine-user/browse_thread/thread/9e045b4e7bffec23?pli=1)
47 was started in 2009 and there has been no solution for the 1.x Doctrine branch
48 yet. Hence, the hook had to be done in a different way, unfortunately. Each
49 model that uses the Serializable behavior should have the construct method
50 implemented with one extra line, just as below:
51
52   [php]
53   class Xxx extends BaseXxx
54   {
55     public function construct()
56     {
57       parent::construct();
58       Doctrine_Auxiliary_Tools::postConstruct($this);
59     }
60   }
61
62 The postConstruct method creates empty values for the serializable columns.
63
64 todo
65 ----
66
67  * fixtures
68
69 Thanks to
70 ---------
71
72 Miko Väli, who was looking for the same Doctrine feature as I was and whose
73 question in the google groups made it clear that I have to overcome the problem
74 myself.
75
76 Comments, bug reports, suggestions
77 ----------------------------------
78
79 If you want to comment on the plugin or suggest your ideas, please feel free to
80 mail me.
Note: See TracBrowser for help on using the browser.