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


PHP Inflector::underscore方法代码示例

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


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

示例1: getOptionParser

 /**
  * Gets the option parser instance and configures it.
  *
  * @return \Cake\Console\ConsoleOptionParser
  */
 public function getOptionParser()
 {
     $parser = parent::getOptionParser();
     $parser->description('Asset Management for CakePHP.');
     foreach ($this->_taskMap as $task => $config) {
         $taskParser = $this->{$task}->getOptionParser();
         $parser->addSubcommand(Inflector::underscore($task), ['help' => $taskParser->description(), 'parser' => $taskParser]);
     }
     return $parser;
 }
开发者ID:phpie,项目名称:assetic-plugin,代码行数:15,代码来源:AsseticShell.php

示例2: main

 /**
  * main
  *
  */
 public function main()
 {
     $schemaPo = APP . 'Locale' . DS . 'schema.pot';
     $conn = ConnectionManager::get('default');
     $collection = $conn->schemaCollection();
     $translations = new Translations();
     $tables = $collection->listTables();
     foreach ($tables as $table) {
         $translations->insert($table, Inflector::humanize(Inflector::underscore($table)));
         $translations->insert($table, Inflector::humanize(Inflector::underscore(Inflector::singularize($table))));
         $columns = $collection->describe($table)->columns();
         foreach ($columns as $column) {
             $c = $collection->describe($table)->column($column);
             $comment = $c['comment'];
             $t = new Translation($table . '.' . $column, Inflector::humanize(Inflector::underscore($column)));
             $translations[] = $t;
             $t->setTranslation($comment);
             $t = new Translation($table . '.' . $column, Inflector::humanize(Inflector::underscore(Inflector::singularize($table))) . ' ' . Inflector::humanize(Inflector::underscore($column)));
             $translations[] = $t;
             $t->setTranslation($comment);
         }
     }
     $poString = $translations->toPoString();
     $caked = preg_replace('/msgctxt "([^"]+)"/i', '#: \\1', $poString);
     $this->createFile($schemaPo, $caked);
 }
开发者ID:k1low,项目名称:po,代码行数:30,代码来源:SchemaTask.php

示例3: _appendShells

 /**
  * Scan the provided paths for shells, and append them into $shellList
  *
  * @param string $type The type of object.
  * @param array $shells The shell name.
  * @param array $shellList List of shells.
  * @return array The updated $shellList
  */
 protected function _appendShells($type, $shells, $shellList)
 {
     foreach ($shells as $shell) {
         $shellList[$type][] = Inflector::underscore(str_replace('Shell', '', $shell));
     }
     return $shellList;
 }
开发者ID:fabioalvaro,项目名称:cakexuxu,代码行数:15,代码来源:CommandTask.php

示例4: get

 /**
  * Get/Create an instance from the registry.
  *
  * When getting an instance, if it does not already exist,
  * a new instance will be created using the provide alias, and options.
  *
  * @param string $alias The name of the alias to get.
  * @param array $options Configuration options for the type constructor.
  * @return \Cake\ElasticSearch\Type
  */
 public static function get($alias, array $options = [])
 {
     if (isset(static::$instances[$alias])) {
         if (!empty($options) && static::$options[$alias] !== $options) {
             throw new RuntimeException(sprintf('You cannot configure "%s", it already exists in the registry.', $alias));
         }
         return static::$instances[$alias];
     }
     static::$options[$alias] = $options;
     list(, $classAlias) = pluginSplit($alias);
     $options = $options + ['name' => Inflector::underscore($classAlias)];
     if (empty($options['className'])) {
         $options['className'] = Inflector::camelize($alias);
     }
     $className = App::className($options['className'], 'Model/Type', 'Type');
     if ($className) {
         $options['className'] = $className;
     } else {
         if (!isset($options['name']) && strpos($options['className'], '\\') === false) {
             list(, $name) = pluginSplit($options['className']);
             $options['name'] = Inflector::underscore($name);
         }
         $options['className'] = 'Cake\\ElasticSearch\\Type';
     }
     if (empty($options['connection'])) {
         $connectionName = $options['className']::defaultConnectionName();
         $options['connection'] = ConnectionManager::get($connectionName);
     }
     static::$instances[$alias] = new $options['className']($options);
     return static::$instances[$alias];
 }
开发者ID:jeffersongoncalves,项目名称:elastic-search,代码行数:41,代码来源:TypeRegistry.php

