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


PHP fORM::registerObjectifyCallback方法代码示例

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


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

示例1: configureMoneyColumn

 /**
  * Sets a column to be formatted as an fMoney object
  * 
  * @param  mixed  $class            The class name or instance of the class to set the column format
  * @param  string $column           The column to format as an fMoney object
  * @param  string $currency_column  If specified, this column will store the currency of the fMoney object
  * @return void
  */
 public static function configureMoneyColumn($class, $column, $currency_column = NULL)
 {
     $class = fORM::getClass($class);
     $table = fORM::tablize($class);
     $schema = fORMSchema::retrieve($class);
     $data_type = $schema->getColumnInfo($table, $column, 'type');
     $valid_data_types = array('float');
     if (!in_array($data_type, $valid_data_types)) {
         throw new fProgrammerException('The column specified, %1$s, is a %2$s column. Must be %3$s to be set as a money column.', $column, $data_type, join(', ', $valid_data_types));
     }
     if ($currency_column !== NULL) {
         $currency_column_data_type = $schema->getColumnInfo($table, $currency_column, 'type');
         $valid_currency_column_data_types = array('varchar', 'char', 'text');
         if (!in_array($currency_column_data_type, $valid_currency_column_data_types)) {
             throw new fProgrammerException('The currency column specified, %1$s, is a %2$s column. Must be %3$s to be set as a currency column.', $currency_column, $currency_column_data_type, join(', ', $valid_currency_column_data_types));
         }
     }
     $camelized_column = fGrammar::camelize($column, TRUE);
     fORM::registerActiveRecordMethod($class, 'encode' . $camelized_column, self::encodeMoneyColumn);
     fORM::registerActiveRecordMethod($class, 'prepare' . $camelized_column, self::prepareMoneyColumn);
     if (!fORM::checkHookCallback($class, 'post::validate()', self::validateMoneyColumns)) {
         fORM::registerHookCallback($class, 'post::validate()', self::validateMoneyColumns);
     }
     fORM::registerReflectCallback($class, self::reflect);
     fORM::registerInspectCallback($class, $column, self::inspect);
     $value = FALSE;
     if ($currency_column) {
         $value = $currency_column;
         if (empty(self::$currency_columns[$class])) {
             self::$currency_columns[$class] = array();
         }
         self::$currency_columns[$class][$currency_column] = $column;
         if (!fORM::checkHookCallback($class, 'post::loadFromResult()', self::makeMoneyObjects)) {
             fORM::registerHookCallback($class, 'post::loadFromResult()', self::makeMoneyObjects);
         }
         if (!fORM::checkHookCallback($class, 'pre::validate()', self::makeMoneyObjects)) {
             fORM::registerHookCallback($class, 'pre::validate()', self::makeMoneyObjects);
         }
         fORM::registerActiveRecordMethod($class, 'set' . $camelized_column, self::setMoneyColumn);
         fORM::registerActiveRecordMethod($class, 'set' . fGrammar::camelize($currency_column, TRUE), self::setCurrencyColumn);
     } else {
         fORM::registerObjectifyCallback($class, $column, self::objectifyMoney);
     }
     if (empty(self::$money_columns[$class])) {
         self::$money_columns[$class] = array();
     }
     self::$money_columns[$class][$column] = $value;
 }
开发者ID:hibble,项目名称:printmaster,代码行数:56,代码来源:fORMMoney.php

