Skip to content

Commit 67d45cb

Browse files
author
gwoo
committed
updating headers on inflector and adding map param to slug(). added more comments to app/config/bootstrap.php
1 parent 66959d5 commit 67d45cb

File tree

3 files changed

+48
-54
lines changed

3 files changed

+48
-54
lines changed

app/config/bootstrap.php

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,46 @@
11
<?php
2-
/* SVN FILE: $Id$ */
32
/**
4-
* Short description for file.
3+
* This file is loaded automatically by the app/webroot/index.php file after the core bootstrap.php
54
*
6-
* Long description for file
5+
* This is an application wide file to load any function that is not used within a class
6+
* define. You can also use this to include or require any files in your application.
77
*
88
* PHP versions 4 and 5
99
*
10-
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
11-
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
10+
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
11+
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://cakefoundation.org)
1212
*
1313
* Licensed under The MIT License
1414
* Redistributions of files must retain the above copyright notice.
1515
*
16-
* @filesource
17-
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
18-
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
16+
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://cakefoundation.org)
17+
* @link http://cakephp.org CakePHP(tm) Project
1918
* @package cake
2019
* @subpackage cake.app.config
2120
* @since CakePHP(tm) v 0.10.8.2117
22-
* @version $Revision$
23-
* @modifiedby $LastChangedBy$
24-
* @lastmodified $Date$
2521
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
2622
*/
2723
/**
24+
* The settings below can be used to set additional paths to models, views and controllers.
25+
* This is related to Ticket #470 (https://trac.cakephp.org/ticket/470)
2826
*
29-
* This file is loaded automatically by the app/webroot/index.php file after the core bootstrap.php is loaded
30-
* This is an application wide file to load any function that is not used within a class define.
31-
* You can also use this to include or require any files in your application.
27+
* $modelPaths = array('/full/path/to/models/', '/next/full/path/to/models/');
28+
* $viewPaths = array('/full/path/to/views/', '/next/full/path/to/views/');
29+
* $controllerPaths = array(/full/path/to/controllers/', '/next/full/path/to/controllers/');
30+
* $pluginPaths = array('/full/path/to/plugins/', '/next/full/path/to/plugins/');
31+
* $behaviorPaths = array('/full/path/to/behaviors/', '/next/full/path/to/behaviors/');
32+
* $componentPaths = array('/full/path/to/components/', '/next/full/path/to/components/');
33+
* $helperPaths = array('/full/path/to/helpers/', '/next/full/path/to/helpers/');
34+
* $vendorPaths = array('/full/path/to/vendors/', '/next/full/path/to/vendors/');
35+
* $shellPaths = array('/full/path/to/shells/', '/next/full/path/to/shells/');
36+
* $localePaths = array('/full/path/to/locale/', '/next/full/path/to/locale/';
3237
*
3338
*/
3439
/**
35-
* The settings below can be used to set additional paths to models, views and controllers.
36-
* This is related to Ticket #470 (https://trac.cakephp.org/ticket/470)
40+
* As of 1.3, additional rules for the inflector are added below
3741
*
38-
* $modelPaths = array('full path to models', 'second full path to models', 'etc...');
39-
* $viewPaths = array('this path to views', 'second full path to views', 'etc...');
40-
* $controllerPaths = array('this path to controllers', 'second full path to controllers', 'etc...');
42+
* Inflector::rule('singular', array('rules' => array(), irregular' => array(), 'uninflected' => array()));
43+
* Inflector::rule('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
4144
*
4245
*/
43-
//EOF
44-
45-
// Inflector::rule('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
46-
// Inflector::rule('singular', array('rules' => array(), irregular' => array(), 'uninflected' => array()));
47-
4846
?>

cake/libs/inflector.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
11
<?php
2-
/* SVN FILE: $Id$ */
32
/**
43
* Pluralize and singularize English words.
54
*
65
* Used by Cake's naming conventions throughout the framework.
76
*
87
* PHP versions 4 and 5
98
*
10-
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
11-
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
9+
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
10+
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
1211
*
1312
* Licensed under The MIT License
1413
* Redistributions of files must retain the above copyright notice.
1514
*
16-
* @filesource
17-
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
18-
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
15+
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
16+
* @link http://cakephp.org
1917
* @package cake
2018
* @subpackage cake.cake.libs
2119
* @since CakePHP(tm) v 0.2.9
22-
* @version $Revision$
23-
* @modifiedby $LastChangedBy$
24-
* @lastmodified $Date$
25-
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
20+
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
2621
*/
2722
/**
2823
* Included libraries.
2924
*
3025
*/
3126
if (!class_exists('Object')) {
32-
uses('object');
27+
require_once(LIBS . 'object.php');
3328
}
3429
/**
3530
* Pluralize and singularize English words.
@@ -422,17 +417,18 @@ function variable($string) {
422417
* Returns a string with all spaces converted to underscores (by default), accented
423418
* characters converted to non-accented characters, and non word characters removed.
424419
*
425-
* @param string $string
426-
* @param string $replacement
420+
* @param string $string the string you want to slug
421+
* @param string $replacement will replace keys in map
422+
* @param array $map extra elements to map to the replacement
427423
* @return string
428424
* @access public
429425
* @static
430426
* @link http://book.cakephp.org/view/572/Class-methods
431427
*/
432-
function slug($string, $replacement = '_') {
428+
function slug($string, $replacement = '_', $map = array()) {
433429
$quotedReplacement = preg_quote($replacement, '/');
434430

435-
$map = array(
431+
$default = array(
436432
'/à|á|å|â/' => 'a',
437433
'/è|é|ê|ẽ|ë/' => 'e',
438434
'/ì|í|î/' => 'i',
@@ -451,6 +447,7 @@ function slug($string, $replacement = '_') {
451447
'/\\s+/' => $replacement,
452448
sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '',
453449
);
450+
$map = array_merge($default, $map);
454451
return preg_replace(array_keys($map), array_values($map), $string);
455452
}
456453
}

cake/tests/cases/libs/inflector.test.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
<?php
2-
/* SVN FILE: $Id$ */
32
/**
4-
* Short description for file.
3+
* InflectorTest
54
*
6-
* Long description for file
5+
* InflectorTest is used to test cases on the Inflector class
76
*
87
* PHP versions 4 and 5
98
*
10-
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
11-
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
9+
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
10+
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
1211
*
13-
* Licensed under The Open Group Test Suite License
14-
* Redistributions of files must retain the above copyright notice.
12+
* Licensed under The Open Group Test Suite License
13+
* Redistributions of files must retain the above copyright notice.
1514
*
16-
* @filesource
17-
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
18-
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
15+
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
16+
* @link http://book.cakephp.org/view/160/Testing
1917
* @package cake.tests
2018
* @subpackage cake.tests.cases.libs
2119
* @since CakePHP(tm) v 1.2.0.4206
22-
* @version $Revision$
23-
* @modifiedby $LastChangedBy$
24-
* @lastmodified $Date$
25-
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
20+
* @license Open Group Test Suite License (http://www.opensource.org/licenses/opengroup.php)
21+
*/
22+
/**
23+
* Included libraries.
24+
*
2625
*/
2726
App::import('Core', 'Inflector');
2827
/**
@@ -305,4 +304,4 @@ function tearDown() {
305304
unset($this->Inflector);
306305
}
307306
}
308-
?>
307+
?>

0 commit comments

Comments
 (0)