示例5: __construct

 /**
  * Class Constructor
  *
  * Merges defaults with
  * - Configure::read(Meta)
  * - Helper options
  * - viewVars _meta
  * in that order (the latter trumps)
  *
  * @param array $options
  */
 public function __construct(View $View, $options = [])
 {
     parent::__construct($View, $options);
     $configureMeta = (array) Configure::read('Meta');
     if (Configure::read('Meta.robots') && is_array(Configure::read('Meta.robots'))) {
         $configureMeta['robots'] = Hash::merge($this->meta['robots'], Configure::read('Meta.robots'));
     }
     $this->meta = $configureMeta + $this->meta;
     if (!empty($options['robots']) && is_array($options['robots'])) {
         $options['robots'] = Hash::merge($this->meta['robots'], $options['robots']);
     }
     $this->meta = $options + $this->meta;
     if (!empty($this->_View->viewVars['_meta'])) {
         $viewVarsMeta = (array) $this->_View->viewVars['_meta'];
         if (!empty($viewVarsMeta['robots']) && is_array($viewVarsMeta['robots'])) {
             $viewVarsMeta['robots'] = Hash::merge($this->meta['robots'], $viewVarsMeta['robots']);
         }
         $this->meta = $viewVarsMeta + $this->meta;
     }
     if ($this->meta['charset'] === null) {
         // By default include this
         $this->meta['charset'] = true;
     }
     if ($this->meta['icon'] === null) {
         // By default include this
         $this->meta['icon'] = true;
     }
     if ($this->meta['title'] === null) {
         $this->meta['title'] = __(Inflector::humanize(Inflector::underscore($this->request->params['controller']))) . ' - ' . __(Inflector::humanize(Inflector::underscore($this->request->params['action'])));
     }
 }
开发者ID:dereuromark,项目名称:cakephp-meta,代码行数:42,代码来源:MetaHelper.php

示例6: getConfig

 /**
  * Overrides the original method from phinx in order to return a tailored
  * Config object containing the connection details for the database.
  *
  * @param bool $forceRefresh
  * @return \Phinx\Config\Config
  */
 public function getConfig($forceRefresh = false)
 {
     if ($this->configuration && $forceRefresh === false) {
         return $this->configuration;
     }
     $folder = 'Migrations';
     if ($this->input->getOption('source')) {
         $folder = $this->input->getOption('source');
     }
     $dir = ROOT . DS . 'config' . DS . $folder;
     $plugin = null;
     if ($this->input->getOption('plugin')) {
         $plugin = $this->input->getOption('plugin');
         $dir = Plugin::path($plugin) . 'config' . DS . $folder;
     }
     if (!is_dir($dir)) {
         mkdir($dir, 0777, true);
     }
     $plugin = $plugin ? Inflector::underscore($plugin) . '_' : '';
     $plugin = str_replace(['\\', '/', '.'], '_', $plugin);
     $connection = $this->getConnectionName($this->input);
     $connectionConfig = ConnectionManager::config($connection);
     $adapterName = $this->getAdapterName($connectionConfig['driver']);
     $config = ['paths' => ['migrations' => $dir], 'environments' => ['default_migration_table' => $plugin . 'phinxlog', 'default_database' => 'default', 'default' => ['adapter' => $adapterName, 'host' => isset($connectionConfig['host']) ? $connectionConfig['host'] : null, 'user' => isset($connectionConfig['username']) ? $connectionConfig['username'] : null, 'pass' => isset($connectionConfig['password']) ? $connectionConfig['password'] : null, 'port' => isset($connectionConfig['port']) ? $connectionConfig['port'] : null, 'name' => $connectionConfig['database'], 'charset' => isset($connectionConfig['encoding']) ? $connectionConfig['encoding'] : null, 'unix_socket' => isset($connectionConfig['unix_socket']) ? $connectionConfig['unix_socket'] : null]]];
     if ($adapterName === 'mysql') {
         if (!empty($connectionConfig['ssl_key']) && !empty($connectionConfig['ssl_cert'])) {
             $config['environments']['default']['mysql_attr_ssl_key'] = $connectionConfig['ssl_key'];
             $config['environments']['default']['mysql_attr_ssl_cert'] = $connectionConfig['ssl_cert'];
         }
         if (!empty($connectionConfig['ssl_ca'])) {
             $config['environments']['default']['mysql_attr_ssl_ca'] = $connectionConfig['ssl_ca'];
         }
     }
     return $this->configuration = new Config($config);
 }
开发者ID:JoHein,项目名称:LeBonCoup,代码行数:42,代码来源:ConfigurationTrait.php

