本文整理汇总了PHP中Jam::capitalize_class_name方法的典型用法代码示例。如果您正苦于以下问题:PHP Jam::capitalize_class_name方法的具体用法?PHP Jam::capitalize_class_name怎么用?PHP Jam::capitalize_class_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jam
的用法示例。
在下文中一共展示了Jam::capitalize_class_name方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($config = array())
{
parent::__construct($config);
foreach ($config['services'] as $service => $config) {
$class = 'Auth_Service_' . Jam::capitalize_class_name($service);
$this->_services[$service] = new $class($config);
}
}
示例2: _execute
protected function _execute(array $options)
{
$module_name = $options['module'];
$module_dir = Arr::get(Kohana::modules(), $module_name);
$author = $options['author'];
switch ($options['type']) {
case 'number':
$parent = 'Stats_Widget_Number';
break;
case 'chart':
$parent = 'Stats_Widget_Chart';
break;
default:
$parent = 'Stats_Widget';
}
$name = $options['name'];
$title = Jam::capitalize_class_name(str_replace('_', ' ', $name));
$path = str_replace('_', DIRECTORY_SEPARATOR, $title);
$dir = $module_dir . 'classes' . DIRECTORY_SEPARATOR . 'Stats' . DIRECTORY_SEPARATOR . 'Widget';
$file = $dir . DIRECTORY_SEPARATOR . $path . EXT;
$class = 'Stats_Widget_' . str_replace(' ', '_', $title);
if (!is_dir(dirname($file))) {
mkdir(dirname($file), 0777, TRUE);
}
$widget_content = <<<WIDGET
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* Stats Widget: {$title}
*
* @package {$module_name}
* @author {$author}
* @copyright (c) 2011-2013 Despark Ltd.
*/
class {$class} extends {$parent} {
\tprotected \$_title = '{$title}';
\tpublic function retrieve(\$start_date, \$end_date)
\t{
\t\t// return 0;
\t}
}
WIDGET;
Minion_Jam_Generate::modify_file($file, $widget_content, $options['force'] !== FALSE);
}
示例3: _execute
protected function _execute(array $options)
{
$module_name = $options['module'];
$dir = Arr::get(Kohana::modules(), $module_name);
$meta = Jam::meta($options['model']);
$controller = $options['controller'] ?: Inflector::plural($meta->model());
$item_name = $meta->model();
$item_title = ucwords(Inflector::humanize($meta->model()));
$plural_name = str_replace('_', ' ', $controller);
$author = $options['author'];
$controller_option = $options['controller'] ? '->controller(\'' . $controller . '\')' : NULL;
$controller_title = Jam::capitalize_class_name($plural_name);
$controller_path = str_replace('_', DIRECTORY_SEPARATOR, $controller_title);
$controller_dir = $dir . 'classes' . DIRECTORY_SEPARATOR . 'Controller' . DIRECTORY_SEPARATOR . 'Tart';
$controller_file = $controller_dir . DIRECTORY_SEPARATOR . $controller_path . EXT;
$controller_class = 'Controller_Tart_' . str_replace(' ', '_', $controller_title);
$views_path = 'tart' . DIRECTORY_SEPARATOR . strtolower($controller_path);
$views_dir = $dir . 'views' . DIRECTORY_SEPARATOR . $views_path . DIRECTORY_SEPARATOR;
$extra_controller = $options['controller'] ? ", array('controller' => '{$controller}')" : '';
$extra_controller_delete = $options['controller'] ? "array('controller' => '{$controller}', 'action' => 'delete')" : "'delete'";
$batch_index = NULL;
$batch_delete = NULL;
$batch_modify = NULL;
if (!is_dir($views_dir)) {
mkdir($views_dir, 0777, TRUE);
}
if (!is_dir(dirname($controller_file))) {
mkdir(dirname($controller_file), 0777, TRUE);
}
if ($options['batch_delete'] !== FALSE or $options['batch_modify'] !== FALSE) {
$actions = '';
if ($options['batch_delete'] !== FALSE) {
$actions .= "\n\t\t\t\t'delete' => 'Delete',";
$batch_delete = <<<BATCH_DELETE
\tpublic function batch_delete(\$ids)
\t{
\t\tif (\$this->request->method() == Request::POST)
\t\t{
\t\t\t\$result = array();
\t\t\tforeach (Jam::all('{$meta->model()}')->where_key(\$ids) as \${$item_name})
\t\t\t{
\t\t\t\t\$result[] = \${$item_name}->delete();
\t\t\t}
\t\t\t\$this->notify('success', count(\$result).' {$plural_name} deleted');
\t\t\t\$this->redirect(Tart::uri('{$controller}'));
\t\t}
\t\telse
\t\t{
\t\t\t\$table = Tart::table(Jam::all('{$meta->model()}')->where_key(\$ids))
\t\t\t\t->selected(\$ids)
\t\t\t\t->columns('{$meta->name_key()}', Tart::column());
\t\t\t\$this->template->content = View::factory('{$views_path}/batch_delete', array('table' => \$table));
\t\t}
\t}
BATCH_DELETE;
}
if ($options['batch_modify'] !== FALSE) {
$actions .= "\n\t\t\t\t'modify' => 'Modify',";
$batch_modify = <<<BATCH_MODIFY
\tpublic function batch_modify(\$ids)
\t{
\t\t\$params = array('{$meta->name_key()}');
\t\tif (\$this->request->method() == Request::POST)
\t\t{
\t\t\t\$modified = Tart_Request::modified_params(\$this->request->post(), \$params);
\t\t\tforeach (Jam::all('{$meta->model()}')->where_key(\$ids) as \$item)
\t\t\t{
\t\t\t\t\$item->set(\$modified)->save();
\t\t\t}
\t\t\t\$this->notify('success', count(\$ids).' {$plural_name} modified: '.Tart_Request::to_modifications(\$modified));
\t\t\t\$this->redirect(Tart::uri('{$controller}'));
\t\t}
\t\telse
\t\t{
\t\t\t\$table = Tart::table(Jam::all('{$meta->model()}')->where_key(\$ids))
\t\t\t\t->selected(\$ids)
\t\t\t\t->columns('{$meta->name_key()}', Tart::column());
\t\t\t\$item = Jam::build('{$meta->model()}', Jam_Form::common_params(\$table->collection(), \$params));
\t\t\t\$this->template->content = View::factory('{$views_path}/batch_modify', array('table' => \$table, 'form' => Jam::form(\$item, 'tart_general')->validation(FALSE)));
\t\t}
\t}
BATCH_MODIFY;
}
$batch_index = <<<BATCH_INDEX
\t\t\t->batch_actions(array({$actions}
\t\t\t))
BATCH_INDEX;
}
$controller_content = <<<CONTROLLER
<?php defined('SYSPATH') OR die('No direct script access.');
/**
//.........这里部分代码省略.........
示例4: finalize
/**
* This is called after initialization to
* finalize any changes to the meta object.
*
* @param string $model
* @return
*/
public function finalize($model)
{
if ($this->_initialized) {
return;
}
// Set the name of a possible behavior class
$behavior_class = Jam::behavior_prefix() . Jam::capitalize_class_name($model);
// See if we have a special behavior class to use
if (class_exists($behavior_class)) {
// Load behavior
$behavior = new $behavior_class();
if (!in_array($behavior, $this->_behaviors)) {
// Add to behaviors
$this->_behaviors[] = $behavior;
}
}
foreach ($this->_behaviors as $name => $behavior) {
if (!$behavior instanceof Jam_Behavior) {
throw new Kohana_Exception('Behavior at index [ :key ] is not an instance of Jam_Behavior, :type found.', array(':type' => is_object($behavior) ? 'instance of ' . get_class($behavior) : gettype($behavior), ':key' => $name));
}
// Initialize behavior
$behavior->initialize($this, $name);
}
// Allow modification of this meta object by the behaviors
$this->_events->trigger('meta.before_finalize', $this);
// Ensure certain fields are not overridden
$this->_model = $model;
$this->_defaults = array();
if (!$this->_errors_filename) {
// Default errors filename to the model's name
$this->_errors_filename = 'validators/' . $this->_model;
}
// Table should be a sensible default
if (empty($this->_table)) {
$this->_table = Inflector::plural($model);
}
// Can we set a sensible foreign key?
if (empty($this->_foreign_key)) {
$this->_foreign_key = $model . '_id';
}
if (empty($this->_unique_key) and method_exists(Jam::class_name($this->_model), 'unique_key')) {
$this->_unique_key = Jam::class_name($this->_model) . '::unique_key';
}
foreach ($this->_fields as $column => $field) {
// Ensure a default primary key is set
if ($field instanceof Jam_Field and $field->primary and empty($this->_primary_key)) {
$this->_primary_key = $column;
}
// Ensure a default plymorphic key is set
if ($field instanceof Jam_Field_Polymorphic and empty($this->_polymorphic_key)) {
$this->_polymorphic_key = $column;
}
}
foreach ($this->_associations as $column => &$association) {
$association->initialize($this, $column);
}
foreach ($this->_fields as $column => &$field) {
$field->initialize($this, $column);
$this->_defaults[$column] = $field->default;
}
if (!$this->_collection and $class = Jam::collection_prefix() . Jam::capitalize_class_name($this->_model) and class_exists($class)) {
$this->_collection = $class;
}
// Meta object is initialized and no longer writable
$this->_initialized = TRUE;
// Final meta callback
$this->_events->trigger('meta.after_finalize', $this);
}
示例5: _execute
protected function _execute(array $options)
{
$module_name = $options['module'] ?: 'applicaiton';
$module_dir = $options['module'] ? Arr::get(Kohana::modules(), $module_name) : APPPATH;
$author = $options['author'] ?: '-';
$name = $options['name'];
$title = Jam::capitalize_class_name(str_replace('_', ' ', $name));
$path = str_replace('_', DIRECTORY_SEPARATOR, $title);
$dir = $module_dir . 'classes' . DIRECTORY_SEPARATOR . 'Model';
$file = $dir . DIRECTORY_SEPARATOR . $path . EXT;
$class = 'Model_' . str_replace(' ', '_', $title);
if (!is_dir(dirname($file))) {
mkdir(dirname($file), 0777, TRUE);
}
$content = <<<MODEL
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* Jam Model: {$title}
*
* @package {$module_name}
* @author {$author}
* @copyright (c) 2011-2013 Despark Ltd.
*/
class {$class} extends Jam_Model {
\tpublic static function initialize(Jam_Meta \$meta)
\t{
\t\t\$meta
\t\t\t->associations(array(
\t\t\t))
\t\t\t->fields(array(
\t\t\t\t'id' => Jam::field('primary'),
\t\t\t\t'name' => Jam::field('string'),
\t\t\t))
\t\t\t->validator('name', array('present' => TRUE));
\t}
}
MODEL;
Minion_Jam_Generate::modify_file($file, $content, $options['force'] !== FALSE, $options['unlink'] !== FALSE);
if ($options['collection'] !== FALSE) {
$dir = $module_dir . 'classes' . DIRECTORY_SEPARATOR . 'model' . DIRECTORY_SEPARATOR . 'collection';
$file = $dir . DIRECTORY_SEPARATOR . $path . EXT;
$class = 'Model_Collection_' . str_replace(' ', '_', $title);
if (!is_dir(dirname($file))) {
mkdir(dirname($file), 0777, TRUE);
}
$content = <<<COLLECTION
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* Collection for {$title}
*
* @package {$module_name}
* @author {$author}
* @copyright (c) 2011-2013 Despark Ltd.
*/
class {$class} extends Jam_Query_Builder_Collection {
}
COLLECTION;
Minion_Jam_Generate::modify_file($file, $content, $options['force'] !== FALSE, $options['unlink'] !== FALSE);
}
}
示例6: form
public static function form($model, $class = NULL)
{
if ($class === NULL) {
$class = Kohana::$config->load('jam.default_form');
}
$class = Jam::capitalize_class_name($class);
if (is_string($model)) {
$model = Jam::build($model);
}
if (class_exists(Jam::$_form_prefix . $class)) {
$class = Jam::$_form_prefix . $class;
}
return new $class($model);
}