示例2: configureFileUploadColumn

 /**
  * Sets a column to be a file upload column
  * 
  * Configuring a column to be a file upload column means that whenever
  * fActiveRecord::populate() is called for an fActiveRecord object, any
  * appropriately named file uploads (via `$_FILES`) will be moved into
  * the directory for this column.
  * 
  * Setting the column to a file path will cause the specified file to
  * be copied into the directory for this column.
  * 
  * @param  mixed             $class      The class name or instance of the class
  * @param  string            $column     The column to set as a file upload column
  * @param  fDirectory|string $directory  The directory to upload/move to
  * @return void
  */
 public static function configureFileUploadColumn($class, $column, $directory)
 {
     $class = fORM::getClass($class);
     $table = fORM::tablize($class);
     $schema = fORMSchema::retrieve($class);
     $data_type = $schema->getColumnInfo($table, $column, 'type');
     $valid_data_types = array('varchar', 'char', 'text');
     if (!in_array($data_type, $valid_data_types)) {
         throw new fProgrammerException('The column specified, %1$s, is a %2$s column. Must be one of %3$s to be set as a file upload column.', $column, $data_type, join(', ', $valid_data_types));
     }
     if (!is_object($directory)) {
         $directory = new fDirectory($directory);
     }
     if (!$directory->isWritable()) {
         throw new fEnvironmentException('The file upload directory, %s, is not writable', $directory->getPath());
     }
     $camelized_column = fGrammar::camelize($column, TRUE);
     fORM::registerActiveRecordMethod($class, 'upload' . $camelized_column, self::upload);
     fORM::registerActiveRecordMethod($class, 'set' . $camelized_column, self::set);
     fORM::registerActiveRecordMethod($class, 'encode' . $camelized_column, self::encode);
     fORM::registerActiveRecordMethod($class, 'prepare' . $camelized_column, self::prepare);
     fORM::registerReflectCallback($class, self::reflect);
     fORM::registerInspectCallback($class, $column, self::inspect);
     fORM::registerReplicateCallback($class, $column, self::replicate);
     fORM::registerObjectifyCallback($class, $column, self::objectify);
     $only_once_hooks = array('post-begin::delete()' => self::begin, 'pre-commit::delete()' => self::delete, 'post-commit::delete()' => self::commit, 'post-rollback::delete()' => self::rollback, 'post::populate()' => self::populate, 'post-begin::store()' => self::begin, 'post-validate::store()' => self::moveFromTemp, 'pre-commit::store()' => self::deleteOld, 'post-commit::store()' => self::commit, 'post-rollback::store()' => self::rollback, 'post::validate()' => self::validate);
     foreach ($only_once_hooks as $hook => $callback) {
         if (!fORM::checkHookCallback($class, $hook, $callback)) {
             fORM::registerHookCallback($class, $hook, $callback);
         }
     }
     if (empty(self::$file_upload_columns[$class])) {
         self::$file_upload_columns[$class] = array();
     }
     self::$file_upload_columns[$class][$column] = $directory;
 }
开发者ID:hibble,项目名称:printmaster,代码行数:52,代码来源:fORMFile.php

示例3: configureNumberColumn

 /**
  * Sets a column to be returned as an fNumber object from calls to `get{ColumnName}()`
  *
  * @param  mixed  $class   The class name or instance of the class to set the column format
  * @param  string $column  The column to return as an fNumber object
  * @return void
  */
 public static function configureNumberColumn($class, $column)
 {
     $class = fORM::getClass($class);
     $table = fORM::tablize($class);
     $schema = fORMSchema::retrieve($class);
     $data_type = $schema->getColumnInfo($table, $column, 'type');
     $valid_data_types = array('integer', 'float');
     if (!in_array($data_type, $valid_data_types)) {
         throw new fProgrammerException('The column specified, %1$s, is a %2$s column. Must be %3$s to be set as a number column.', $column, $data_type, join(', ', $valid_data_types));
     }
     $camelized_column = fGrammar::camelize($column, TRUE);
     fORM::registerActiveRecordMethod($class, 'encode' . $camelized_column, self::encodeNumberColumn);
     fORM::registerActiveRecordMethod($class, 'prepare' . $camelized_column, self::prepareNumberColumn);
     fORM::registerReflectCallback($class, self::reflect);
     fORM::registerInspectCallback($class, $column, self::inspect);
     fORM::registerObjectifyCallback($class, $column, self::objectifyNumber);
     if (empty(self::$number_columns[$class])) {
         self::$number_columns[$class] = array();
     }
     self::$number_columns[$class][$column] = TRUE;
 }
开发者ID:gopalgrover23,项目名称:flourish-classes,代码行数:28,代码来源:fORMColumn.php


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