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


PHP fGrammar::camelize方法代码示例

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


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

示例1: reflect

 /**
  * Adjusts the fActiveRecord::reflect() signatures of columns that have been configured in this class
  * 
  * @internal
  * 
  * @param  string  $class                 The class to reflect
  * @param  array   &$signatures           The associative array of `{method name} => {signature}`
  * @param  boolean $include_doc_comments  If doc comments should be included with the signature
  * @return void
  */
 public static function reflect($class, &$signatures, $include_doc_comments)
 {
     if (!isset(self::$money_columns[$class])) {
         return;
     }
     foreach (self::$money_columns[$class] as $column => $enabled) {
         $camelized_column = fGrammar::camelize($column, TRUE);
         // Get and set methods
         $signature = '';
         if ($include_doc_comments) {
             $signature .= "/**\n";
             $signature .= " * Gets the current value of " . $column . "\n";
             $signature .= " * \n";
             $signature .= " * @return fMoney  The current value\n";
             $signature .= " */\n";
         }
         $get_method = 'get' . $camelized_column;
         $signature .= 'public function ' . $get_method . '()';
         $signatures[$get_method] = $signature;
         $signature = '';
         if ($include_doc_comments) {
             $signature .= "/**\n";
             $signature .= " * Sets the value for " . $column . "\n";
             $signature .= " * \n";
             $signature .= " * @param  fMoney|string|integer \$" . $column . "  The new value - a string or integer will be converted to the default currency (if defined)\n";
             $signature .= " * @return fActiveRecord  The record object, to allow for method chaining\n";
             $signature .= " */\n";
         }
         $set_method = 'set' . $camelized_column;
         $signature .= 'public function ' . $set_method . '($' . $column . ')';
         $signatures[$set_method] = $signature;
         $signature = '';
         if ($include_doc_comments) {
             $signature .= "/**\n";
             $signature .= " * Encodes the value of " . $column . " for output into an HTML form\n";
             $signature .= " * \n";
             $signature .= " * If the value is an fMoney object, the ->__toString() method will be called\n";
             $signature .= " * resulting in the value minus the currency symbol and thousands separators\n";
             $signature .= " * \n";
             $signature .= " * @return string  The HTML form-ready value\n";
             $signature .= " */\n";
         }
         $encode_method = 'encode' . $camelized_column;
         $signature .= 'public function ' . $encode_method . '()';
         $signatures[$encode_method] = $signature;
         $signature = '';
         if ($include_doc_comments) {
             $signature .= "/**\n";
             $signature .= " * Prepares the value of " . $column . " for output into HTML\n";
             $signature .= " * \n";
             $signature .= " * If the value is an fMoney object, the ->format() method will be called\n";
             $signature .= " * resulting in the value including the currency symbol and thousands separators\n";
             $signature .= " * \n";
             $signature .= " * @param  boolean \$remove_zero_fraction  If a fraction of all zeros should be removed\n";
             $signature .= " * @return string  The HTML-ready value\n";
             $signature .= " */\n";
         }
         $prepare_method = 'prepare' . $camelized_column;
         $signature .= 'public function ' . $prepare_method . '($remove_zero_fraction=FALSE)';
         $signatures[$prepare_method] = $signature;
     }
 }
开发者ID:hibble,项目名称:printmaster,代码行数:72,代码来源:fORMMoney.php

