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


PHP Inflector::dasherize方法代码示例

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


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

示例1: beforeRender

 /**
  * Before render callback.
  *
  * @param \Cake\Event\Event $event The beforeRender event.
  * @return void
  */
 public function beforeRender(Event $event)
 {
     parent::beforeRender($event);
     $params = $this->request->params;
     $page_id = Inflector::dasherize(implode('-', array_merge([$params['controller']], $params['pass'])));
     $this->set(compact('page_id'));
 }
开发者ID:m-esprit,项目名称:web-app,代码行数:13,代码来源:PagesController.php

示例2: _renderInputWithData

 /**
  * Renders new file input field with value. Applicable for edit action.
  *
  * @param  Table $table Table
  * @param  string $field Field
  * @param  array $options Options
  * @param  mixed $data Data
  * @return string HTML input field with data attribute.
  */
 protected function _renderInputWithData($table, $field, $data, $options)
 {
     $files = [];
     $hiddenIds = '';
     $fieldName = $this->_getFieldName($table, $field);
     $fileUploadsUtils = new FileUploadsUtils($table);
     $entities = $fileUploadsUtils->getFiles($table, $field, $data);
     if ($entities instanceof \Cake\ORM\ResultSet) {
         if (!$entities->count()) {
             return $this->_renderInputWithoutData($table, $field, $options);
         }
     }
     // @TODO: check if we return null anywhere, apart of ResultSet.
     // IF NOT: remove this block
     if (is_null($entities)) {
         return $this->_renderInputWithoutData($table, $field, $options);
     }
     foreach ($entities as $file) {
         $files[] = ['id' => $file->id, 'path' => $file->path];
         $hiddenIds .= $this->cakeView->Form->hidden($this->_getFieldName($table, $field, $options) . '_ids][', ['class' => str_replace('.', '_', $fieldName . '_ids'), 'value' => $file->id]);
     }
     $label = $this->cakeView->Form->label($field);
     $uploadField = $this->cakeView->Form->file($fieldName . '[]', ['multiple' => true, 'data-document-id' => $data, 'data-upload-url' => sprintf("/api/%s/upload", Inflector::dasherize($table->table())), 'data-files' => json_encode($files)]);
     return sprintf(self::WRAPPER, $label, $uploadField, $hiddenIds);
 }
开发者ID:QoboLtd,项目名称:cakephp-csv-migrations,代码行数:34,代码来源:FilesFieldHandler.php

示例3: bodyCssClass

 public function bodyCssClass()
 {
     $page = WasabiCms::page();
     $classes = [];
     $classes[] = 'layout-' . Inflector::dasherize($page->layout);
     $classes[] = 'page-' . Inflector::dasherize($page->slug);
     return implode(' ', $classes);
 }
开发者ID:wasabi-cms,项目名称:cms,代码行数:8,代码来源:ThemeView.php

示例4: _dasherize

 /**
  * Helper method for dasherizing keys in a URL array.
  *
  * @param array $url An array of URL keys.
  * @return array
  */
 protected function _dasherize($url)
 {
     foreach (['controller', 'plugin', 'action'] as $element) {
         if (!empty($url[$element])) {
             $url[$element] = Inflector::dasherize($url[$element]);
         }
     }
     return $url;
 }
开发者ID:sylwesterkowal,项目名称:plugin.cakephp-slug,代码行数:15,代码来源:SlugRoute.php

示例5: nameTransaction

 /**
  * nameTransaction() method.
  *
  * Name the transaction using request data.
  *
  * @param Cake\Network\Network $request The request.
  * @return string
  */
 public function nameTransaction(Request $request)
 {
     $plugin = $request->params['plugin'];
     $prefix = $request->params['prefix'];
     $controller = $request->params['controller'];
     $action = $request->params['action'];
     $transaction = Inflector::dasherize($controller) . '/' . $action;
     if ($prefix !== null) {
         $transaction = Inflector::dasherize($prefix) . '/' . $transaction;
     }
     if ($plugin !== null) {
         $transaction = Inflector::dasherize($plugin) . '/' . $transaction;
     }
     return $transaction;
 }
开发者ID:brunitto,项目名称:cakephp-new-relic,代码行数:23,代码来源:NameTransactionFilter.php

