Development

/branches/1.3/lib/generator/sfModelGeneratorHelper.class.php

You must first sign up to be able to contribute.

root/branches/1.3/lib/generator/sfModelGeneratorHelper.class.php

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

[1.3] moved methods that don't need to be generated from generator templates to base classes, added abstract signatures for the rest. removed unused getConnection() method.

  • 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  * Model generator helper.
5  *
6  * @package    symfony
7  * @subpackage generator
8  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
9  * @version    SVN: $Id$
10  */
11 abstract class sfModelGeneratorHelper
12 {
13   abstract public function getUrlForAction($action);
14
15   public function linkToNew($params)
16   {
17     return '<li class="sf_admin_action_new">'.link_to(__($params['label'], array(), 'sf_admin'), '@'.$this->getUrlForAction('new')).'</li>';
18   }
19
20   public function linkToEdit($object, $params)
21   {
22     return '<li class="sf_admin_action_edit">'.link_to(__($params['label'], array(), 'sf_admin'), $this->getUrlForAction('edit'), $object).'</li>';
23   }
24
25   public function linkToDelete($object, $params)
26   {
27     if ($object->isNew())
28     {
29       return '';
30     }
31
32     return '<li class="sf_admin_action_delete">'.link_to(__($params['label'], array(), 'sf_admin'), $this->getUrlForAction('delete'), $object, array('method' => 'delete', 'confirm' => !empty($params['confirm']) ? __($params['confirm'], array(), 'sf_admin') : $params['confirm'])).'</li>';
33   }
34
35   public function linkToList($params)
36   {
37     return '<li class="sf_admin_action_list">'.link_to(__($params['label'], array(), 'sf_admin'), '@'.$this->getUrlForAction('list')).'</li>';
38   }
39
40   public function linkToSave($object, $params)
41   {
42     return '<li class="sf_admin_action_save"><input type="submit" value="'.__($params['label'], array(), 'sf_admin').'" /></li>';
43   }
44
45   public function linkToSaveAndAdd($object, $params)
46   {
47     if (!$object->isNew())
48     {
49       return '';
50     }
51
52     return '<li class="sf_admin_action_save_and_add"><input type="submit" value="'.__($params['label'], array(), 'sf_admin').'" name="_save_and_add" /></li>';
53   }
54 }
55
Note: See TracBrowser for help on using the browser.