示例2: set

 /**
  * Copies a file from the filesystem to the file upload directory and sets it as the file for the specified column
  * 
  * This method will perform the fImage calls defined for the column.
  * 
  * @internal
  * 
  * @param  fActiveRecord $object            The fActiveRecord instance
  * @param  array         &$values           The current values
  * @param  array         &$old_values       The old values
  * @param  array         &$related_records  Any records related to this record
  * @param  array         &$cache            The cache array for the record
  * @param  string        $method_name       The method that was called
  * @param  array         $parameters        The parameters passed to the method
  * @return fActiveRecord  The record object, to allow for method chaining
  */
 public static function set($object, &$values, &$old_values, &$related_records, &$cache, $method_name, $parameters)
 {
     $class = get_class($object);
     list($action, $column) = fORM::parseMethod($method_name);
     $doc_root = realpath($_SERVER['DOCUMENT_ROOT']);
     if (!array_key_exists(0, $parameters)) {
         throw new fProgrammerException('The method %s requires exactly one parameter', $method_name . '()');
     }
     $file_path = $parameters[0];
     // Handle objects being passed in
     if ($file_path instanceof fFile) {
         $file_path = $file_path->getPath();
     } elseif (is_object($file_path) && is_callable(array($file_path, '__toString'))) {
         $file_path = $file_path->__toString();
     } elseif (is_object($file_path)) {
         $file_path = (string) $file_path;
     }
     if ($file_path !== NULL && $file_path !== '' && $file_path !== FALSE) {
         if (!$file_path || !file_exists($file_path) && !file_exists($doc_root . $file_path)) {
             throw new fEnvironmentException('The file specified, %s, does not exist. This may indicate a missing enctype="multipart/form-data" attribute in form tag.', $file_path);
         }
         if (!file_exists($file_path) && file_exists($doc_root . $file_path)) {
             $file_path = $doc_root . $file_path;
         }
         if (is_dir($file_path)) {
             throw new fProgrammerException('The file specified, %s, is not a file but a directory', $file_path);
         }
         $upload_dir = self::$file_upload_columns[$class][$column];
         try {
             $temp_dir = new fDirectory($upload_dir->getPath() . self::TEMP_DIRECTORY . DIRECTORY_SEPARATOR);
         } catch (fValidationException $e) {
             $temp_dir = fDirectory::create($upload_dir->getPath() . self::TEMP_DIRECTORY . DIRECTORY_SEPARATOR);
         }
         $file = fFilesystem::createObject($file_path);
         $new_file = $file->duplicate($temp_dir);
     } else {
         $new_file = NULL;
     }
     fActiveRecord::assign($values, $old_values, $column, $new_file);
     // Perform column inheritance
     if (!empty(self::$column_inheritence[$class][$column])) {
         foreach (self::$column_inheritence[$class][$column] as $other_column) {
             self::set($object, $values, $old_values, $related_records, $cache, 'set' . fGrammar::camelize($other_column, TRUE), array($file));
         }
     }
     if ($new_file) {
         self::processImage($class, $column, $new_file);
     }
     return $object;
 }
开发者ID:hibble,项目名称:printmaster,代码行数:66,代码来源:fORMFile.php

示例3: storeOneToStar

 /**
  * Stores a set of one-to-many related records in the database
  *
  * @throws fValidationException  When one of the "many" records throws an exception from fActiveRecord::store()
  * @internal
  *
  * @param  string  $class             The class to store the related records for
  * @param  array   &$values           The current values for the main record being stored
  * @param  array   &$related_records  The related records array
  * @param  string  $related_class     The related class being stored
  * @param  string  $route             The route to the related class
  * @param  boolean $force_cascade     This flag will be passed to the fActiveRecord::delete() method on related records that are being deleted
  * @return void
  */
 public static function storeOneToStar($class, &$values, &$related_records, $related_class, $route, $force_cascade)
 {
     $table = fORM::tablize($class);
     $related_table = fORM::tablize($related_class);
     $schema = fORMSchema::retrieve($class);
     $relationship = fORMSchema::getRoute($schema, $table, $related_table, $route);
     $column_value = $values[$relationship['column']];
     if (!empty($related_records[$related_table][$route]['record_set'])) {
         $record_set = $related_records[$related_table][$route]['record_set'];
     } else {
         $record_set = self::buildRecords($class, $values, $related_records, $related_class, $route);
     }
     $where_conditions = array($relationship['related_column'] . '=' => $column_value);
     $existing_records = fRecordSet::build($related_class, $where_conditions);
     $existing_primary_keys = $existing_records->getPrimaryKeys();
     $new_primary_keys = $record_set->getPrimaryKeys();
     $primary_keys_to_delete = self::multidimensionArrayDiff($existing_primary_keys, $new_primary_keys);
     foreach ($primary_keys_to_delete as $primary_key_to_delete) {
         $object_to_delete = new $related_class($primary_key_to_delete);
         // don't delete record if the relationship does not call for it
         if ($relationship['on_delete'] == 'set_null') {
             $related_set_method = 'set' . fGrammar::camelize($relationship['related_column'], TRUE);
             $object_to_delete->{$related_set_method}(NULL);
             $object_to_delete->store();
             continue;
         }
         $object_to_delete->delete($force_cascade);
     }
     $set_method_name = 'set' . fGrammar::camelize($relationship['related_column'], TRUE);
     $first_pk_column = self::determineFirstPKColumn($class, $related_class, $route);
     $filter = self::determineRequestFilter(fORM::classize($relationship['table']), $related_class, $route);
     $pk_field = $filter . $first_pk_column;
     $input_keys = array_keys(fRequest::get($pk_field, 'array', array()));
     // Set all of the values first to prevent issues with recursive relationships
     foreach ($record_set as $i => $record) {
         $record->{$set_method_name}($column_value);
     }
     foreach ($record_set as $i => $record) {
         fRequest::filter($filter, isset($input_keys[$i]) ? $input_keys[$i] : $i);
         $record->store();
         fRequest::unfilter();
     }
 }
