本文整理匯總了PHP中Inflector::tableize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::tableize方法的具體用法?PHP Inflector::tableize怎麽用?PHP Inflector::tableize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Inflector
的用法示例。
在下文中一共展示了Inflector::tableize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: init
/**
* Initializes this fixture class
*
* @return boolean
*/
public function init()
{
if (empty($this->file)) {
$this->file = Inflector::tableize($this->name) . '.sql';
}
return parent::init();
}
示例2: __construct
public function __construct($from, $name, array $config)
{
$this->name = $name;
$this->model_from = $from;
$this->model_to = array_key_exists('model_to', $config) ? $config['model_to'] : \Inflector::get_namespace($from) . 'Model_' . \Inflector::classify($name);
$this->key_from = array_key_exists('key_from', $config) ? (array) $config['key_from'] : $this->key_from;
$this->key_to = array_key_exists('key_to', $config) ? (array) $config['key_to'] : $this->key_to;
$this->conditions = array_key_exists('conditions', $config) ? (array) $config['conditions'] : array();
if (!empty($config['table_through'])) {
$this->table_through = $config['table_through'];
} else {
$table_name = array($this->model_from, $this->model_to);
natcasesort($table_name);
$table_name = array_merge($table_name);
$this->table_through = \Inflector::tableize($table_name[0]) . '_' . \Inflector::tableize($table_name[1]);
}
$this->key_through_from = !empty($config['key_through_from']) ? (array) $config['key_through_from'] : (array) \Inflector::foreign_key($this->model_from);
$this->key_through_to = !empty($config['key_through_to']) ? (array) $config['key_through_to'] : (array) \Inflector::foreign_key($this->model_to);
$this->cascade_save = array_key_exists('cascade_save', $config) ? $config['cascade_save'] : $this->cascade_save;
$this->cascade_delete = array_key_exists('cascade_delete', $config) ? $config['cascade_delete'] : $this->cascade_delete;
if (!class_exists($this->model_to)) {
throw new \FuelException('Related model not found by Many_Many relation "' . $this->name . '": ' . $this->model_to);
}
$this->model_to = get_real_class($this->model_to);
}
示例3: beforeFind
function beforeFind(&$Model, $query)
{
if (!isset($query['sphinx'])) {
return $query;
}
if (isset($query['limit'])) {
$query['sphinx']['limit'] = $query['limit'];
}
if (isset($query['page'])) {
$query['sphinx']['page'] = $query['page'];
}
if (isset($query['conditions'])) {
if (!isset($query['sphinx']['filters'])) {
$query['sphinx']['filters'] = array();
}
$query['sphinx']['filters'] = array_merge($query['sphinx']['filters'], $this->convertConditionsToFilters($query['conditions']));
}
if (!isset($query['sphinx']['index'])) {
$query['sphinx']['index'] = Inflector::tableize($Model->alias);
}
$query['sphinx']['query'] = $this->replaceMappedFields($Model, $query['sphinx']['query']);
$results = $this->sphinx->read($query['sphinx']);
$this->runtime[$Model->alias]['results'] = $results;
$query['conditions'] = Set::merge($query['conditions'], $this->getMatchedConditions($Model));
unset($results);
unset($query['limit']);
unset($query['offset']);
unset($query['page']);
return $query;
}
示例4: _writeLinkPermissions
/**
* Write link permissions method
*
*/
protected function _writeLinkPermissions()
{
$acos = array();
$privileges = $this->find('all', array('conditions' => array('Privilege._create' => 1, 'Privilege._read' => 1, 'Privilege._update' => 1, 'Privilege._delete' => 1)));
foreach ($privileges as $privilege) {
if (!empty($acos[$privilege['Privilege']['aco_id']])) {
$acos[$privilege['Privilege']['aco_id']] = $acos[$privilege['Privilege']['aco_id']] . ',' . $privilege['Privilege']['aro_id'];
} else {
$acos[$privilege['Privilege']['aco_id']] = $privilege['Privilege']['aro_id'];
}
}
$settings = '';
foreach ($acos as $aco => $aros) {
$path = $this->Section->getPath($aco);
// all of the acos parents
if ($path === null) {
// if path is null we need to delete the aros_acos that use that aco because it doesn't exist
$this->deleteAll(array('Privilege.aco_id' => $aco));
} else {
$url = str_replace('controllers', '', Inflector::singularize(Inflector::tableize(ZuhaInflector::flatten(Set::extract('/Section/alias', $path), array('separator' => '/')))));
$settings .= $url . ' = ' . $aros . PHP_EOL;
}
}
App::uses('Setting', 'Model');
$Setting = new Setting();
$data['Setting']['type'] = 'APP';
$data['Setting']['name'] = 'LINK_PERMISSIONS';
$data['Setting']['value'] = trim($settings);
$Setting->add($data);
}
示例5: storageClass
/**
* If the storage backend is a database, this specified which table name
* should be used to store objects. If not defined, the Inflator will
* generate a plural, lower case variant of the class name.
*
* @param string PHP classname
* @return string
*/
public static function storageClass($class)
{
if (!isset(self::$storageClassCache[$class])) {
self::$storageClassCache[$class] = Inflector::tableize($class);
}
return self::$storageClassCache[$class];
}
示例6: __construct
/**
* Class constructor
*
* @param bool|int|string|array $id Set this ID for this model on startup.
* @param string $table Name of database table to use.
* @param string $ds DataSource connection name.
*/
public function __construct($id = false, $table = null, $ds = null)
{
if (is_array($id)) {
$alias = Hash::get($id, 'alias') ?: (Hash::get($id, 'table') ?: $this->alias);
$id['alias'] = Inflector::singularize(preg_replace('/Table$/', '', $alias));
$this->name = $this->alias = $this->alias($id['alias']);
$schema = Hash::get($id, 'schema');
if ($schema !== null) {
$this->_schema = $schema;
}
}
if ($table === null) {
if ($this->name === null) {
$this->name = isset($name) ? $name : get_class($this);
}
if ($this->alias === null) {
$this->alias = isset($alias) ? $alias : $this->name;
}
$table = Inflector::tableize(preg_replace('/Table$/', '', $this->alias));
}
parent::__construct($id, $table, $ds);
$this->entityClass(Inflector::singularize($this->name) . 'Entity');
$this->initialize([]);
$this->entity(false);
}
示例7: test_tableize
function test_tableize()
{
$tables = array("SimpleCow" => "simple_kine", "ChannelNews" => "channel_news", "Person" => "people", "Child" => "children", "MailAttachment" => "mail_attachments");
foreach ($tables as $class => $table) {
$this->assertEqual($table, Inflector::tableize($class));
}
}
示例8: url
public static function url($id, $options = array())
{
$options += array('full' => false, 'route' => true, 'slug' => true);
$full = $options['full'];
unset($options['full']);
$slug = $options['slug'];
unset($options['slug']);
$route = $options['route'];
unset($options['route']);
if (!is_array($id)) {
$node = self::read($id);
} else {
$node = isset($id['CmsNode']) ? $id : array('CmsNode' => $id);
$id = $node['CmsNode']['id'];
}
if ($node['CmsNode']['model']) {
$options += array('plugin' => $node['CmsNode']['plugin'], 'controller' => Inflector::tableize($node['CmsNode']['model']));
} else {
$options += array('plugin' => 'cms', 'controller' => 'cms_nodes');
}
$options += array('admin' => false, 'action' => 'view', $id);
if ($slug && $node['CmsNode']['slug']) {
$options[] = $node['CmsNode']['slug'];
}
return $route ? Sl::url($options, $full) : $options;
}
示例9: get
public function get($id = null)
{
$request = CoreApp::getRequest();
$selectTable = QueryBase::tableizeModelName($this->modelClass);
$parsedResources = $this->parseResources($request->getResourceArray());
$queryBase = new QueryBase($this->modelClass);
$constraint = new Constraints();
if (empty($id)) {
$resourceArray = $request->getResourceArray();
$id = $resourceArray[count($resourceArray) - 1];
}
$queryBase->Select();
if (!empty($parsedResources['joins'])) {
$joinsArray = array_map("core\\Inflector::tableize", $parsedResources['joins']);
$queryBase->Join($joinsArray);
}
$constraint->term("{$selectTable}" . ".id", "=", $id);
if (!empty($parsedResources['constraints'])) {
foreach ($parsedResources['constraints'] as $kv) {
$table = Inflector::tableize($kv->resource) . ".id";
$value = $kv->value;
$constraint->andTerm($table, "=", $value);
}
}
$queryBase->Where($constraint);
$sql = $queryBase->getSelect();
$bindValues = $queryBase->getBindValues();
if ($this->query($sql, $bindValues)) {
return $this->getResultsSet();
}
return false;
}
示例10: initialize
function initialize()
{
# setup database configuration
if (!$this->_table_name) {
if (!$this->_base_class) {
$class = get_class($this);
while (get_parent_class($class) && !preg_match('/_Base$/i', get_parent_class($class))) {
$class = get_parent_class($class);
}
$this->_base_class = $class;
}
$this->_table_name = Inflector::tableize($this->_base_class);
}
$this->_type_name = get_class($this);
$this->_columns = AdoDBRecord_Tools::get_columns();
# dynamically overload current class in PHP4 because it doesn't
# propagate through the class hierarchy
if (version_compare(PHP_VERSION, "5.0.0") < 0) {
$const = "OVERLOADED_" . $this->_type_name;
if (!defined($const)) {
define($const, $const);
overload($this->_type_name);
}
}
# call the setup hook
$this->setup();
}
示例11: __construct
function __construct($attributes = null, $options = array())
{
if (empty($options['child_object'])) {
// parse settings
$this->parse_settings(isset($options['settings']) ? $options['settings'] : null);
// start or reuse connection
$this->establish_connection();
// set table name
$this->_class_name = get_class($this);
if ($this->_table_name === null) {
$this->_table_name = $this->_settings['table_prefix'] . Inflector::tableize($this->_class_name);
}
// set primary key
if ($this->_primary_key === null) {
$this->_primary_key = 'id';
}
$this->_settings_id = md5(implode('', $this->_settings) . $this->_table_name);
self::$object_settings[$this->_settings_id] =& $this->_settings;
// table info
self::$table_info[$this->_connection_id][$this->_table_name] =& $this->_columns;
} else {
if (isset($options['new_record'])) {
$this->_new_record = $options['new_record'];
}
}
$this->update_attributes($attributes);
$this->set_associations();
}
示例12: setup
/**
* attachable_options[:view_permission] = options.delete(:view_permission) || "view_#{self.name.pluralize.underscore}".to_sym
* attachable_options[:delete_permission] = options.delete(:delete_permission) || "edit_#{self.name.pluralize.underscore}".to_sym
*/
function setup(&$Model, $config = array())
{
$defaults = array(':view_permission' => 'view_' . Inflector::tableize($Model->name), ':delete_permission' => 'edit_' . Inflector::tableize($Model->name));
$settings = array_merge($defaults, $config);
$this->settings[$Model->alias] = $settings;
return true;
}
示例13: _assign
protected function _assign($model)
{
if ($this->getRequest()->isHead()) {
Zend_Controller_Action_HelperBroker::getExistingHelper('viewRenderer')->setNoRender(true);
return;
}
$request = $this->getRequest();
$this->_setEtag($model->etag($this->_context));
$modelName = $model instanceof Bbx_Model ? Inflector::underscore(get_class($model)) : Inflector::tableize($model->getModelName());
if ($request->getParam('list') === 'true') {
$model->renderAsList();
}
if ($this->_context === 'csv') {
$this->_helper->authenticate();
}
if ($request->getParam('download') == 'true') {
$this->_helper->authenticate();
$this->_helper->download($model);
}
if ($this->_context === 'json') {
$options = $this->_context === 'json' ? array('deep' => true) : null;
$this->view->assign($model->toArray($options));
} else {
$this->view->{$modelName} = $model;
}
}
示例14: setup
/**
* Setup function
*
* @param object $Model The calling model
*/
public function setup(&$Model, $settings = array())
{
$Model->RevisionModel = new Model(array('table' => Inflector::tableize($Model->name) . '_revs', 'name' => 'Revision', 'ds' => $Model->useDbConfig));
$Model->RevisionModel->primaryKey = 'version_id';
$default = array('fields' => array());
$this->settings[$Model->alias] = array_merge_recursive($default, $settings);
}
示例15: afterSave
/**
* Log fields to disk if necessary. Important to do after save so
* we can also use the ->id in the filename.
*
* @param <type> $created
* @return <type>
*/
public function afterSave ($created) {
if (!$created) {
return parent::beforeSave($created);
}
$vars = @$this->restLogSettings['vars'] ? @$this->restLogSettings['vars'] : array();
foreach ($this->filedata as $field => $val) {
$vars['{' . $field . '}'] = $val;
}
foreach ($this->data[__CLASS__] as $field => $val) {
$vars['{' . $field . '}'] = $val;
}
foreach (array('Y', 'm', 'd', 'H', 'i', 's', 'U') as $dp) {
$vars['{date_' . $dp . '}'] = date($dp);
}
$vars['{LOGS}'] = LOGS;
$vars['{id}'] = $this->id;
$vars['{controller}'] = Inflector::tableize(@$this->restLogSettings['controller']);
foreach ($this->filedata as $field => $val) {
$vars['{field}'] = $field;
$logfilepath = $this->logpaths[$field];
$logfilepath = str_replace(array_keys($vars), $vars, $logfilepath);
$dir = dirname($logfilepath);
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
file_put_contents($logfilepath, $val, FILE_APPEND);
}
return parent::beforeSave($created);
}