示例7: variant

 /**
  * Return the webroot path to the image generated variant if this exist or to the controller if not.
  *
  * @param string $imagePath         Path to the original image file from webroot if absolute, or relative to img/
  * @param string|array $variantName Name of the variant configuration key or options array
  * @param array $options            options
  * @return string
  */
 public function variant($imagePath, $variantName, array $options = [])
 {
     if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) {
         list($plugin, $imagePath) = $this->_View->pluginSplit($imagePath, false);
     }
     $url = false;
     $imagePath = $imagePath[0] === '/' ? substr($imagePath, 1) : $imagePath;
     if (!isset($plugin)) {
         $originalFile = WWW_ROOT . $imagePath;
         $variantFile = dirname($originalFile) . DS . $variantName . DS . basename($originalFile);
         if (is_file($variantFile)) {
             $url = str_replace(DS, '/', str_replace(WWW_ROOT, '/', $variantFile));
         }
     } else {
         $originalFile = WWW_ROOT . Inflector::underscore($plugin) . DS . $imagePath;
         $variantFile = dirname($originalFile) . DS . $variantName . DS . basename($originalFile);
         if (is_file($variantFile)) {
             $url = str_replace(DS, '/', str_replace(WWW_ROOT, '/', $variantFile));
         } else {
             $originalFile = Plugin::path($plugin) . 'webroot' . DS . $imagePath;
             $variantFile = dirname($originalFile) . DS . $variantName . DS . basename($originalFile);
             if (is_file($variantFile)) {
                 $url = str_replace(Plugin::path($plugin) . 'webroot' . DS, '/' . Inflector::underscore($plugin) . '/', $variantFile);
                 $url = str_replace(DS, '/', $url);
             }
         }
     }
     if ($url === false) {
         $url = ['controller' => 'Presenter', 'action' => 'variant', 'plugin' => 'ImagePresenter', 'prefix' => false, '?' => ['image' => isset($plugin) ? "{$plugin}.{$imagePath}" : $imagePath, 'variant' => $variantName]];
     }
     return Router::url($url);
 }
开发者ID:xavier83ar,项目名称:image-presenter,代码行数:40,代码来源:ImageHelper.php

示例8: _list

 /**
  * Get list of plugins to process. Plugins without a webroot directory are skipped.
  *
  * @param string|null $name Name of plugin for which to symlink assets.
  *   If null all plugins will be processed.
  * @return array List of plugins with meta data.
  */
 protected function _list($name = null)
 {
     if ($name === null) {
         $pluginsList = Plugin::loaded();
     } else {
         if (!Plugin::loaded($name)) {
             $this->err(sprintf('Plugin %s is not loaded.', $name));
             return [];
         }
         $pluginsList = [$name];
     }
     $plugins = [];
     foreach ($pluginsList as $plugin) {
         $path = Plugin::path($plugin) . 'webroot';
         if (!is_dir($path)) {
             $this->out('', 1, Shell::VERBOSE);
             $this->out(sprintf('Skipping plugin %s. It does not have webroot folder.', $plugin), 2, Shell::VERBOSE);
             continue;
         }
         $link = Inflector::underscore($plugin);
         $dir = WWW_ROOT;
         $namespaced = false;
         if (strpos($link, '/') !== false) {
             $namespaced = true;
             $parts = explode('/', $link);
             $link = array_pop($parts);
             $dir = WWW_ROOT . implode(DIRECTORY_SEPARATOR, $parts) . DIRECTORY_SEPARATOR;
         }
         $plugins[$plugin] = ['srcPath' => Plugin::path($plugin) . 'webroot', 'destDir' => $dir, 'link' => $link, 'namespaced' => $namespaced];
     }
     return $plugins;
 }
开发者ID:CakeDC,项目名称:cakephp,代码行数:39,代码来源:AssetsTask.php

示例9: tabs

 /**
  * Create bootstrap tabs.
  *
  * @param array $data
  * @param string $id
  * @return string
  * @SuppressWarnings(PHPMD.ShortVariable)
  */
 public function tabs($id, array $data = [])
 {
     $i = 0;
     $output = [];
     foreach ($data as $key => $options) {
         $i++;
         $title = !is_array($options) ? $options : $key;
         $alias = Text::slug((string) Inflector::underscore($key), '-');
         if (is_string($options)) {
             $options = [];
         }
         $_options = ['linkOptions' => ['data-toggle' => 'tab']];
         if (isset($options['title'])) {
             $title = $options['title'];
             unset($options['title']);
         }
         $_options['linkOptions']['title'] = $title;
         if ($i == 1) {
             $_options = $this->addClass($_options, 'active');
         }
         $options = Hash::merge($_options, $options);
         $linkOptions = $options['linkOptions'];
         unset($options['linkOptions']);
         $link = $this->Html->link($title, '#' . $alias, $linkOptions);
         $output[] = $this->Html->tag('li', $link, $options);
     }
     return $this->Html->tag('ul', implode('', $output), ['class' => 'nav nav-tabs', 'id' => $id]);
 }
