当前位置: 首页>>代码示例>>PHP>>正文


PHP AkInflector::modulize方法代码示例

本文整理汇总了PHP中AkInflector::modulize方法的典型用法代码示例。如果您正苦于以下问题:PHP AkInflector::modulize方法的具体用法?PHP AkInflector::modulize怎么用?PHP AkInflector::modulize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AkInflector的用法示例。


在下文中一共展示了AkInflector::modulize方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 function &addAssociated($association_id, $options = array())
 {
     $default_options = array('class_name' => empty($options['class_name']) ? AkInflector::modulize($association_id) : $options['class_name'], 'conditions' => false, 'order' => false, 'include_conditions_when_included' => true, 'include_order_when_included' => true, 'group' => false, 'foreign_key' => false, 'dependent' => 'nullify', 'finder_sql' => false, 'counter_sql' => false, 'include' => false, 'instantiate' => false, 'group' => false, 'limit' => false, 'offset' => false, 'handler_name' => strtolower(AkInflector::underscore(AkInflector::singularize($association_id))), 'select' => false);
     $options = array_merge($default_options, $options);
     $options['foreign_key'] = empty($options['foreign_key']) ? AkInflector::underscore($this->Owner->getModelName()) . '_id' : $options['foreign_key'];
     $Collection =& $this->_setCollectionHandler($association_id, $options['handler_name']);
     $Collection->setOptions($association_id, $options);
     $this->addModel($association_id, $Collection);
     if ($options['instantiate']) {
         $associated =& $Collection->load();
     }
     $this->setAssociatedId($association_id, $options['handler_name']);
     $Collection->association_id = $association_id;
     return $Collection;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:15,代码来源:AkHasMany.php

示例2: cast

 function cast()
 {
     $this->model_name = AkInflector::modulize($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->files = array('controller.php' => $this->controller_file_path, '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_name . '.tpl', 'style.css' => AK_PUBLIC_DIR . DS . 'stylesheets' . DS . 'scaffold.css', 'view_add' => AK_VIEWS_DIR . DS . $this->singular_name . DS . 'add.tpl', 'view_destroy' => AK_VIEWS_DIR . DS . $this->singular_name . DS . 'destroy.tpl', 'view_edit' => AK_VIEWS_DIR . DS . $this->singular_name . DS . 'edit.tpl', 'view_listing' => AK_VIEWS_DIR . DS . $this->singular_name . DS . 'listing.tpl', 'view_show' => AK_VIEWS_DIR . DS . $this->singular_name . DS . 'show.tpl', 'form' => AK_VIEWS_DIR . DS . $this->singular_name . DS . '_form.tpl');
     $this->user_actions = array();
     foreach ((array) @$this->actions as $action) {
         $this->user_actions[$action] = AK_VIEWS_DIR . DS . $this->singular_name . DS . $action . '.tpl';
     }
 }
开发者ID:joeymetal,项目名称:v1,代码行数:17,代码来源:scaffold_generator.php

示例3: populateTables

    function populateTables()
    {
        $args = func_get_args();
        $tables = !empty($args) ? (is_array($args[0]) ? $args[0] : (count($args) > 1 ? $args : Ak::toArray($args))) : array();
        foreach ($tables as $table){
            $file = AK_TEST_DIR.DS.'fixtures'.DS.'data'.DS.(empty($this->module)?'':$this->module.DS).Ak::sanitize_include($table).'.yaml';
            if(!file_exists($file)){
                continue;
            }
            $class_name = AkInflector::modulize($table);
            if($this->instantiateModel($class_name)){
                $items = Ak::convert('yaml','array',file_get_contents($file));
                foreach ($items as $item){
                    $this->{$class_name}->create($item);
                }
            }

        }
    }
开发者ID:joeymetal,项目名称:v1,代码行数:19,代码来源:AkUnitTest.php

示例4: 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::modulize($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;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:23,代码来源:Ak.php

示例5: _getIncludedControllerNames

 /**
  * @todo Refactorize transversing dir instead of looking for loaded files (if faster)
  */
 function _getIncludedControllerNames()
 {
     $controllers = array();
     foreach (get_included_files() as $file_name) {
         if (strstr($file_name, AK_CONTROLLERS_DIR)) {
             $controllers[] = AkInflector::modulize(str_replace(array(AK_CONTROLLERS_DIR . DS, '.php'), '', $file_name));
         }
     }
     return $controllers;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:13,代码来源:AkActionController.php

示例6: array

 function &addAssociated($association_id, $options = array())
 {
     $default_options = array('class_name' => empty($options['class_name']) ? AkInflector::modulize($association_id) : $options['class_name'], 'table_name' => false, 'join_table' => false, 'join_class_name' => false, 'foreign_key' => false, 'association_foreign_key' => false, 'conditions' => false, 'order' => false, 'join_class_extends' => 'AkActiveRecord', 'finder_sql' => false, 'delete_sql' => false, 'insert_sql' => false, 'include' => false, 'group' => false, 'limit' => false, 'offset' => false, 'handler_name' => strtolower(AkInflector::underscore(AkInflector::singularize($association_id))), 'select' => false, 'instantiate' => false);
     $options = array_merge($default_options, $options);
     $owner_name = $this->Owner->getModelName();
     $owner_table = $this->Owner->getTableName();
     $associated_name = $options['class_name'];
     $associated_table_name = $options['table_name'] = empty($options['table_name']) ? AkInflector::tableize($associated_name) : $options['table_name'];
     $join_tables = array($owner_table, $associated_table_name);
     sort($join_tables);
     $options['join_table'] = empty($options['join_table']) ? join('_', $join_tables) : $options['join_table'];
     $options['join_class_name'] = empty($options['join_class_name']) ? join(array_map(array('AkInflector', 'modulize'), array_map(array('AkInflector', 'singularize'), $join_tables))) : $options['join_class_name'];
     $options['foreign_key'] = empty($options['foreign_key']) ? AkInflector::underscore($owner_name) . '_id' : $options['foreign_key'];
     $options['association_foreign_key'] = empty($options['association_foreign_key']) ? AkInflector::underscore($associated_name) . '_id' : $options['association_foreign_key'];
     $Collection =& $this->_setCollectionHandler($association_id, $options['handler_name']);
     $Collection->setOptions($association_id, $options);
     $this->addModel($association_id, $Collection);
     if ($options['instantiate']) {
         $associated =& $Collection->load();
     }
     $this->setAssociatedId($association_id, $options['handler_name']);
     $Collection->association_id = $association_id;
     $Collection->_loadJoinObject() ? null : trigger_error(Ak::t('Could find join model %model_name for hasAndBelongsToMany association %id', array('%table_name' => $options['join_class_name'], 'id' => $this->association_id)), E_USER_ERROR);
     return $Collection;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:25,代码来源:AkHasAndBelongsToMany.php

示例7: array

 /**
  * Finder methods must instantiate through this method to work with the single-table inheritance model and
  * eager loading associations.
  * that makes it possible to create objects of different types from the same table.
  */
 function &instantiate($record, $set_as_new = true)
 {
     $inheritance_column = $this->getInheritanceColumn();
     if (!empty($record[$inheritance_column])) {
         $inheritance_column = $record[$inheritance_column];
         $inheritance_model_name = AkInflector::modulize($inheritance_column);
         @(require_once AkInflector::toModelFilename($inheritance_model_name));
         if (!class_exists($inheritance_model_name)) {
             trigger_error($this->t("The single-table inheritance mechanism failed to locate the subclass: '%class_name'. " . "This error is raised because the column '%column' is reserved for storing the class in case of inheritance. " . "Please rename this column if you didn't intend it to be used for storing the inheritance class " . "or overwrite #{self.to_s}.inheritance_column to use another column for that information.", array('%class_name' => $inheritance_model_name, '%column' => $this->getInheritanceColumn())), E_USER_ERROR);
         }
     }
     $model_name = isset($inheritance_model_name) ? $inheritance_model_name : $this->getModelName();
     $object =& new $model_name('attributes', $record);
     $object->_newRecord = $set_as_new;
     AK_CLI && AK_ENVIRONMENT == 'development' ? $object->toString() : null;
     return $object;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:22,代码来源:AkActiveRecord.php

示例8: _getIncludedModelNames

 function _getIncludedModelNames()
 {
     $included_files = get_included_files();
     $models = array();
     foreach ($included_files as $file_name) {
         if (strstr($file_name, AK_MODELS_DIR)) {
             $models[] = AkInflector::modulize(str_replace(array(AK_MODELS_DIR . DS, '.php'), '', $file_name));
         }
     }
     return $models;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:11,代码来源:AkBaseModel.php

示例9: 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::modulize($class_name);
         include_once AkInflector::toModelFilename($class_name);
         eval("\$model =& new {$class_name}();");
         $this->observe(&$model);
     }
 }
开发者ID:joeymetal,项目名称:v1,代码行数:15,代码来源:AkObserver.php


注:本文中的AkInflector::modulize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。