Permalink
Browse files

App::uses and usage replacements for String => CakeText.

  • Loading branch information...
dereuromark committed Jan 5, 2015
1 parent 63093e1 commit 52ecccb1a295d4605e8777162c5017d23a5eec3c
@@ -122,7 +122,7 @@ public function generate() {
if ($this->params['force']) {
$options['models'] = false;
} elseif (!empty($this->params['models'])) {
$options['models'] = String::tokenize($this->params['models']);
$options['models'] = CakeText::tokenize($this->params['models']);
}
$snapshot = false;
@@ -151,7 +151,7 @@ public function generate() {
Configure::write('Cache.disable', $cacheDisable);
if (!empty($this->params['exclude']) && !empty($content)) {
$excluded = String::tokenize($this->params['exclude']);
$excluded = CakeText::tokenize($this->params['exclude']);
foreach ($excluded as $table) {
unset($content['tables'][$table]);
}
@@ -340,7 +340,7 @@ protected function _generateRecords($tableInfo, $recordCount = 1) {
isset($fieldInfo['length']) && $fieldInfo['length'] == 36
);
if ($isPrimaryUuid) {
$insert = String::uuid();
$insert = CakeText::uuid();
} else {
$insert = "Lorem ipsum dolor sit amet";
if (!empty($fieldInfo['length'])) {
@@ -18,7 +18,7 @@
App::uses('AppShell', 'Console/Command');
App::uses('File', 'Utility');
App::uses('Folder', 'Utility');
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');
App::uses('Security', 'Utility');
/**
@@ -212,7 +212,7 @@ public function bake($path, $skel = null, $skip = array('empty')) {
}
foreach ($Folder->messages() as $message) {
$this->out(String::wrap(' * ' . $message), 1, Shell::VERBOSE);
$this->out(CakeText::wrap(' * ' . $message), 1, Shell::VERBOSE);
}
return true;
@@ -14,7 +14,7 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');
/**
* HelpFormatter formats help for console shells. Can format to either
@@ -64,7 +64,7 @@ public function text($width = 72) {
$out = array();
$description = $parser->description();
if (!empty($description)) {
$out[] = String::wrap($description, $width);
$out[] = CakeText::wrap($description, $width);
$out[] = '';
}
$out[] = __d('cake_console', '<info>Usage:</info>');
@@ -76,7 +76,7 @@ public function text($width = 72) {
$out[] = '';
$max = $this->_getMaxLength($subcommands) + 2;
foreach ($subcommands as $command) {
$out[] = String::wrap($command->help($max), array(
$out[] = CakeText::wrap($command->help($max), array(
'width' => $width,
'indent' => str_repeat(' ', $max),
'indentAt' => 1
@@ -93,7 +93,7 @@ public function text($width = 72) {
$out[] = __d('cake_console', '<info>Options:</info>');
$out[] = '';
foreach ($options as $option) {
$out[] = String::wrap($option->help($max), array(
$out[] = CakeText::wrap($option->help($max), array(
'width' => $width,
'indent' => str_repeat(' ', $max),
'indentAt' => 1
@@ -108,7 +108,7 @@ public function text($width = 72) {
$out[] = __d('cake_console', '<info>Arguments:</info>');
$out[] = '';
foreach ($arguments as $argument) {
$out[] = String::wrap($argument->help($max), array(
$out[] = CakeText::wrap($argument->help($max), array(
'width' => $width,
'indent' => str_repeat(' ', $max),
'indentAt' => 1
@@ -118,7 +118,7 @@ public function text($width = 72) {
}
$epilog = $parser->epilog();
if (!empty($epilog)) {
$out[] = String::wrap($epilog, $width);
$out[] = CakeText::wrap($epilog, $width);
$out[] = '';
}
return implode("\n", $out);
@@ -584,11 +584,11 @@ protected function _getInput($prompt, $options, $default) {
* @param string $text Text the text to format.
* @param string|int|array $options Array of options to use, or an integer to wrap the text to.
* @return string Wrapped / indented text
* @see String::wrap()
* @see CakeText::wrap()
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::wrapText
*/
public function wrapText($text, $options = array()) {
return String::wrap($text, $options);
return CakeText::wrap($text, $options);
}
/**
@@ -17,7 +17,7 @@
*/
App::uses('Component', 'Controller');
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');
App::uses('Hash', 'Utility');
App::uses('Security', 'Utility');
@@ -103,10 +103,10 @@ public static function bootstrap($boot = true) {
self::$_values['Exception']
);
// Preload Debugger + String in case of E_STRICT errors when loading files.
// Preload Debugger + CakeText in case of E_STRICT errors when loading files.
if (self::$_values['debug'] > 0) {
class_exists('Debugger');
class_exists('String');
class_exists('CakeText');
}
}
}
@@ -140,7 +140,7 @@ public function beforeFind(Model $Model, $query) {
unset($this->_joinTable, $this->_runtimeModel);
return $query;
} elseif (is_string($query['fields'])) {
$query['fields'] = String::tokenize($query['fields']);
$query['fields'] = CakeText::tokenize($query['fields']);
}
$fields = array_merge(
@@ -17,7 +17,7 @@
*/
App::uses('DboSource', 'Model/Datasource');
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');
/**
* DBO implementation for the SQLite3 DBMS.
@@ -303,7 +303,7 @@ public function resultSet($results) {
if (stripos($querystring, 'SELECT') === 0 && stripos($querystring, 'FROM') > 0) {
$selectpart = substr($querystring, 7);
$selects = array();
foreach (String::tokenize($selectpart, ',', '(', ')') as $part) {
foreach (CakeText::tokenize($selectpart, ',', '(', ')') as $part) {
$fromPos = stripos($part, ' FROM ');
if ($fromPos !== false) {
$selects[] = trim(substr($part, 0, $fromPos));
@@ -17,7 +17,7 @@
*/
App::uses('DataSource', 'Model/Datasource');
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');
App::uses('View', 'View');
/**
@@ -2513,7 +2513,7 @@ public function fields(Model $Model, $alias = null, $fields = array(), $quote =
if ($allFields) {
$fields = array_keys($Model->schema());
} elseif (!is_array($fields)) {
$fields = String::tokenize($fields);
$fields = CakeText::tokenize($fields);
}
$fields = array_values(array_filter($fields));
$allFields = $allFields || in_array('*', $fields) || in_array($Model->alias . '.*', $fields);
@@ -2813,7 +2813,7 @@ protected function _parseKey($key, $value, Model $Model = null) {
}
if ($bound) {
return String::insert($key . ' ' . trim($operator), $value);
return CakeText::insert($key . ' ' . trim($operator), $value);
}
if (!preg_match($operatorMatch, trim($operator))) {
View
@@ -20,7 +20,7 @@
App::uses('ClassRegistry', 'Utility');
App::uses('Validation', 'Utility');
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');
App::uses('Hash', 'Utility');
App::uses('BehaviorCollection', 'Model');
App::uses('ModelBehavior', 'Model');
@@ -1915,9 +1915,9 @@ protected function _doSave($data = null, $options = array()) {
if (empty($this->data[$this->alias][$this->primaryKey]) && $this->_isUUIDField($this->primaryKey)) {
if (array_key_exists($this->primaryKey, $this->data[$this->alias])) {
$j = array_search($this->primaryKey, $fields);
$values[$j] = String::uuid();
$values[$j] = CakeText::uuid();
} else {
list($fields[], $values[]) = array($this->primaryKey, String::uuid());
list($fields[], $values[]) = array($this->primaryKey, CakeText::uuid());
}
}
@@ -2026,7 +2026,7 @@ protected function _saveMulti($joined, $id, $db) {
$values = array($id, $row);
if ($isUUID && $primaryAdded) {
$values[] = String::uuid();
$values[] = CakeText::uuid();
}
$newValues[$row] = $values;
@@ -3187,7 +3187,7 @@ protected function _findList($state, $query, $results = array()) {
$list = array("{n}.{$this->alias}.{$this->primaryKey}", "{n}.{$this->alias}.{$this->displayField}", null);
} else {
if (!is_array($query['fields'])) {
$query['fields'] = String::tokenize($query['fields']);
$query['fields'] = CakeText::tokenize($query['fields']);
}
if (count($query['fields']) === 1) {
@@ -17,7 +17,7 @@
App::uses('Multibyte', 'I18n');
App::uses('AbstractTransport', 'Network/Email');
App::uses('File', 'Utility');
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');
App::uses('View', 'View');
/**
@@ -776,7 +776,7 @@ public function getHeaders($include = array()) {
}
if ($this->_messageId !== false) {
if ($this->_messageId === true) {
$headers['Message-ID'] = '<' . str_replace('-', '', String::UUID()) . '@' . $this->_domain . '>';
$headers['Message-ID'] = '<' . str_replace('-', '', CakeText::UUID()) . '@' . $this->_domain . '>';
} else {
$headers['Message-ID'] = $this->_messageId;
}
@@ -20,7 +20,7 @@
App::uses('Model', 'Model');
App::uses('AppModel', 'Model');
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
@@ -73,7 +73,7 @@ public function testAddWithPreSpecifiedId() {
'conditions' => array($modelClass . '.name' => '1.1')
));
$id = String::uuid();
$id = CakeText::uuid();
$this->Tree->create();
$result = $this->Tree->save(array($modelClass => array(
'id' => $id,
@@ -19,7 +19,7 @@
*/
App::uses('CakeLog', 'Log');
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');
/**
* Provide custom logging and error handling.
@@ -337,7 +337,7 @@ public static function trace($options = array()) {
$trace['path'] = self::trimPath($trace['file']);
$trace['reference'] = $reference;
unset($trace['object'], $trace['args']);
$back[] = String::insert($tpl, $trace, array('before' => '{:', 'after' => '}'));
$back[] = CakeText::insert($tpl, $trace, array('before' => '{:', 'after' => '}'));
}
}
@@ -637,7 +637,7 @@ public static function outputAs($format = null) {
*
* `Debugger::addFormat('custom', $data);`
*
* Where $data is an array of strings that use String::insert() variable
* Where $data is an array of strings that use CakeText::insert() variable
* replacement. The template vars should be in a `{:id}` style.
* An error formatter can have the following keys:
*
@@ -775,7 +775,7 @@ public function outputError($data) {
if (isset($tpl['links'])) {
foreach ($tpl['links'] as $key => $val) {
$links[$key] = String::insert($val, $data, $insertOpts);
$links[$key] = CakeText::insert($val, $data, $insertOpts);
}
}
@@ -791,14 +791,14 @@ public function outputError($data) {
if (is_array($value)) {
$value = implode("\n", $value);
}
$info .= String::insert($tpl[$key], array($key => $value) + $data, $insertOpts);
$info .= CakeText::insert($tpl[$key], array($key => $value) + $data, $insertOpts);
}
$links = implode(' ', $links);
if (isset($tpl['callback']) && is_callable($tpl['callback'])) {
return call_user_func($tpl['callback'], $data, compact('links', 'info'));
}
echo String::insert($tpl['error'], compact('links', 'info') + $data, $insertOpts);
echo CakeText::insert($tpl['error'], compact('links', 'info') + $data, $insertOpts);
}
/**
@@ -14,7 +14,7 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');
/**
* Library of array functions for manipulating and extracting data
@@ -112,7 +112,7 @@ public static function extract(array $data, $path) {
if (strpos($path, '[') === false) {
$tokens = explode('.', $path);
} else {
$tokens = String::tokenize($path, '.', '[', ']');
$tokens = CakeText::tokenize($path, '.', '[', ']');
}
$_key = '__set_item__';
@@ -258,7 +258,7 @@ public static function insert(array $data, $path, $values = null) {
if (strpos($path, '[') === false) {
$tokens = explode('.', $path);
} else {
$tokens = String::tokenize($path, '.', '[', ']');
$tokens = CakeText::tokenize($path, '.', '[', ']');
}
if (strpos($path, '{') === false && strpos($path, '[') === false) {
@@ -341,7 +341,7 @@ public static function remove(array $data, $path) {
if (strpos($path, '[') === false) {
$tokens = explode('.', $path);
} else {
$tokens = String::tokenize($path, '.', '[', ']');
$tokens = CakeText::tokenize($path, '.', '[', ']');
}
if (strpos($path, '{') === false && strpos($path, '[') === false) {
@@ -16,7 +16,7 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');
/**
* Security Library contains utility methods related to security
@@ -63,7 +63,7 @@ public static function inactiveMins() {
* @return string Hash
*/
public static function generateAuthKey() {
return Security::hash(String::uuid());
return Security::hash(CakeText::uuid());
}
/**
View
@@ -16,7 +16,7 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');
App::uses('Hash', 'Utility');
/**
@@ -549,7 +549,7 @@ public static function classicExtract($data, $path = null) {
return null;
}
if (is_string($path) && strpos($path, '{') !== false) {
$path = String::tokenize($path, '.', '{', '}');
$path = CakeText::tokenize($path, '.', '{', '}');
} elseif (is_string($path)) {
$path = explode('.', $path);
}
Oops, something went wrong.

0 comments on commit 52ecccb

Please sign in to comment.