Development

/branches/1.3/lib/plugins/sfDoctrinePlugin/lib/record/sfDoctrineRecordI18nFilter.class.php

You must first sign up to be able to contribute.

root/branches/1.3/lib/plugins/sfDoctrinePlugin/lib/record/sfDoctrineRecordI18nFilter.class.php

Revision 24337, 1.7 kB (checked in by Kris.Wallsmith, 5 years ago)

[1.3, 1.4] cleaned up comments and coding standards in doctrine record classes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) Jonathan H. Wage <jonwage@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * sfDoctrineRecordI18nFilter implements access to the translated properties for
13  * the current culture from the internationalized model.
14  *
15  * @package    symfony
16  * @subpackage doctrine
17  * @author     Jonathan H. Wage <jonwage@gmail.com>
18  * @version    SVN: $Id$
19  */
20 class sfDoctrineRecordI18nFilter extends Doctrine_Record_Filter
21 {
22   /**
23    * @see Doctrine_Table::unshiftFilter()
24    */
25   public function init()
26   {
27   }
28
29   /**
30    * Calls set on Translation relationship.
31    *
32    * Allows manipulation of I18n properties from the main object.
33    *
34    * @param Doctrine_Record $record
35    * @param string          $name   Name of the property
36    * @param string          $value  Value of the property
37    */
38   public function filterSet(Doctrine_Record $record, $name, $value)
39   {
40     return $record['Translation'][sfDoctrineRecord::getDefaultCulture()][$name] = $value;
41   }
42
43   /**
44    * Call get on Translation relationship.
45    *
46    * Allow access to I18n properties from the main object.
47    *
48    * @param Doctrine_Record $record
49    * @param string          $name   Name of the property
50    */
51   public function filterGet(Doctrine_Record $record, $name)
52   {
53     $culture = sfDoctrineRecord::getDefaultCulture();
54     if (isset($record['Translation'][$culture]))
55     {
56       return $record['Translation'][$culture][$name];
57     }
58     else
59     {
60       $defaultCulture = sfConfig::get('sf_default_culture');
61       return $record['Translation'][$defaultCulture][$name];
62     }
63   }
64 }
Note: See TracBrowser for help on using the browser.