本文整理汇总了PHP中AkInflector::toModelFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP AkInflector::toModelFilename方法的具体用法?PHP AkInflector::toModelFilename怎么用?PHP AkInflector::toModelFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AkInflector
的用法示例。
在下文中一共展示了AkInflector::toModelFilename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
function generate()
{
$this->_preloadPaths();
$this->class_name = AkInflector::camelize($this->class_name);
$files = array(
'model'=>AkInflector::toModelFilename($this->class_name),
'unit_test'=>AK_TEST_DIR.DS.'unit'.DS.'app'.DS.'models'.DS.$this->underscored_model_name.'.php',
'model_fixture.tpl'=>AK_TEST_DIR.DS.'fixtures'.DS.$this->model_path,
'installer_fixture.tpl'=>AK_TEST_DIR.DS.'fixtures'.DS.$this->installer_path
);
$this->_template_vars = (array)$this;
foreach ($files as $template=>$file_path){
$this->save($file_path, $this->render($template));
}
$installer_path = AK_APP_DIR.DS.'installers'.DS.$this->underscored_model_name.'_installer.php';
if(!file_exists($installer_path)){
$this->save($installer_path, $this->render('installer'));
}
$unit_test_runner = AK_TEST_DIR.DS.'unit.php';
if(!file_exists($unit_test_runner)){
Ak::file_put_contents($unit_test_runner, file_get_contents(AK_FRAMEWORK_DIR.DS.'test'.DS.'app.php'));
}
}
示例2: cast
function cast()
{
$this->model_name = AkInflector::camelize($this->model_name);
$this->model_file_path = AkInflector::toModelFilename($this->model_name);
$this->controller_name = empty($this->controller_name) ? $this->model_name : (AkInflector::camelize($this->controller_name));
$this->controller_file_path = AkInflector::toControllerFilename($this->controller_name);
$this->controller_class_name = $this->controller_name.'Controller';
$this->controller_human_name = AkInflector::humanize($this->controller_name);
$this->helper_var_name = '$'.AkInflector::underscore($this->controller_name).'_helper';
$this->singular_name = AkInflector::underscore($this->model_name);
$this->plural_name = AkInflector::pluralize($this->singular_name);
$this->singular_controller_name = AkInflector::underscore($this->controller_name);
$this->files = array(
'controller.php' => $this->controller_file_path,
/**
* @todo Implement generic functional tests
*/
// 'functional_test.php' => AK_TEST_DIR.DS.'functional'.DS.'test_'.$this->controller_class_name.'.php',
'helper.php' => AK_HELPERS_DIR.DS.trim($this->helper_var_name,'$').'.php',
'layout' => AK_VIEWS_DIR.DS.'layouts'.DS.$this->singular_controller_name.'.tpl',
'view_add' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'add.tpl',
'view_destroy' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'destroy.tpl',
'view_edit' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'edit.tpl',
'view_listing' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'listing.tpl',
'view_show' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'show.tpl',
'form' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'_form.tpl',
);
$this->user_actions = array();
foreach ((array)@$this->actions as $action){
$this->user_actions[$action] = AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.$action.'.tpl';
}
}
示例3: generate
function generate()
{
$this->_preloadPaths();
$this->class_name = AkInflector::camelize($this->class_name);
$files = array(
'mailer'=>AkInflector::toModelFilename($this->class_name),
'unit_test'=>AK_TEST_DIR.DS.'unit'.DS.'app'.DS.'models'.DS.$this->underscored_class_name.'.php'
);
foreach ($files as $template=>$file_path){
$this->save($file_path, $this->render($template));
}
$mailer_views_folder = AK_VIEWS_DIR.DS.AkInflector::underscore($this->class_name);
@Ak::make_dir($mailer_views_folder);
foreach ($this->actions as $action){
$this->assignVarToTemplate('action', $action);
$path = $mailer_views_folder.DS.$action.'.tpl';
$this->assignVarToTemplate('path', $path);
$this->save($path, $this->render('view'));
}
}
示例4: _createNewTestingModel
function _createNewTestingModel($test_model_name)
{
static $shutdown_called;
switch ($test_model_name) {
case 'AkTestNestedCategory':
$model_source = '<?php
class AkTestNestedCategory extends AkActiveRecord
{
var $act_as = "nested_set";
}
?>';
break;
default:
$model_source = '<?php class ' . $test_model_name . ' extends AkActiveRecord { } ?>';
break;
}
$file_name = AkInflector::toModelFilename($test_model_name);
if (!Ak::file_put_contents($file_name, $model_source)) {
die('Ooops!, in order to perform this test, you must set your app/model permissions so this can script can create and delete files into/from it');
}
if (!in_array($file_name, get_included_files()) && !class_exists($test_model_name)) {
include $file_name;
} else {
return false;
}
$this->_testing_models_to_delete[] = $file_name;
if (!isset($shutdown_called)) {
$shutdown_called = true;
register_shutdown_function(array(&$this, '_deleteTestingModels'));
}
return true;
}
示例5: cast
function cast()
{
$this->model_name = AkInflector::camelize($this->model_name);
$this->model_file_path = AkInflector::toModelFilename($this->model_name);
if (empty($this->actions) && !empty($this->controller_name) && strstr($this->controller_name, ',')) {
$this->controller_name = '';
}
$this->controller_name = empty($this->controller_name) ? AkInflector::pluralize($this->model_name) : AkInflector::camelize($this->controller_name);
$this->controller_file_path = AkInflector::toControllerFilename($this->controller_name);
$this->controller_class_name = str_replace(array('/', '::'), '_', $this->controller_name . 'Controller');
$this->controller_name = AkInflector::demodulize($this->controller_name);
$this->controller_human_name = AkInflector::humanize($this->controller_name);
$this->helper_name = (AkInflector::is_plural($this->controller_name) ? AkInflector::singularize($this->controller_name) : $this->controller_name) . 'Helper';
$this->helper_var_name = '$' . AkInflector::underscore($this->helper_name);
$this->singular_name = AkInflector::underscore($this->model_name);
$this->plural_name = AkInflector::pluralize($this->singular_name);
$this->singular_controller_name = AkInflector::underscore($this->controller_name);
$this->module_preffix = AkInflector::underscore(substr($this->controller_class_name, 0, strrpos($this->controller_class_name, '_')));
$this->module_preffix = empty($this->module_preffix) ? '' : DS . $this->module_preffix;
$this->files = array('controller.php' => $this->controller_file_path, 'helper.php' => AK_HELPERS_DIR . $this->module_preffix . DS . trim($this->helper_var_name, '$') . '.php', 'layout' => AK_VIEWS_DIR . DS . 'layouts' . DS . $this->singular_controller_name . '.tpl', 'view_add' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'add.tpl', 'view_destroy' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'destroy.tpl', 'view_edit' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'edit.tpl', 'view_listing' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'listing.tpl', 'view_show' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'show.tpl', 'form' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . '_form.tpl');
$this->user_actions = array();
foreach ((array) @$this->actions as $action) {
$this->user_actions[$action] = AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . $action . '.tpl';
}
}
示例6: generate
function generate()
{
$this->_preloadPaths();
$this->class_name = AkInflector::camelize($this->class_name);
$files = array('model' => AkInflector::toModelFilename($this->class_name), 'unit_test' => AK_TEST_DIR . DS . 'unit' . DS . 'app' . DS . 'models' . DS . $this->underscored_model_name . '.php', 'model_fixture.tpl' => AK_TEST_DIR . DS . 'fixtures' . DS . $this->model_path, 'installer_fixture.tpl' => AK_TEST_DIR . DS . 'fixtures' . DS . $this->installer_path);
foreach ($files as $template => $file_path) {
$this->save($file_path, $this->render($template));
}
}
示例7: generate
public function generate()
{
$this->_preloadPaths();
$this->class_name = AkInflector::camelize($this->class_name);
$files = array('model' => AkInflector::toModelFilename($this->class_name), 'unit_test' => AkConfig::getDir('test') . DS . 'unit' . DS . $this->test_file_name);
if (!$this->active_document) {
$files['installer'] = AkConfig::getDir('app_installers') . DS . $this->underscored_model_name . '_installer.php';
}
foreach ($files as $template => $file_path) {
$this->save($file_path, $this->render($template));
}
}
示例8: _createNewTestingModel
function _createNewTestingModel($test_model_name)
{
static $shutdown_called;
switch ($test_model_name) {
case 'AkTestPerson':
$model_source =
'<?php
class AkTestPerson extends AkActiveRecord
{
function validate()
{
$this->validatesPresenceOf("first_name");
}
function validateOnCreate()
{
$this->validatesAcceptanceOf("tos");
}
function validateOnUpdate()
{
$this->validatesPresenceOf("email");
}
}
?>';
break;
default:
$model_source = '<?php class '.$test_model_name.' extends AkActiveRecord { } ?>';
break;
}
$file_name = AkInflector::toModelFilename($test_model_name);
if(!Ak::file_put_contents($file_name,$model_source)){
die('Ooops!, in order to perform this test, you must set your app/model permissions so this can script can create and delete files into/from it');
}
if(!in_array($file_name, get_included_files()) && !class_exists($test_model_name)){
include($file_name);
}else {
return false;
}
$this->_testing_models_to_delete[] = $file_name;
if(!isset($shutdown_called)){
$shutdown_called = true;
register_shutdown_function(array(&$this,'_deleteTestingModels'));
}
return true;
}
示例9: _setupCloner
function _setupCloner()
{
$this->clone_setup_done = true;
$this->class_to_clone = AkInflector::underscore($this->class_to_clone);
$this->class_name = AkInflector::underscore($this->class_name);
$this->clone_replacements = array(AkInflector::camelize($this->class_to_clone) . 'Controller' => AkInflector::camelize($this->class_name) . 'Controller', AkInflector::humanize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::humanize(AkInflector::pluralize($this->class_name)), AkInflector::titleize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::titleize(AkInflector::pluralize($this->class_name)), AkInflector::humanize($this->class_to_clone) => AkInflector::humanize($this->class_name), AkInflector::titleize($this->class_to_clone) => AkInflector::titleize($this->class_name), AkInflector::camelize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::camelize(AkInflector::pluralize($this->class_name)), AkInflector::pluralize($this->class_to_clone) => AkInflector::pluralize($this->class_name), AkInflector::camelize($this->class_to_clone) => AkInflector::camelize($this->class_name), $this->class_to_clone => $this->class_name);
//AK_VIEWS_DIR.DS.AkInflector::underscore($this->class_name).DS.$action.'.tpl'
$this->files_to_clone = array(AkInflector::toModelFilename($this->class_to_clone) => AkInflector::toModelFilename($this->class_name), AK_TEST_DIR . DS . 'unit' . DS . 'test_' . $this->class_to_clone . '.php' => AK_TEST_DIR . DS . 'unit' . DS . 'test_' . $this->class_name . '.php', AK_TEST_DIR . DS . 'fixtures' . DS . AkInflector::tableize($this->class_to_clone) . '.yml' => AK_TEST_DIR . DS . 'fixtures' . DS . AkInflector::tableize($this->class_name) . '.yml', AkInflector::toControllerFilename($this->class_to_clone) => AkInflector::toControllerFilename($this->class_name), AK_TEST_DIR . DS . 'functional' . DS . 'test_' . AkInflector::camelize($this->class_to_clone . '_controller') . '.php' => AK_TEST_DIR . DS . 'functional' . DS . 'test_' . AkInflector::camelize($this->class_name . '_controller') . '.php', AK_HELPERS_DIR . DS . AkInflector::underscore("{$this->class_to_clone}_helper") . '.php' => AK_HELPERS_DIR . DS . AkInflector::underscore("{$this->class_name}_helper") . '.php');
foreach ($this->_getControllerViews() as $view_file) {
$this->files_to_clone[AK_VIEWS_DIR . DS . $this->class_to_clone . DS . $view_file . '.tpl'] = AK_VIEWS_DIR . DS . $this->class_name . DS . $view_file . '.tpl';
}
$this->files_to_clone[AK_VIEWS_DIR . DS . 'layouts' . DS . $this->class_to_clone . '.tpl'] = AK_VIEWS_DIR . DS . 'layouts' . DS . $this->class_name . '.tpl';
foreach (Ak::dir(AK_APP_DIR . DS . 'locales' . DS . $this->class_to_clone, array('dirs' => false)) as $locale_file) {
$this->files_to_clone[AK_APP_DIR . DS . 'locales' . DS . $this->class_to_clone . DS . $locale_file] = AK_APP_DIR . DS . 'locales' . DS . $this->class_name . DS . $locale_file;
}
}
示例10: setObservedModels
/**
* Constructs the Observer
* @param $subject the name or names of the Models to observe
*/
function setObservedModels()
{
$args = func_get_args();
$models = func_num_args() == 1 ? is_array($args[0]) ? $args[0] : array($args[0]) : $args;
foreach ($models as $class_name) {
/**
* @todo use Ak::import() instead.
*/
$class_name = AkInflector::camelize($class_name);
if (!class_exists($class_name)) {
require_once AkInflector::toModelFilename($class_name);
}
$model =& new $class_name();
$this->observe(&$model);
}
}
示例11: import
/**
* Gets an array or a comma separated list of models. Then it includes its
* respective files and returns an array of available models.
*
* @return array available models
*/
function import()
{
$args = func_get_args();
$args = is_array($args[0]) ? $args[0] : (func_num_args() > 1 ? $args : Ak::stringToArray($args[0]));
$models = array();
foreach ($args as $arg) {
$model_name = AkInflector::camelize($arg);
if (class_exists($model_name)) {
$models[] = $model_name;
continue;
}
$model = AkInflector::toModelFilename($model_name);
if (file_exists($model)) {
$models[] = $model_name;
include_once $model;
continue;
}
// Shouldn't we trigger an user-error?: Unknown Model or could not find the Model
}
return $models;
}
示例12: import
/**
* Gets an array or a comma separated list of models. Then it includes its
* respective files and returns an array of available models.
*
* @return unknown
*/
function import()
{
$args = func_get_args();
$args = is_array($args[0]) ? $args[0] : (func_num_args() > 1 ? $args : Ak::stringToArray($args[0]));
$models = array();
foreach ($args as $arg){
$model_name = AkInflector::camelize($arg);
$model = AkInflector::toModelFilename($model_name);
if(file_exists($model)){
$models[] = $model_name;
include_once($model);
}elseif (class_exists($model_name)){
$models[] = $model_name;
}
}
return $models;
}
示例13: setObservedModels
/**
* Constructs the Observer
* @param $subject the name or names of the Models to observe
*/
function setObservedModels ()
{
$args = func_get_args();
$models = func_num_args() == 1 ? ( is_array($args[0]) ? $args[0] : array($args[0]) ) : $args;
foreach ($models as $class_name)
{
$class_name = AkInflector::camelize($class_name);
include_once(AkInflector::toModelFilename($class_name));
eval("\$model =& new $class_name();");
$this->observe(&$model);
}
}
示例14: _createJoinClass
public function _createJoinClass()
{
$options = $this->getOptions($this->association_id);
$class_file_code = "<?php \n\n//This code was generated automatically by the active record hasAndBelongsToMany Method\n\n";
$class_code = "class {$options['join_class_name']} extends {$options['join_class_extends']} {\n public \$_avoidTableNameValidation = true;\n public function {$options['join_class_name']}()\n {\n \$this->setModelName(\"{$options['join_class_name']}\");\n \$attributes = (array)func_get_args();\n \$this->setTableName('{$options['join_table']}', true, true);\n \$this->init(\$attributes);\n }\n}";
$class_file_code .= $class_code . "\n\n?>";
$join_file = AkInflector::toModelFilename($options['join_class_name']);
if ($this->_automatically_create_join_model_files && !file_exists($join_file) && @Ak::file_put_contents($join_file, $class_file_code)) {
require_once $join_file;
} else {
eval($class_code);
}
return class_exists($options['join_class_name']);
}
示例15: _createNewTestingModel
function _createNewTestingModel($test_model_name)
{
static $shutdown_called;
switch ($test_model_name) {
case 'AkTestObservedPerson':
$model_source = '<?php
class AkTestObservedPerson extends AkActiveRecord
{
}
?>';
break;
case 'AkTestObservedAccount':
$model_source = '<?php
class AkTestObservedAccount extends AkActiveRecord
{
}
?>';
break;
case 'AkTestObservedPersonObserver':
$model_source = '<?php
class AkTestObservedPersonObserver extends AkObserver
{
function update($state)
{
switch ($state)
{
case "new person created" :
echo $state;
break;
default:
break;
}
}
function afterCreate(&$record)
{
echo $record->get("first_name")." has been email with account details";
$this->logNotified($record,__FUNCTION__);
}
function afterSave(&$record){$this->logNotified($record,__FUNCTION__);}
function afterValidationOnCreate(&$record){$this->logNotified($record,__FUNCTION__);}
function afterValidationOnUpdate(&$record){$this->logNotified($record,__FUNCTION__);}
function beforeSave(&$record){$this->logNotified($record,__FUNCTION__);
if(!empty($record->city) && $record->city == "Carlet")
{
$record->state = "Valencia";
}
}
function beforeCreate(&$record){$this->logNotified($record,__FUNCTION__); }
function beforeValidationOnCreate(&$record){$this->logNotified($record,__FUNCTION__);}
function beforeValidation(&$record){$this->logNotified($record,__FUNCTION__);}
function afterValidation(&$record) {$this->logNotified($record,__FUNCTION__);}
function logNotified(&$record, $function)
{
if(!isset($record->notified_observers[$function])){
$record->notified_observers[$function] = 0;
}
$record->notified_observers[$function]++;
}
}
?>';
break;
case 'AkTestAuditor':
$model_source = '<?php
class AkTestAuditor extends AkObserver
{
function update($state)
{
switch ($state)
{
case "new person created" :
echo $state;
break;
default:
break;
}
}
function afterCreate(&$record)
{
$record->audited = true;
}
}
?>';
break;
default:
$model_source = '<?php class ' . $test_model_name . ' extends AkActiveRecord { } ?>';
break;
}
$file_name = AkInflector::toModelFilename($test_model_name);
if (!Ak::file_put_contents($file_name, $model_source)) {
die('Ooops!, in order to perform this test, you must set your app/model permissions so this can script can create and delete files into/from it');
}
if (!in_array($file_name, get_included_files()) && !class_exists($test_model_name)) {
include $file_name;
} else {
//.........这里部分代码省略.........