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


PHP Inflector::rules方法代码示例

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


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

示例1: testTransliteration

	public function testTransliteration() {
		$data = array(
			'transliteration' => array(
				'\$' => 'dollar',
				'&' => 'and'
			)
		);
		Catalog::write('runtime', 'inflection', 'en', $data);

		Inflector::rules(
			'transliteration', Catalog::read('runtime', 'inflection.transliteration', 'en')
		);

		$result = Inflector::slug('this & that');
		$expected = 'this-and-that';
		$this->assertEqual($expected, $result);

		$data = array(
			'transliteration' => array(
				't' => 'd',
				'&' => 'und'
			)
		);
		Catalog::write('runtime', 'inflection', 'de', $data);

		Inflector::rules(
			'transliteration', Catalog::read('runtime', 'inflection.transliteration', 'de')
		);

		$result = Inflector::slug('this & that');
		$expected = 'dhis-und-dhad';
		$this->assertEqual($expected, $result);
	}
开发者ID:niel,项目名称:lithium,代码行数:33,代码来源:CatalogInflectorTest.php

示例2: function

<?php

/**
 * radium: lithium application framework
 *
 * @copyright     Copyright 2013, brünsicke.com GmbH (http://bruensicke.com)
 * @license       http://opensource.org/licenses/BSD-3-Clause The BSD License
 */
use lithium\util\Inflector;
use lithium\util\Validator;
use radium\media\Mime;
/*
 * We want to avoid method names like `statuses()` - therefore, we go this route
 */
Inflector::rules('uninflected', 'status');
/*
 * apply new validation rules to the Validator class, because we need them
 */
Validator::add(array('sha1' => '/^[A-Fa-f0-9]{40}$/', 'slug' => '/^[a-z0-9\\_\\-\\.]*$/', 'loose_slug' => '/^[a-zA-Z0-9\\_\\-\\.]*$/', 'strict_slug' => '/^[a-z][a-z0-9\\_\\-]*$/', 'isUnique' => function ($value, $format, $options) {
    $conditions = array($options['field'] => $value);
    foreach ((array) $options['model']::meta('key') as $field) {
        if (!empty($options['values'][$field])) {
            $conditions[$field] = array('!=' => $options['values'][$field]);
        }
    }
    $fields = $options['field'];
    $result = $options['model']::find('first', compact('fields', 'conditions'));
    return (bool) empty($result);
}, 'status' => function ($value, $format, $options) {
    return (bool) $options['model']::status($value);
}, 'type' => function ($value, $format, $options) {
开发者ID:bruensicke,项目名称:radium,代码行数:31,代码来源:validators.php

示例3: testAddingUninflectedWords

 public function testAddingUninflectedWords()
 {
     $this->assertEqual(Inflector::pluralize('bord'), 'bords');
     Inflector::rules('uninflected', 'bord');
     $this->assertEqual(Inflector::pluralize('bord'), 'bord');
 }
开发者ID:nashadalam,项目名称:lithium,代码行数:6,代码来源:InflectorTest.php


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