本文整理匯總了PHP中Inflector::Singularize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::Singularize方法的具體用法?PHP Inflector::Singularize怎麽用?PHP Inflector::Singularize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Inflector
的用法示例。
在下文中一共展示了Inflector::Singularize方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getHeaders
/**
* DEPENDS on app_model for translateFieldNames and getFieldNames
* DEPENDS on that you dont change default model and/or controller name
* gets translated tablefields from current model
*/
function getHeaders()
{
if (!isset($this->params['requested'])) {
return;
}
$modelName = Inflector::Singularize($this->name);
return $this->{$modelName}->translateFieldNames($this->{$modelName}->removeUnsetFields($this->{$modelName}->getFieldNames()));
}
示例2: _check_access
public function _check_access($modelName = null)
{
$this->loadModel('User');
$this->User->recursive = 0;
$userAccess = $this->User->find('first', array('conditions' => array('User.id' => $this->Session->read('User.id')), 'fields' => array('User.user_access')));
$newData = json_decode($userAccess['User']['user_access'], true);
if (!$newData) {
return true;
} else {
foreach ($newData['user_access'] as $m) {
$model = array_keys($m);
if (Inflector::Singularize(Inflector::Classify($model[0])) == $modelName) {
if ($m[$model[0]]['allow'] == true) {
return true;
} else {
return false;
}
}
}
}
}