示例6: _generateFiles

 /**
  * Generate all files for a plugin
  *
  * Find the first path which contains `src/Template/Bake/Plugin` that contains
  * something, and use that as the template to recursively render a plugin's
  * contents. Allows the creation of a bake them containing a `Plugin` folder
  * to provide customized bake output for plugins.
  *
  * @param string $pluginName the CamelCase name of the plugin
  * @param string $path the path to the plugins dir (the containing folder)
  * @return void
  */
 protected function _generateFiles($pluginName, $path)
 {
     $namespace = str_replace('/', '\\', $pluginName);
     $name = $pluginName;
     $vendor = 'your-name-here';
     if (strpos($pluginName, '/') !== false) {
         list($vendor, $name) = explode('/', $pluginName);
     }
     $package = $vendor . '/' . $name;
     $this->BakeTemplate->set(['package' => $package, 'namespace' => $namespace, 'plugin' => $pluginName, 'routePath' => Inflector::dasherize($pluginName), 'path' => $path, 'root' => ROOT]);
     $root = $path . $pluginName . DS;
     $paths = [];
     if (!empty($this->params['theme'])) {
         $paths[] = Plugin::path($this->params['theme']) . 'src/Template/';
     }
     $paths = array_merge($paths, Configure::read('App.paths.templates'));
     $paths[] = Plugin::path('Bake') . 'src/Template/';
     do {
         $templatesPath = array_shift($paths) . 'Bake/Plugin';
         $templatesDir = new Folder($templatesPath);
         $templates = $templatesDir->findRecursive('.*\\.ctp');
     } while (!$templates);
     sort($templates);
     foreach ($templates as $template) {
         $template = substr($template, strrpos($template, 'Plugin') + 7, -4);
         $this->_generateFile($template, $root);
     }
 }
开发者ID:MillHidden,项目名称:BiellesMeusiennes,代码行数:40,代码来源:PluginTask.php

示例7: testDasherized

 /**
  * testDasherized method
  *
  * @return void
  */
 public function testDasherized()
 {
     $this->assertSame('test-thing', Inflector::dasherize('TestThing'));
     $this->assertSame('test-thing', Inflector::dasherize('testThing'));
     $this->assertSame('test-thing-extra', Inflector::dasherize('TestThingExtra'));
     $this->assertSame('test-thing-extra', Inflector::dasherize('testThingExtra'));
     $this->assertSame('test-this-thing', Inflector::dasherize('test_this_thing'));
     // Test stupid values
     $this->assertSame('', Inflector::dasherize(null));
     $this->assertSame('', Inflector::dasherize(''));
     $this->assertSame('0', Inflector::dasherize(0));
     $this->assertSame('', Inflector::dasherize(false));
 }
开发者ID:jeremyheaton,项目名称:ultiswap,代码行数:18,代码来源:InflectorTest.php

示例8: __setPhoneKeys

 /**
  * @return void
  */
 private function __setPhoneKeys()
 {
     $keys = [];
     foreach ($this->_fieldsName['phone'] as $key) {
         $inflectored = [Inflector::camelize($key), Inflector::dasherize($key), Inflector::underscore($key), Inflector::variable($key)];
         foreach ($inflectored as $field) {
             // Default Version
             $keys[$field] = $field;
             // strtolower
             $keys[strtolower($key)] = strtolower($key);
             // strtoupper
             $keys[strtoupper($key)] = strtoupper($key);
         }
     }
     $this->_fields['phone'] = $keys;
 }
开发者ID:erwane,项目名称:cakephp-contact,代码行数:19,代码来源:ContactEntityTrait.php

示例9: _getPrefix

 /**
  * Get the prefix for a namespace.
  *
  * @param string|null $namespace The namespace to get a prefix from.
  * @return string|null
  */
 protected function _getPrefix($namespace = null)
 {
     if (empty($namespace)) {
         return null;
     }
     $pathArray = explode('\\', $namespace);
     if (count($pathArray) >= 5 && $pathArray[3] !== 'Controller') {
         return Inflector::dasherize($pathArray[3]) . '_';
     }
     return null;
 }
开发者ID:rochamarcelo,项目名称:acl,代码行数:17,代码来源:AclExtras.php

示例10: beforeRender

 /**
  * Before render callback.
  *
  * @param \Cake\Event\Event $event The beforeRender event.
  * @return void
  */
 public function beforeRender(Event $event)
 {
     if (!array_key_exists('_serialize', $this->viewVars) && in_array($this->response->type(), ['application/json', 'application/xml'])) {
         $this->set('_serialize', true);
     }
     $viewVars = [];
     $params = $this->request->params;
     if ($params['controller'] !== 'Pages') {
         $page_id = Inflector::dasherize($params['controller'] . '-' . $params['action']);
         $viewVars[] = 'page_id';
     }
     if ($user = $this->Auth->user()) {
         $user = TableRegistry::get('Users')->get($user['id']);
         $viewVars[] = 'user';
     }
     $this->set(compact($viewVars));
 }
开发者ID:m-esprit,项目名称:web-app,代码行数:23,代码来源:AppController.php

示例11: resourceKey

 /**
  * Return resource key.
  *
  * @param string $name Name.
  * @return string
  */
 public function resourceKey($name)
 {
     return Inflector::pluralize(Inflector::dasherize($name));
 }
开发者ID:cakeplugins,项目名称:api,代码行数:10,代码来源:TransformerTask.php


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