开发者ID:alandsidel,项目名称:flourish-classes,代码行数:57,代码来源:fORMRelated.php

示例4: replicate

 /**
  * Generates a clone of the current record, removing any auto incremented primary key value and allowing for replicating related records
  * 
  * This method will accept three different sets of parameters:
  * 
  *  - No parameters: this object will be cloned
  *  - A single `TRUE` value: this object plus all many-to-many associations and all child records (recursively) will be cloned
  *  - Any number of plural related record class names: the many-to-many associations or child records that correspond to the classes specified will be cloned
  * 
  * The class names specified can be a simple class name if there is only a
  * single route between the two corresponding database tables. If there is 
  * more than one route between the two tables, the class name should be
  * substituted with a string in the format `'RelatedClass{route}'`.
  * 
  * @param  string $related_class  The plural related class to replicate - see method description for details
  * @param  string ...
  * @return fActiveRecord  The cloned record
  */
 public function replicate($related_class = NULL)
 {
     fORM::callHookCallbacks($this, 'pre::replicate()', $this->values, $this->old_values, $this->related_records, $this->cache, fActiveRecord::$replicate_level);
     fActiveRecord::$replicate_level++;
     $class = get_class($this);
     $hash = self::hash($this->values, $class);
     $schema = fORMSchema::retrieve($class);
     $table = fORM::tablize($class);
     // If the object has not been replicated yet, do it now
     if (!isset(fActiveRecord::$replicate_map[$class])) {
         fActiveRecord::$replicate_map[$class] = array();
     }
     if (!isset(fActiveRecord::$replicate_map[$class][$hash])) {
         fActiveRecord::$replicate_map[$class][$hash] = clone $this;
         // We need the primary key to get a hash, otherwise certain recursive relationships end up losing members
         $pk_columns = $schema->getKeys($table, 'primary');
         if (sizeof($pk_columns) == 1 && $schema->getColumnInfo($table, $pk_columns[0], 'auto_increment')) {
             fActiveRecord::$replicate_map[$class][$hash]->values[$pk_columns[0]] = $this->values[$pk_columns[0]];
         }
     }
     $clone = fActiveRecord::$replicate_map[$class][$hash];
     $parameters = func_get_args();
     $recursive = FALSE;
     $many_to_many_relationships = $schema->getRelationships($table, 'many-to-many');
     $one_to_many_relationships = $schema->getRelationships($table, 'one-to-many');
     // When just TRUE is passed we recursively replicate all related records
     if (sizeof($parameters) == 1 && $parameters[0] === TRUE) {
         $parameters = array();
         $recursive = TRUE;
         foreach ($many_to_many_relationships as $relationship) {
             $parameters[] = fGrammar::pluralize(fORM::classize($relationship['related_table'])) . '{' . $relationship['join_table'] . '}';
         }
         foreach ($one_to_many_relationships as $relationship) {
             $parameters[] = fGrammar::pluralize(fORM::classize($relationship['related_table'])) . '{' . $relationship['related_column'] . '}';
         }
     }
     $record_sets = array();
     foreach ($parameters as $parameter) {
         // Parse the Class{route} strings
         if (strpos($parameter, '{') !== FALSE) {
             $brace = strpos($parameter, '{');
             $related_class = fGrammar::singularize(substr($parameter, 0, $brace));
             $related_class = fORM::getRelatedClass($class, $related_class);
             $related_table = fORM::tablize($related_class);
             $route = substr($parameter, $brace + 1, -1);
         } else {
             $related_class = fGrammar::singularize($parameter);
             $related_class = fORM::getRelatedClass($class, $related_class);
             $related_table = fORM::tablize($related_class);
             $route = fORMSchema::getRouteName($schema, $table, $related_table);
         }
         // Determine the kind of relationship
         $many_to_many = FALSE;
         $one_to_many = FALSE;
         foreach ($many_to_many_relationships as $relationship) {
             if ($relationship['related_table'] == $related_table && $relationship['join_table'] == $route) {
                 $many_to_many = TRUE;
                 break;
             }
         }
         foreach ($one_to_many_relationships as $relationship) {
             if ($relationship['related_table'] == $related_table && $relationship['related_column'] == $route) {
                 $one_to_many = TRUE;
                 break;
             }
         }
         if (!$many_to_many && !$one_to_many) {
             throw new fProgrammerException('The related class specified, %1$s, does not appear to be in a many-to-many or one-to-many relationship with %$2s', $parameter, get_class($this));
         }
         // Get the related records
         $record_set = fORMRelated::buildRecords($class, $this->values, $this->related_records, $related_class, $route);
         // One-to-many records need to be replicated, possibly recursively
         if ($one_to_many) {
             if ($recursive) {
                 $records = $record_set->call('replicate', TRUE);
             } else {
                 $records = $record_set->call('replicate');
             }
             $record_set = fRecordSet::buildFromArray($related_class, $records);
             $record_set->call('set' . fGrammar::camelize($route, TRUE), NULL);
         }
         // Cause the related records to be associated with the new clone
//.........这里部分代码省略.........
开发者ID:mrjwc,项目名称:printmaster,代码行数:101,代码来源:fActiveRecord.php

示例5: precreate

 /** 
  * Creates the objects for related records that are in a one-to-one or many-to-one relationship with the current class in a single DB query
  *  
  * @param  string $related_class  This should be the name of a related class
  * @param  string $route          This should be the column name of the foreign key and is only required when there are multiple routes to a related table. If there are multiple routes and this is not specified, an fProgrammerException will be thrown.
  * @return fRecordSet  The record set object, to allow for method chaining
  */
 private function precreate($related_class, $route = NULL)
 {
     if (!$this->records) {
         return $this;
     }
     $this->validateSingleClass('precreate');
     // If there are no primary keys we can just exit
     if (!array_merge($this->getPrimaryKeys())) {
         return $this;
     }
     fActiveRecord::validateClass($related_class);
     fActiveRecord::forceConfigure($related_class);
     $relationship = fORMSchema::getRoute(fORMSchema::retrieve($this->class), fORM::tablize($this->class), fORM::tablize($related_class), $route, '*-to-one');
     $values = $this->call('get' . fGrammar::camelize($relationship['column'], TRUE));
     $values = array_unique($values);
     self::build($related_class, array($relationship['related_column'] . '=' => $values));
     return $this;
 }
开发者ID:JhunCabas,项目名称:material-management,代码行数:25,代码来源:fRecordSet.php

示例6: configureTimezoneColumn

 /**
  * Sets a timestamp column to store the timezone in another column
  *
  * Since not all databases support timezone information in timestamp
  * columns, this method allows storing the timezone in another columns.
  * When the timestamp and timezone are retrieved from the database, they
  * will be automatically combined together into an fTimestamp object.
  *
  * @param  mixed  $class             The class name or instance of the class to set the column format
  * @param  string $timestamp_column  The timestamp column to store the timezone for
  * @param  string $timezone_column   The column to store the timezone in
  * @return void
  */
 public static function configureTimezoneColumn($class, $timestamp_column, $timezone_column)
 {
     $class = fORM::getClass($class);
     $table = fORM::tablize($class);
     $schema = fORMSchema::retrieve($class);
     $timestamp_data_type = $schema->getColumnInfo($table, $timestamp_column, 'type');
     if ($timestamp_data_type != 'timestamp') {
         throw new fProgrammerException('The timestamp column specified, %1$s, is a %2$s column. Must be a %3$s to have a related timezone column.', $timestamp_column, $data_type, 'timestamp');
     }
     $timezone_column_data_type = $schema->getColumnInfo($table, $timezone_column, 'type');
     $valid_timezone_column_data_types = array('varchar', 'char', 'text');
     if (!in_array($timezone_column_data_type, $valid_timezone_column_data_types)) {
         throw new fProgrammerException('The timezone column specified, %1$s, is a %2$s column. Must be %3$s to be set as a timezone column.', $timezone_column, $timezone_column_data_type, join(', ', $valid_timezone_column_data_types));
     }
     if (!fORM::checkHookCallback($class, 'post::validate()', self::validateTimezoneColumns)) {
         fORM::registerHookCallback($class, 'post::validate()', self::validateTimezoneColumns);
     }
     if (!fORM::checkHookCallback($class, 'post::loadFromResult()', self::makeTimestampObjects)) {
         fORM::registerHookCallback($class, 'post::loadFromResult()', self::makeTimestampObjects);
     }
     if (!fORM::checkHookCallback($class, 'pre::validate()', self::makeTimestampObjects)) {
         fORM::registerHookCallback($class, 'pre::validate()', self::makeTimestampObjects);
     }
     fORM::registerInspectCallback($class, $timezone_column, self::inspect);
     fORM::registerActiveRecordMethod($class, 'set' . fGrammar::camelize($timestamp_column, TRUE), self::setTimestampColumn);
     fORM::registerActiveRecordMethod($class, 'set' . fGrammar::camelize($timezone_column, TRUE), self::setTimezoneColumn);
     if (empty(self::$timestamp_columns[$class])) {
         self::$timestamp_columns[$class] = array();
     }
     self::$timestamp_columns[$class][$timestamp_column] = $timezone_column;
     if (empty(self::$timezone_columns[$class])) {
         self::$timezone_columns[$class] = array();
     }
     self::$timezone_columns[$class][$timezone_column] = $timestamp_column;
 }
开发者ID:alandsidel,项目名称:flourish-classes,代码行数:48,代码来源:fORMDate.php

示例7: classize

 /**
  * Takes a table and turns it into a class name - uses custom mapping if set
  *
  * @param  string $table  The table name
  * @return string  The class name
  */
 public static function classize($table)
 {
     if (!($class = array_search($table, self::$class_table_map))) {
         $class = fGrammar::camelize(fGrammar::singularize($table), TRUE);
         self::$class_table_map[$class] = $table;
     }
     return $class;
 }
开发者ID:gopalgrover23,项目名称:flourish-classes,代码行数:14,代码来源:fORM.php

示例8: reflect

 /**
  * Adjusts the fActiveRecord::reflect() signatures of columns that have been configured in this class
  *
  * @internal
  *
  * @param  string  $class                 The class to reflect
  * @param  array   &$signatures           The associative array of `{method name} => {signature}`
  * @param  boolean $include_doc_comments  If doc comments should be included with the signature
  * @return void
  */
 public static function reflect($class, &$signatures, $include_doc_comments)
 {
     if (!isset(self::$ordering_columns[$class])) {
         return;
     }
     foreach (self::$ordering_columns[$class] as $column => $enabled) {
         $camelized_column = fGrammar::camelize($column, TRUE);
         $signature = '';
         if ($include_doc_comments) {
             $signature .= "/**\n";
             $signature .= " * Returns metadata about " . $column . "\n";
             $signature .= " * \n";
             $signature .= " * @param  string \$element  The element to return. Must be one of: 'type', 'not_null', 'default', 'feature', 'max_ordering_value'.\n";
             $signature .= " * @return mixed  The metadata array or a single element\n";
             $signature .= " */\n";
         }
         $inspect_method = 'inspect' . $camelized_column;
         $signature .= 'public function ' . $inspect_method . '($element=NULL)';
         $signatures[$inspect_method] = $signature;
     }
 }
开发者ID:gopalgrover23,项目名称:flourish-classes,代码行数:31,代码来源:fORMOrdering.php

示例9: testCamelizeCustom

 public function testCamelizeCustom()
 {
     fGrammar::addCamelUnderscoreRule('3rdParty', '3rd_party');
     $this->assertEquals('3rdParty', fGrammar::camelize('3rd_party', TRUE));
 }
开发者ID:nurulimamnotes,项目名称:flourish-old,代码行数:5,代码来源:fGrammarTest.php

示例10: reflectPhpDoc

 /**
  * Generates phpdoc for class
  * @return string
  */
 public function reflectPhpDoc()
 {
     $signatures = array();
     $class = get_class($this);
     $table = fORM::tablize($class);
     $schema = fORMSchema::retrieve($class);
     foreach ($schema->getColumnInfo($table) as $column => $columnInfo) {
         $camelizedColumn = fGrammar::camelize($column, TRUE);
         // Get and set methods
         $fixedType = $columnInfo['type'];
         if ($fixedType == 'blob') {
             $fixedType = 'string';
         }
         if ($fixedType == 'varchar') {
             $fixedType = 'string';
         }
         if ($fixedType == 'date') {
             $fixedType = 'fDate|string';
         }
         if ($fixedType == 'timestamp') {
             $fixedType = 'fTimestamp|string';
         }
         if ($fixedType == 'time') {
             $fixedType = 'fTime|string';
         }
         $firstFixedType = reset(explode('|', $fixedType));
         $signatures[] = $this->generateMagicMethodPhpDoc('get' . $camelizedColumn, array(), $firstFixedType, "Gets the current value of {$column}");
         $signatures[] = $this->generateMagicMethodPhpDoc('set' . $camelizedColumn, array($fixedType => $column), $class, "Sets the value for {$column}");
     }
     return $signatures;
 }
开发者ID:pmanterys,项目名称:wp-mw-newsletter,代码行数:35,代码来源:AbstractModel.php

示例11: setRandomStrings

 /**
  * Sets the appropriate column values to a random string if the object is new
  *
  * @internal
  *
  * @param  fActiveRecord $object            The fActiveRecord instance
  * @param  array         &$values           The current values
  * @param  array         &$old_values       The old values
  * @param  array         &$related_records  Any records related to this record
  * @param  array         &$cache            The cache array for the record
  * @return string  The formatted link
  */
 public static function setRandomStrings($object, &$values, &$old_values, &$related_records, &$cache)
 {
     if ($object->exists()) {
         return;
     }
     $class = get_class($object);
     $table = fORM::tablize($class);
     foreach (self::$random_columns[$class] as $column => $settings) {
         if (fActiveRecord::hasOld($old_values, $column) && $values[$column]) {
             continue;
         }
         self::generate($object, $values, $old_values, $related_records, $cache, 'generate' . fGrammar::camelize($column, TRUE), array());
     }
 }
开发者ID:gopalgrover23,项目名称:flourish-classes,代码行数:26,代码来源:fORMColumn.php

示例12: reflect

 /**
  * Adjusts the fActiveRecord::reflect() signatures of columns that have been configured in this class
  * 
  * @internal
  * 
  * @param  string  $class                 The class to reflect
  * @param  array   &$signatures           The associative array of `{method name} => {signature}`
  * @param  boolean $include_doc_comments  If doc comments should be included with the signature
  * @return void
  */
 public static function reflect($class, &$signatures, $include_doc_comments)
 {
     $image_columns = isset(self::$image_upload_columns[$class]) ? array_keys(self::$image_upload_columns[$class]) : array();
     $file_columns = isset(self::$file_upload_columns[$class]) ? array_keys(self::$file_upload_columns[$class]) : array();
     foreach ($file_columns as $column) {
         $camelized_column = fGrammar::camelize($column, TRUE);
         $noun = 'file';
         if (in_array($column, $image_columns)) {
             $noun = 'image';
         }
         $signature = '';
         if ($include_doc_comments) {
             $signature .= "/**\n";
             $signature .= " * Encodes the filename of " . $column . " for output into an HTML form\n";
             $signature .= " * \n";
             $signature .= " * Only the filename will be returned, any directory will be stripped.\n";
             $signature .= " * \n";
             $signature .= " * @return string  The HTML form-ready value\n";
             $signature .= " */\n";
         }
         $encode_method = 'encode' . $camelized_column;
         $signature .= 'public function ' . $encode_method . '()';
         $signatures[$encode_method] = $signature;
         if (in_array($column, $image_columns)) {
             $signature = '';
             if ($include_doc_comments) {
                 $signature .= "/**\n";
                 $signature .= " * Takes the existing image and runs it through the prescribed fImage method calls\n";
                 $signature .= " * \n";
                 $signature .= " * @return void\n";
                 $signature .= " */\n";
             }
             $process_method = 'process' . $camelized_column;
             $signature .= 'public function ' . $process_method . '()';
             $signatures[$process_method] = $signature;
         }
         $signature = '';
         if ($include_doc_comments) {
             $signature .= "/**\n";
             $signature .= " * Prepares the filename of " . $column . " for output into HTML\n";
             $signature .= " * \n";
             $signature .= " * By default only the filename will be returned and any directory will be stripped.\n";
             $signature .= " * The \$include_web_path parameter changes this behaviour.\n";
             $signature .= " * \n";
             $signature .= " * @param  boolean \$include_web_path  If the full web path to the " . $noun . " should be included\n";
             $signature .= " * @return string  The HTML-ready value\n";
             $signature .= " */\n";
         }
         $prepare_method = 'prepare' . $camelized_column;
         $signature .= 'public function ' . $prepare_method . '($include_web_path=FALSE)';
         $signatures[$prepare_method] = $signature;
         $signature = '';
         if ($include_doc_comments) {
             $signature .= "/**\n";
             $signature .= " * Takes a file uploaded through an HTML form for " . $column . " and moves it into the specified directory\n";
             $signature .= " * \n";
             $signature .= " * Any columns that were designated as inheriting from this column will get a copy\n";
             $signature .= " * of the uploaded file.\n";
             $signature .= " * \n";
             if ($noun == 'image') {
                 $signature .= " * Any fImage calls that were added to the column will be processed on the uploaded image.\n";
                 $signature .= " * \n";
             }
             $signature .= " * @return void\n";
             $signature .= " */\n";
         }
         $upload_method = 'upload' . $camelized_column;
         $signature .= 'public function ' . $upload_method . '()';
         $signatures[$upload_method] = $signature;
         $signature = '';
         if ($include_doc_comments) {
             $signature .= "/**\n";
             $signature .= " * Takes a file that exists on the filesystem and copies it into the specified directory for " . $column . "\n";
             $signature .= " * \n";
             if ($noun == 'image') {
                 $signature .= " * Any fImage calls that were added to the column will be processed on the copied image.\n";
                 $signature .= " * \n";
             }
             $signature .= " * @return void\n";
             $signature .= " */\n";
         }
         $set_method = 'set' . $camelized_column;
         $signature .= 'public function ' . $set_method . '()';
         $signatures[$set_method] = $signature;
         $signature = '';
         if ($include_doc_comments) {
             $signature .= "/**\n";
             $signature .= " * Returns metadata about " . $column . "\n";
             $signature .= " * \n";
             $signature .= " * @param  string \$element  The element to return. Must be one of: 'type', 'not_null', 'default', 'valid_values', 'max_length', 'feature', 'directory'.\n";
//.........这里部分代码省略.........
开发者ID:jsuarez,项目名称:MyDesign,代码行数:101,代码来源:fORMFile.php

示例13: buildRecords

 /**
  * Recursivly builds records.
  *
  * @param array* $completed_fixtures
  *   Completed records is stored in this array
  * @param $fixture_data
  *   Build records of this fixture
  */
 private function buildRecords(&$completed_fixtures, $fixture_name, $traverse = TRUE)
 {
     if (array_key_exists($fixture_name, $completed_fixtures)) {
         return;
     }
     // Load data
     if (isset($this->fixture_data[$fixture_name]) === FALSE) {
         $this->loadFixture($fixture_name);
     }
     $class_name = fORM::classize($fixture_name);
     // If the class does not exists created it
     if (class_exists($class_name) === FALSE) {
         fORM::defineActiveRecordClass($class_name);
     }
     // Create the records
     $method_name = NULL;
     $record = NULL;
     $records = array();
     foreach ($this->fixture_data[$fixture_name] as $record_data) {
         $record = new $class_name();
         foreach ($record_data as $key => $value) {
             $method_name = 'set' . fGrammar::camelize($key, $upper = TRUE);
             $value = $this->applyHookCallbacks(self::PreSetBuildHook, $fixture_name, $key, $value);
             if ($this->isRelationshipKey($fixture_name, $key)) {
                 $related_table = $this->getRelatedTable($fixture_name, $key);
                 $required = $this->isRequiredKey($fixture_name, $key);
                 if ($traverse && array_key_exists($related_table, $completed_fixtures) === FALSE && $fixture_name !== $related_table) {
                     if (isset($value) && array_key_exists($related_table, $this->fixture_sources)) {
                         $this->buildRecords($completed_fixtures, $related_table);
                         array_unshift($this->tables_to_tear_down, $related_table);
                     }
                 }
             }
             $record->{$method_name}($value);
         }
         $record->store();
         $records[] = $record;
     }
     $completed_fixtures[$fixture_name] = fRecordSet::buildFromArray($class_name, $records);
 }
开发者ID:mblarsen,项目名称:ffixture,代码行数:48,代码来源:fFixture.php


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