开发者ID:UnionCMS,项目名称:Core,代码行数:36,代码来源:UnionHelper.php

示例10: getConfig

 /**
  * Overrides the original method from phinx in order to return a tailored
  * Config object containing the connection details for the database.
  *
  * @return Phinx\Config\Config
  */
 public function getConfig()
 {
     if ($this->configuration) {
         return $this->configuration;
     }
     $folder = 'Migrations';
     if ($this->input->getOption('source')) {
         $folder = $this->input->getOption('source');
     }
     $dir = ROOT . DS . 'config' . DS . $folder;
     $plugin = null;
     if ($this->input->getOption('plugin')) {
         $plugin = $this->input->getOption('plugin');
         $dir = Plugin::path($plugin) . 'config' . DS . $folder;
     }
     if (!is_dir($dir)) {
         mkdir($dir, 0777, true);
     }
     $plugin = $plugin ? Inflector::underscore($plugin) . '_' : '';
     $plugin = str_replace(array('\\', '/', '.'), '_', $plugin);
     $connection = 'default';
     if ($this->input->getOption('connection')) {
         $connection = $this->input->getOption('connection');
     }
     $config = ConnectionManager::config($connection);
     return $this->configuration = new Config(['paths' => ['migrations' => $dir], 'environments' => ['default_migration_table' => $plugin . 'phinxlog', 'default_database' => 'default', 'default' => ['adapter' => $this->getAdapterName($config['driver']), 'host' => isset($config['host']) ? $config['host'] : null, 'user' => isset($config['username']) ? $config['username'] : null, 'pass' => isset($config['password']) ? $config['password'] : null, 'port' => isset($config['port']) ? $config['port'] : null, 'name' => $config['database'], 'charset' => $config['encoding']]]]);
 }
开发者ID:neilan35,项目名称:betterwindow1,代码行数:33,代码来源:ConfigurationTrait.php

示例11: getClasses

 /**
  * Get classes for main wrapper.
  *
  * @return string
  */
 public function getClasses()
 {
     $plugin = preg_replace('/[^A-Z0-9_\\.-]/i', '', $this->request->param('plugin'));
     $plugin = Inflector::underscore($plugin);
     $controller = mb_strtolower($this->request->param('controller'));
     $action = mb_strtolower($this->request->param('action'));
     return implode(' ', ['plg-' . Inflector::slug($plugin, '-'), 'cont-' . $controller, 'action-' . $action]);
 }
开发者ID:Cheren,项目名称:union,代码行数:13,代码来源:DocumentHelper.php

示例12: table

 /**
  * Returns the cache key (prefix) to be used with a table class.
  *
  * @param \Cake\ORM\Table $table The table class
  * @return string
  */
 public static function table(\Cake\ORM\Table $table)
 {
     $alias = get_class($table);
     if (false === isset(static::$liveCache[__FUNCTION__][$alias])) {
         static::$liveCache[__FUNCTION__][$alias] = implode('_', array_filter([Inflector::underscore($table->connection()->configName()), Fqn::prefix($alias), Inflector::underscore(Fqn::root($alias)), Inflector::underscore(Fqn::tail($alias)), Inflector::underscore($table->alias())]));
     }
     return static::$liveCache[__FUNCTION__][$alias];
 }
开发者ID:jmjjg,项目名称:cakephp-database,代码行数:14,代码来源:CacheKey.php

示例13: getActionName

 public function getActionName($controller, $id)
 {
     $this->autoRender = false;
     $indexed_tables = $this->_getIndexedTables();
     if (isset($indexed_tables[$controller][$id])) {
         echo $indexed_tables[$controller][$id] . ' (' . __(Inflector::humanize(Inflector::underscore($controller))) . ' / ' . $id . ')';
     }
 }
开发者ID:aiphee,项目名称:cakephp-related-content,代码行数:8,代码来源:RelatedContentController.php

示例14: elementName

 /**
  * Get the element name for the panel.
  *
  * @return string
  */
 public function elementName()
 {
     list($ns, $name) = namespaceSplit(get_class($this));
     if ($this->plugin) {
         return $this->plugin . '.' . Inflector::underscore($name);
     }
     return Inflector::underscore($name);
 }
开发者ID:fabioalvaro,项目名称:cakexuxu,代码行数:13,代码来源:DebugPanel.php

示例15: __call

 public function __call($method, $args)
 {
     $type = Inflector::underscore(substr($method, 3));
     if (!isset($args[0])) {
         $args[0] = [];
     }
     $args[0] += [$this->config('typeField') => $type];
     return call_user_func_array([$this->_table($type), 'newEntity'], $args);
 }
开发者ID:UseMuffin,项目名称:Sti,代码行数:9,代码来源:StiBehavior.php


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