当前位置: 首页>>代码示例>>PHP>>正文


PHP sfInflector::underscore方法代码示例

本文整理汇总了PHP中sfInflector::underscore方法的典型用法代码示例。如果您正苦于以下问题:PHP sfInflector::underscore方法的具体用法?PHP sfInflector::underscore怎么用?PHP sfInflector::underscore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sfInflector的用法示例。


在下文中一共展示了sfInflector::underscore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: executeGenerate

 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));
 }
开发者ID:souravmondal-cn,项目名称:symfonyweather,代码行数:25,代码来源:sfDoctrineGenerateModuleTask.class.php

示例2: __call

 /**
  * 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();
 }
开发者ID:kawahara,项目名称:opPointPlugin,代码行数:31,代码来源:opPointPluginConfiguration.class.php

示例3: processSave

 /**
  * 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;
 }
开发者ID:cbsistem,项目名称:appflower_studio,代码行数:36,代码来源:afStudioLayoutCommand.class.php

示例4: compile

 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;
     }
 }
开发者ID:bshaffer,项目名称:Symfony-Snippets,代码行数:32,代码来源:csModelGeneratorConfiguration.class.php

示例5: retrieveGadgetsByTypesName

 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;
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:27,代码来源:GadgetTable.class.php

示例6: getLinkToAction

 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";
 }
开发者ID:nvidela,项目名称:kimkelen,代码行数:26,代码来源:sfPropelRevisitedGenerator.class.php

示例7: addFields

 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)));
     }
 }
开发者ID:nurfiantara,项目名称:ehri-ica-atom,代码行数:26,代码来源:globalReplaceAction.class.php

示例8: getObjects

 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;
 }
开发者ID:eyumay,项目名称:srms.psco,代码行数:32,代码来源:sfDependentSelectDoctrineSource.class.php

示例9: fromArray

 public function fromArray($params)
 {
     foreach ($this as $prop => $value) {
         $optName = sfInflector::underscore(str_replace('_', '', $prop));
         if (isset($params[$optName])) {
             $this->{$prop} = $params[$optName];
         }
     }
 }
开发者ID:eyumay,项目名称:srms.psco,代码行数:9,代码来源:sfDependentSelectSource.class.php

示例10: run

 /**
  * 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();
     }
 }
开发者ID:jakzal,项目名称:gyImagenePlugin,代码行数:15,代码来源:gyLimeTest.class.php

示例11: setup

  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']));
  }
开发者ID:romankallweit,项目名称:swingmachine,代码行数:10,代码来源:sfHadoriThemeConfiguration.class.php

示例12: renderHeaders

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>';
    }
}
开发者ID:solutema,项目名称:siwapp-sf1,代码行数:10,代码来源:SiwappHelper.php

示例13: getObjectForParameters

 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;
 }
开发者ID:kiwpon,项目名称:opWebAPIPlugin,代码行数:10,代码来源:opWebAPIRoute.class.php

示例14: __call

 /**
  * 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);
         }
     }
 }
开发者ID:quafzi,项目名称:timpanyPlugin,代码行数:18,代码来源:PlugintpyOrderItem.class.php

示例15: getConfig

 /**
  * 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;
 }
开发者ID:WIZARDISHUNGRY,项目名称:symfony,代码行数:22,代码来源:sfModelGeneratorConfigurationField.class.php


注:本文中的sfInflector::underscore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。