當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。