protected function executeGenerate($arguments = array(), $options = array()) { // generate module $tmpDir = sfConfig::get('sf_cache_dir') . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . md5(uniqid(rand(), true)); $generatorManager = new sfGeneratorManager($this->configuration, $tmpDir); $generatorManager->generate('sfDoctrineGenerator', array('model_class' => $arguments['model'], 'moduleName' => $arguments['module'], 'theme' => $options['theme'], 'non_verbose_templates' => $options['non-verbose-templates'], 'with_show' => $options['with-show'], 'singular' => $options['singular'] ? $options['singular'] : sfInflector::underscore($arguments['model']), 'plural' => $options['plural'] ? $options['plural'] : sfInflector::underscore($arguments['model'] . 's'), 'route_prefix' => $options['route-prefix'], 'with_doctrine_route' => $options['with-doctrine-route'], 'actions_base_class' => $options['actions-base-class'])); $moduleDir = sfConfig::get('sf_app_module_dir') . '/' . $arguments['module']; // copy our generated module $this->getFilesystem()->mirror($tmpDir . DIRECTORY_SEPARATOR . 'auto' . ucfirst($arguments['module']), $moduleDir, sfFinder::type('any')); if (!$options['with-show']) { $this->getFilesystem()->remove($moduleDir . '/templates/showSuccess.php'); } // change module name $finder = sfFinder::type('file')->name('*.php'); $this->getFilesystem()->replaceTokens($finder->in($moduleDir), '', '', array('auto' . ucfirst($arguments['module']) => $arguments['module'])); // customize php and yml files $finder = sfFinder::type('file')->name('*.php', '*.yml'); $this->getFilesystem()->replaceTokens($finder->in($moduleDir), '##', '##', $this->constants); // create basic test $this->getFilesystem()->copy(sfConfig::get('sf_symfony_lib_dir') . DIRECTORY_SEPARATOR . 'task' . DIRECTORY_SEPARATOR . 'generator' . DIRECTORY_SEPARATOR . 'skeleton' . DIRECTORY_SEPARATOR . 'module' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'actionsTest.php', sfConfig::get('sf_test_dir') . DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR . $arguments['application'] . DIRECTORY_SEPARATOR . $arguments['module'] . 'ActionsTest.php'); // customize test file $this->getFilesystem()->replaceTokens(sfConfig::get('sf_test_dir') . DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR . $arguments['application'] . DIRECTORY_SEPARATOR . $arguments['module'] . 'ActionsTest.php', '##', '##', $this->constants); // delete temp files $this->getFilesystem()->remove(sfFinder::type('any')->in($tmpDir)); }
/** * magic method to use listen to some event * * @param string $methodName * @param array $args */ public function __call($methodName, $args) { if (0 === strpos($methodName, 'listenTo')) { $name = sfInflector::underscore(substr($methodName, 8)); if (!in_array($name, array_keys(self::getPointConfig()))) { throw new BadMethodCallException(); } if (!(1 === count($args) && $args[0] instanceof sfEvent)) { throw new InvalidArgumentException(); } $event = $args[0]; if (0 === strpos($event->getName(), 'op_action.post_execute')) { if (isset(self::$pointConfig[$name]['check'])) { $check = self::$pointConfig[$name]['check']; if ('redirect' === $check && $event->getSubject() instanceof opFrontWebController && sfView::SUCCESS === $event['result'] || $event['result'] === $check) { $this->pointUp($name); } return; } $this->pointUp($name); } return; } throw new BadMethodCallException(); }
/** * Saving changed page information * * @return afResponse * @author Sergey Startsev */ protected function processSave() { // Getting needed parameters - page, application name, and sure definition $page_name = pathinfo($this->getParameter('page'), PATHINFO_FILENAME); $application = $this->getParameter('app'); $definition = $this->getParameter('definition', array()); $module = $this->getParameter('module', self::PAGES_MODULE); $permissions = new Permissions(); $is_writable = $permissions->isWritable(sfConfig::get('sf_apps_dir') . '/' . $application . '/config/pages/'); if ($is_writable !== true) { return $is_writable; } //idXml is stored inside the portal_state table from appFlowerPlugin $idXml = "pages/{$page_name}"; $page = afsPageModelHelper::retrieve($page_name, $application); $is_new = $page->isNew(); $page->setTitle(sfInflector::humanize(sfInflector::underscore($page_name))); $page->setDefinition($definition); $saveResponse = $page->save(); $response = afResponseHelper::create(); if ($saveResponse->getParameter(afResponseSuccessDecorator::IDENTIFICATOR)) { $console = afStudioConsole::getInstance()->execute(array("sf appflower:portal-state-cc {$idXml}", "sf appflower:validator-cache frontend cache yes", 'sf afs:fix-perms')); return $response->success(true)->content(!$is_new ? sprintf('Page <b>%s</b> has been saved', $page_name) : sprintf('Page <b>%s</b> has been created', $page_name))->console($console); } $response->success(false); if ($saveResponse->hasParameter(afResponseMessageDecorator::IDENTIFICATOR)) { $response->content($saveResponse->getParameter(afResponseMessageDecorator::IDENTIFICATOR)); } return $response; }
protected function compile() { parent::compile(); // =================================== // = Add for exporting configuration = // =================================== $this->configuration['credentials']['export'] = array(); $this->configuration['export'] = array('fields' => array(), 'title' => $this->getExportTitle(), 'actions' => $this->getExportActions() ? $this->getExportActions() : array('_list' => array('action' => 'index', 'label' => 'Back'))); $config = $this->getConfig(); foreach (array_keys($config['default']) as $field) { $formConfig = array_merge($config['default'][$field], isset($config['form'][$field]) ? $config['form'][$field] : array()); $this->configuration['export']['fields'][$field] = new sfModelGeneratorConfigurationField($field, array_merge(array('label' => sfInflector::humanize(sfInflector::underscore($field))), $config['default'][$field], isset($config['export'][$field]) ? $config['export'][$field] : array())); } foreach ($this->getExportDisplay() as $field) { list($field, $flag) = sfModelGeneratorConfigurationField::splitFieldWithFlag($field); $this->configuration['export']['fields'][$field] = new sfModelGeneratorConfigurationField($field, array_merge(array('type' => 'Text', 'label' => sfInflector::humanize(sfInflector::underscore($field))), isset($config['default'][$field]) ? $config['default'][$field] : array(), isset($config['export'][$field]) ? $config['export'][$field] : array(), array('flag' => $flag))); } // export actions foreach ($this->configuration['export']['actions'] as $action => $parameters) { $this->configuration['export']['actions'][$action] = $this->fixActionParameters($action, $parameters); } $this->configuration['export']['display'] = array(); foreach ($this->getExportDisplay() as $name) { list($name, $flag) = sfModelGeneratorConfigurationField::splitFieldWithFlag($name); if (!isset($this->configuration['export']['fields'][$name])) { throw new InvalidArgumentException(sprintf('The field "%s" does not exist.', $name)); } $field = $this->configuration['export']['fields'][$name]; $field->setFlag($flag); $this->configuration['export']['display'][$name] = $field; } }
public function retrieveGadgetsByTypesName($typesName) { if (isset($this->gadgets[$typesName])) { return $this->gadgets[$typesName]; } if (sfConfig::get('op_is_enable_gadget_cache', true)) { $dir = sfConfig::get('sf_app_cache_dir') . '/config'; $file = $dir . '/' . sfInflector::underscore($typesName) . "_gadgets.php"; if (is_readable($file)) { $results = unserialize(file_get_contents($file)); $this->gadgets[$typesName] = $results; return $results; } } $types = $this->getTypes($typesName); foreach ($types as $type) { $results[$type] = $this->retrieveByType($type); } if (sfConfig::get('op_is_enable_gadget_cache', true)) { if (!is_dir($dir)) { @mkdir($dir, 0777, true); } file_put_contents($file, serialize($results)); } $this->gadgets[$typesName] = $results; return $results; }
public function getLinkToAction($actionName, $params, $pk_link = false) { $options = isset($params['params']) && !is_array($params['params']) ? sfToolkit::stringToArray($params['params']) : array(); // default values if ($actionName[0] == '_') { $actionName = substr($actionName, 1); $name = $actionName; //$icon = sfConfig::get('sf_admin_web_dir').'/images/'.$actionName.'_icon.png'; $action = $actionName; if ($actionName == 'delete') { $options['post'] = true; if (!isset($options['confirm'])) { $options['confirm'] = 'Are you sure?'; } } } else { $name = isset($params['name']) ? $params['name'] : $actionName; //$icon = isset($params['icon']) ? sfToolkit::replaceConstants($params['icon']) : sfConfig::get('sf_admin_web_dir').'/images/default_icon.png'; $action = isset($params['action']) ? $params['action'] : 'List' . sfInflector::camelize($actionName); } $url_params = $pk_link ? '?' . $this->getPrimaryKeyUrlParams() : '\''; $phpOptions = var_export($options, true); // little hack $phpOptions = preg_replace("/'confirm' => '(.+?)(?<!\\\\)'/", '\'confirm\' => __(\'$1\')', $phpOptions); return '<li class="sf_admin_action_' . sfInflector::underscore($name) . '">[?php echo link_to(__(\'' . $params['label'] . '\'), \'' . $this->getModuleName() . '/' . $action . $url_params . ($options ? ', ' . $phpOptions : '') . ') ?]</li>' . "\n"; }
public function addFields() { // Information object attribute (db column) to perform s/r on $map = new InformationObjectI18nTableMap(); foreach ($map->getColumns() as $col) { if (!$col->isPrimaryKey() && !$col->isForeignKey()) { $col_name = $col->getPhpName(); $choices[$col_name] = sfInflector::humanize(sfInflector::underscore($col_name)); } } $this->form->setValidator('column', new sfValidatorString()); $this->form->setWidget('column', new sfWidgetFormSelect(array('choices' => $choices), array('style' => 'width: auto'))); // Search-replace values $this->form->setValidator('pattern', new sfValidatorString()); $this->form->setWidget('pattern', new sfWidgetFormInput()); $this->form->setValidator('replacement', new sfValidatorString()); $this->form->setWidget('replacement', new sfWidgetFormInput()); $this->form->setValidator('caseSensitive', new sfValidatorBoolean()); $this->form->setWidget('caseSensitive', new sfWidgetFormInputCheckbox()); $this->form->setValidator('allowRegex', new sfValidatorBoolean()); $this->form->setWidget('allowRegex', new sfWidgetFormInputCheckbox()); if ($this->request->isMethod('post') && !isset($this->request->confirm) && !empty($this->request->pattern) && !empty($this->request->replacement)) { $this->form->setValidator('confirm', new sfValidatorBoolean()); $this->form->setWidget('confirm', new sfWidgetFormInputHidden(array(), array('value' => true))); } }
public function getObjects($fk = null) { if (!$this->_tableMethod) { $query = Doctrine_Core::getTable($this->_model)->createQuery(); if (is_array($order = $this->_orderBy)) { $query->addOrderBy($order[0] . ' ' . $order[1]); } if ($fk) { $refColumn = str_replace('get_', '', sfInflector::underscore($this->_refMethod)); $query->addWhere("{$refColumn} = ?", $fk); } $objects = $query->execute(); } else { $tableMethod = $this->_tableMethod; $results = Doctrine_Core::getTable($this->_model)->{$tableMethod}($fk); if ($results instanceof Doctrine_Query) { $objects = $results->execute(); } else { if ($results instanceof Doctrine_Collection) { $objects = $results; } else { if ($results instanceof Doctrine_Record) { $objects = new Doctrine_Collection($this->_model); $objects[] = $results; } else { $objects = array(); } } } } return $objects; }
public function fromArray($params) { foreach ($this as $prop => $value) { $optName = sfInflector::underscore(str_replace('_', '', $prop)); if (isset($params[$optName])) { $this->{$prop} = $params[$optName]; } } }
/** * Runs all test methods * * @return null */ public function run() { foreach ($this->getTestMethods() as $method) { $test = $method->getName(); $this->info(sfInflector::humanize(sfInflector::underscore(substr($test, 4)))); $this->setUp(); $this->{$test}(); $this->tearDown(); } }
public function setup() { $this->askForApplication(); $this->askForModel(); $this->task->bootstrapSymfony($this->options['application'], $this->options['env']); $this->askForOption('module', null, sfInflector::underscore($this->options['model'])); }
function renderHeaders($headers, $sort, $route) { foreach ($headers as $k => $v) { echo '<th class="' . strtolower(sfInflector::underscore($k)) . '">'; $change_sort_type = $sort[0] == $k && $sort[1] == $v[1] ? toggleStatus($v[1]) : $v[1]; $class = $sort[0] == $k ? toggleStatus($change_sort_type) : null; echo link_to(__($v[0]), $route . '?sort[0]=' . $k . '&sort[1]=' . $change_sort_type, array('class' => $class)); echo '</th>'; } }
protected function getObjectForParameters($parameters) { $query = Doctrine::getTable($this->options['model'])->createQuery(); if (self::URI_TYPE_MEMBER === $this->options['uriType']) { return $query->where('id = ?', $parameters['id']); } elseif (self::URI_TYPE_COLLECTION === $this->options['uriType'] && isset($parameters['parent_model'])) { return $query->where(sfInflector::underscore($parameters['parent_model']) . '_id = ?', $parameters['parent_id']); } return $query; }
/** * extend magic getter to access frozen product data * * @throws Doctrine_Record_UnknownPropertyException * * @see lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/record/sfDoctrineRecord::__call() */ public function __call($method, $args) { if ('get' == substr($method, 0, 3)) { $property = sfInflector::underscore(substr($method, 3)); try { return parent::get($property); } catch (Doctrine_Record_UnknownPropertyException $e) { return $this->getFrozen($property); } } }
/** * Returns the configuration value for a given key. * * If the key is null, the method returns all the configuration array. * * @param string $key A key string * @param mixed $default The default value if the key does not exist * @param Boolean $escaped Whether to escape single quote (false by default) * * @return mixed The configuration value associated with the key */ public function getConfig($key = null, $default = null, $escaped = false) { if (is_null($key)) { return $this->config; } if ('label' == $key && !isset($this->config['label'])) { return sfInflector::humanize(sfInflector::underscore($this->name)); } $value = sfModelGeneratorConfiguration::getFieldConfigValue($this->config, $key, $default); return $escaped ? str_replace("'", "\\'", $value) : $value; }
function delete_form_for_object($object, $internal_uri = null, $call_me = null) { $form = new DeleteForm(); $form->setDefault('id', $object->getId()); if ($internal_uri == null) { $internal_uri = sfInflector::underscore(get_class($object)) . '/delete'; } if ($call_me == null) { $call_me = strtolower(get_class($object)); } return '<form class="delete-form" action="' . url_for($internal_uri) . '" method="POST">' . $form . '<a class="delete-button" href="#">Delete ' . $call_me . '</a>' . ' <span class="confirm" style="display: none;">' . 'Are you sure you want to delete this ' . $call_me . '? ' . '<a class="confirm-yes" href="#">Yes</a> ' . '<a class="confirm-no" href="#">No</a>' . '</span>' . '</form>'; }
public function getPKeysStringIdentifiers($prefix = '', $full = false) { $params = array(); foreach ($this->getPrimaryKeys() as $pk) { $fieldName = sfInflector::underscore($pk); if ($full) { $params[] = sprintf("%s->%s()", $prefix . 'coco', $this->getColumnGetter($fieldName, false)); } else { $params[] = sprintf("%s", $this->getColumnGetter($fieldName, true, $prefix)); } } return implode(".'&", $params); }
protected function mergePresetAndValues($preset, $values) { $result = array(); foreach ($preset as $k => $v) { $k = sfInflector::underscore($k); if (in_array($k, array('is_config', 'is_regist', 'is_search'))) { $k = str_replace('is_', 'is_disp_', $k); } $result[$k] = $v; } $result = array_merge($result, $values); return $result; }
public function __call($method, $args) { switch (substr($method, 0, 3)) { case 'set': $property = sfInflector::underscore(substr($method, 3)); return $this->{$property} = $args[0]; case 'get': $property = sfInflector::underscore(substr($method, 3)); return $this->{$property}; default: throw new Exception('Undefined method "' . $method . '"'); } }
public function getObjects($fk = null) { $class = constant($this->_model . '::PEER'); $criteria = new Criteria(); if (is_array($order = $this->_orderBy)) { $method = sprintf('add%sOrderByColumn', 0 === strpos(strtoupper($order[1]), 'ASC') ? 'Ascending' : 'Descending'); $criteria->{$method}(call_user_func(array($class, 'translateFieldName'), $order[0], BasePeer::TYPE_PHPNAME, BasePeer::TYPE_COLNAME)); } if ($fk) { $criteria->add(call_user_func(array($class, 'translateFieldName'), str_replace('get_', '', sfInflector::underscore($this->_refMethod)), BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME), $fk); } return call_user_func(array($class, $this->_peerMethod), $criteria); }
public function getGadgetConfigListByType($type) { $configs = sfConfig::get('op_gadget_config'); foreach ($configs as $key => $config) { if (in_array($type, self::getTypes($key))) { $configName = 'op_' . sfInflector::underscore($key); if ('gadget' !== $key) { $configName .= '_gadget'; } $configName .= '_list'; return sfConfig::get($configName, array()); } } return array(); }
public function setup() { require_once dirname(__FILE__) . '/../config/opSecurityConfigHandler.class.php'; $DS = DIRECTORY_SEPARATOR; $OpenPNE2Path = sfConfig::get('sf_lib_dir') . $DS . 'vendor' . $DS; // ##PROJECT_LIB_DIR##/vendor/ set_include_path($OpenPNE2Path . PATH_SEPARATOR . get_include_path()); $result = parent::setup(); $configCache = $this->getConfigCache(); $file = $configCache->checkConfig('data/config/plugin.yml', true); if ($file) { include $file; } require_once dirname(__FILE__) . '/../plugin/opPluginManager.class.php'; $pluginActivations = opPluginManager::getPluginActivationList(); $pluginActivations = array_merge(array_fill_keys($this->getPlugins(), true), $pluginActivations); foreach ($pluginActivations as $key => $value) { if (!in_array($key, $this->getPlugins())) { unset($pluginActivations[$key]); } } $pluginActivations = $this->filterSkinPlugins($pluginActivations); $this->enablePlugins(array_keys($pluginActivations, true)); $this->disablePlugins(array_keys($pluginActivations, false)); unset($this->cache['getPluginPaths']); // it should be rewrited $this->plugins = array_unique($this->plugins); // gadget include $this->getConfigCache()->checkConfig('config/gadget_layout_config.yml'); include $this->getConfigCache()->checkConfig('config/gadget_config.yml'); require_once sfConfig::get('sf_lib_dir') . '/config/opGadgetConfigHandler.class.php'; $gadgetConfigs = sfConfig::get('op_gadget_config', array()); foreach ($gadgetConfigs as $key => $config) { $filename = 'config/' . sfInflector::underscore($key); $params = array(); if ($key != 'gadget') { $filename .= '_gadget'; $params['prefix'] = sfInflector::underscore($key) . '_'; } $filename .= '.yml'; $this->getConfigCache()->registerConfigHandler($filename, 'opGadgetConfigHandler', $params); include $this->getConfigCache()->checkConfig($filename); } return $result; }
protected function generateRoutes() { $options = $this->getOptions(); $apis = array('retrieve_feed', 'retrieve_resource', 'insert_resource', 'update_resource', 'delete_resource'); if (!empty($options['apis'])) { $apis = (array) $options['apis']; } $model = $options['model']; if (!class_exists(ucfirst($model))) { return false; } $parentModel = ''; $prefix = 'feeds_' . sfInflector::underscore($model) . '_'; if (!empty($options['parent_model'])) { $parentModel = $options['parent_model']; if (!class_exists(ucfirst($parentModel))) { return false; } } foreach ($this->templates as $name => $template) { if (!in_array($name, $apis)) { continue; } $uris = array(); $action = array('module' => 'feeds', 'action' => $template['action']); $requirements = array('model' => $model, 'sf_method' => $template['method']); $routeOption = array('model' => ucfirst($model), 'type' => 'object', 'uriType' => $template['uriType']); $routeOption['api_name'] = 'webapi_' . sfInflector::underscore($model) . '_' . $template['method']; $routeOption['api_caption'] = ucfirst($template['method']) . ' ' . sfInflector::humanize($model) . ' item(s)'; if ($template['uriType'] === opWebAPIRoute::URI_TYPE_COLLECTION) { $uri = $this->collectionUriRule; if ($parentModel) { $uri .= '/:parent_model/:parent_id'; $requirements['parent_model'] = $parentModel; } $uris['normal'] = $uri; $uris['category'] = $uri . '/-/*'; } else { $uris['normal'] = $this->memberUriRule; } foreach ($uris as $key => $value) { $this->routes[$prefix . $name . '_' . $key] = new opWebAPIRoute($value, array_merge($action, array('sf_format' => 'atom')), $requirements, $routeOption); } } }
public static function setIntervalConfigs($values) { $configTable = Doctrine::getTable('SnsConfig'); foreach (self::$defaultIntervalConfigs as $key => $default) { if (!isset($values[$key])) { continue; } $configName = self::$configPrefix . sfInflector::underscore($key); $value = $values[$key]; if ($value === $default) { $record = $configTable->retrieveByName($configName); if ($record) { $record->delete(); } } else { $configTable->set($configName, $value); } } }
public function __call($func, $args) { //-- Add Generic get* metonds switch (substr($func, 0, 3)) { case 'get': $field = sfInflector::underscore(substr($func, 3)); if (0 === strlen($field)) { return $this->data[$args[0]]; } if (array_key_exists($field, $this->data)) { return $this->data[$field]; } else { return null; } break; default: throw new Exception('Fatal Error: Call to undefined method ' . __CLASS__ . '::' . $func . '() in ' . __FILE__ . ' on ' . __LINE__); break; } }
protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $properties = parse_ini_file(sfConfig::get('sf_config_dir') . '/properties.ini', true); $constants = array('PROJECT_NAME' => isset($properties['symfony']['name']) ? $properties['symfony']['name'] : 'symfony', 'APP_NAME' => $arguments['application'], 'MODULE_NAME' => $arguments['module'], 'MODEL_CLASS' => $arguments['model'], 'AUTHOR_NAME' => isset($properties['symfony']['author']) ? $properties['symfony']['author'] : 'Your name here', 'THEME' => $options['theme'], 'OBJECT_NAME' => sfInflector::humanize(sfInflector::underscore($arguments['model']))); $moduleDir = sfConfig::get('sf_app_module_dir') . '/' . $arguments['module']; // create module structure $finder = sfFinder::type('any')->discard('.sf'); $dirs = $this->configuration->getGeneratorSkeletonDirs('DbFinderAdmin', $options['theme']); foreach ($dirs as $dir) { if (is_dir($dir)) { $this->getFilesystem()->mirror($dir, $moduleDir, $finder); break; } } // customize php and yml files $finder = sfFinder::type('file')->name('*.php', '*.yml'); $this->getFilesystem()->replaceTokens($finder->in($moduleDir), '##', '##', $constants); //set our generated directories writable so we can put generated files in them //$finder = sfFinder::type('directory')->ignore_version_control()->discard('.sf'); //$this->getFilesystem()->chmod($finder,$moduleDir,0777); }
protected function parseVariables($context, $key) { preg_match_all('/%%([^%]+)%%/', $this->configuration[$context][$key], $matches, PREG_PATTERN_ORDER); foreach ($matches[1] as $name) { list($name, $flag) = sfModelGeneratorConfigurationField::splitFieldWithFlag($name); if (!isset($this->configuration[$context]['fields'][$name])) { $this->configuration[$context]['fields'][$name] = new sfModelGeneratorConfigurationField($name, array_merge(array('type' => 'Text', 'label' => sfInflector::humanize(sfInflector::underscore($name))), isset($config['default'][$name]) ? $config['default'][$name] : array(), isset($config[$context][$name]) ? $config[$context][$name] : array(), array('flag' => $flag))); } else { $this->configuration[$context]['fields'][$name]->setFlag($flag); } $this->configuration[$context][$key] = str_replace('%%' . $flag . $name . '%%', '%%' . $name . '%%', $this->configuration[$context][$key]); } }
/** * Gets all the fields for the current model. * * @param Boolean $withM2M Whether to include m2m fields or not * * @return array An array of field names */ public function getAllFieldNames($withM2M = true) { $names = array(); foreach ($this->getColumns() as $name => $column) { $names[] = sfInflector::underscore($name); } if ($withM2M) { foreach ($this->getManyToManyTables() as $tables) { $names[] = sfInflector::underscore($tables['alias']) . '_list'; } } return $names; }
/** * Returns the task name * * @return string The task name */ public function getName() { if ($this->name) { return $this->name; } $name = get_class($this); if ('sf' == substr($name, 0, 2)) { $name = substr($name, 2); } if ('Task' == substr($name, -4)) { $name = substr($name, 0, -4); } return str_replace('_', '-', sfInflector::underscore($name)); }
$form = $this->getFormObject(); ?> <h1><?php echo sfInflector::humanize($this->getModuleName()); ?> List</h1> <table> <thead> <tr> <?php foreach ($this->getColumns() as $column) { ?> <th><?php echo sfInflector::humanize(sfInflector::underscore($column->getPhpName())); ?> </th> <?php } ?> </tr> </thead> <tbody> [?php foreach ($<?php echo $this->getPluralName(); ?> as $<?php echo $this->getSingularName(); ?> ): ?]