Development

/branches/1.3/lib/plugins/sfPropelPlugin/lib/generator/sfPropelAdminGenerator.class.php

You must first sign up to be able to contribute.

root/branches/1.3/lib/plugins/sfPropelPlugin/lib/generator/sfPropelAdminGenerator.class.php

Revision 9134, 1.7 kB (checked in by dwhittle, 7 years ago)

sfPropelPlugin: merged r9132 (phpdoc updates)

  • Property svn:mime-type set to text/x-php
  • 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) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.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  * Propel Admin generator.
13  *
14  * This class generates an admin module with propel.
15  *
16  * @package    symfony
17  * @subpackage propel
18  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
19  * @version    SVN: $Id$
20  */
21
22 class sfPropelAdminGenerator extends sfPropelCrudGenerator
23 {
24   /**
25    * Initializes the current sfGenerator instance.
26    *
27    * @param sfGeneratorManager $generatorManager A sfGeneratorManager instance
28    */
29   public function initialize(sfGeneratorManager $generatorManager)
30   {
31     parent::initialize($generatorManager);
32
33     $this->setGeneratorClass('sfPropelAdmin');
34   }
35
36   public function getAllColumns()
37   {
38     $phpNames = array();
39     foreach ($this->getTableMap()->getColumns() as $column)
40     {
41       $phpNames[] = new sfAdminColumn($column->getPhpName(), $column);
42     }
43
44     return $phpNames;
45   }
46
47   public function getAdminColumnForField($field, $flag = null)
48   {
49     $phpName = sfInflector::camelize($field);
50
51     return new sfAdminColumn($phpName, $this->getColumnForPhpName($phpName), $flag);
52   }
53
54   // returns a column phpName or null if none was found
55   public function getColumnForPhpName($phpName)
56   {
57     // search the matching column for this column name
58
59     foreach ($this->getTableMap()->getColumns() as $column)
60     {
61       if ($column->getPhpName() == $phpName)
62       {
63         $found = true;
64
65         return $column;
66       }
67     }
68
69     // not a "real" column, so we will simulate one
70     return null;
71   }
72 }
73
Note: See TracBrowser for help on using the browser.