Example #1
0
 protected function _addParamsToDataset($dataset, $params)
 {
     foreach ($params as $param => $value) {
         $method = lmb_camel_case('set_' . $param, false);
         $dataset->{$method}($value);
     }
 }
 /**
  * @param lmbProjectConstructor $project
  * @param lmbDbInfo $database_info
  * @param lmbDbTableInfo $table
  * @param string $model_name
  */
 function __construct($project, $database_info, $table, $model_name = null, $templates_dir = null)
 {
     parent::__construct($project, $database_info, $table, $templates_dir);
     if (is_null($model_name)) {
         $model_name = lmb_camel_case($table->getName());
     }
     $this->_model_name = $model_name;
 }
 function testChangeOutput()
 {
     $cont = $this->_getContainer();
     $cont->setOutputType('gif');
     $class_name = 'lmb' . lmb_camel_case($this->driver) . 'OutputImageFilter';
     $filter = new $class_name(array('type' => 'jpeg'));
     $filter->apply($cont);
     $this->assertEqual($cont->getOutputType(), 'jpeg');
 }
 function testCamelCaseDontUcfirst()
 {
     $this->assertEqual(lmb_camel_case('foo', false), 'foo');
     $this->assertEqual(lmb_camel_case('foo_bar', false), 'fooBar');
     $this->assertEqual(lmb_camel_case('foo168_bar', false), 'foo168Bar');
     $this->assertEqual(lmb_camel_case('foo_bar_hey_wow', false), 'fooBarHeyWow');
     $this->assertEqual(lmb_camel_case('_foo_bar', false), '_fooBar');
     $this->assertEqual(lmb_camel_case('_foo_bar_', false), '_fooBar_');
     $this->assertEqual(lmb_camel_case('___foo___bar', false), '___foo_Bar');
     $this->assertEqual(lmb_camel_case('___foo___bar_hey', false), '___foo_BarHey');
 }
 function _fillHints()
 {
     $result = array();
     foreach ($this->_hints as $hint) {
         $method = '_get' . lmb_camel_case($hint) . 'Hint';
         $wrapped_hint = $this->_wrapHint($hint);
         if (!strpos($this->_template_sql, $wrapped_hint)) {
             throw new lmbException('Hint ' . $wrapped_hint . ' is not found in template sql "' . $this->_template_sql . '"');
         }
         $result[$wrapped_hint] = $this->{$method}();
     }
     $hints_in_template_sql = $this->_findAndWrapHintsFromTemplateSql();
     foreach ($hints_in_template_sql as $hint) {
         if (!isset($result[$hint])) {
             $result[$hint] = "";
         }
     }
     return $result;
 }
 function _createDataSet()
 {
     if (!$this->class_path) {
         throw new lmbException('Class path is not defined!');
     }
     $class_path = new lmbClassPath($this->class_path);
     $class_path->import();
     $class_name = $class_path->getClassName();
     if (is_null($this->record_id) && is_null($this->record_ids)) {
         if (!$this->find) {
             return lmbActiveRecord::find($class_name);
         } else {
             $method = 'find' . lmb_camel_case($this->find);
             $callback = array($class_name, $method);
             if (!is_callable($callback)) {
                 throw new lmbException('Active record of class "' . $class_name . '" does not support method "' . $method . '"');
             }
             return call_user_func_array($callback, $this->find_params);
         }
     }
     if ($this->record_id) {
         try {
             if ($this->find) {
                 $method = 'find' . lmb_camel_case($this->find);
                 $callback = array($class_name, $method);
                 if (!is_callable($callback)) {
                     throw new lmbException('Active record of class "' . $class_name . '" does not support method "' . $method . '"');
                 }
                 $record = call_user_func_array($callback, array($this->record_id));
             } else {
                 $record = lmbActiveRecord::findById($class_name, $this->record_id);
             }
         } catch (lmbARNotFoundException $e) {
             $record = array();
         }
         return $this->_singleItemCollection($record);
     } elseif ($this->record_ids) {
         return lmbActiveRecord::findByIds($class_name, $this->record_ids);
     }
     return new lmbCollection();
 }
Example #7
0
 protected function _mapActionToMethod($action)
 {
     return lmb_camel_case('do_' . $action);
 }
Example #8
0
 protected function _mapPropertyToSetMethod($property)
 {
     $method = 'set' . lmb_camel_case($property);
     if ($method !== 'set' && method_exists($this, $method)) {
         return $method;
     }
 }
Example #9
0
 protected function _mapPropertyToSetMethod($property)
 {
     $this->_ensureSignatures();
     $method = 'set' . lmb_camel_case($property);
     if (isset($this->_tools_signatures[$method])) {
         return $method;
     }
 }
Example #10
0
 static function actionToMethod($name)
 {
     return lmb_camel_case(self::sanitizeName($name));
 }
 static function getLmbRule($underscored_name)
 {
     if (isset(self::$rules_shortcuts[$underscored_name])) {
         $underscored_name = self::$rules_shortcuts[$underscored_name];
     }
     return 'lmb' . lmb_camel_case($underscored_name) . 'Rule.class.php';
 }
 function _processDispatchResult(&$dispatched)
 {
     if (isset($dispatched['controller'])) {
         $dispatched['controller'] = lmb_camel_case($dispatched['controller']);
     }
 }
 function testCamelCaseWithNumbers()
 {
     $this->assertEqual(lmb_camel_case('foo_0'), 'Foo_0');
     $this->assertEqual(lmb_camel_case('foo_1_bar'), 'Foo_1Bar');
 }
Example #14
0
 protected function _mapTableNameToClass($table_name)
 {
     return lmb_camel_case($table_name);
 }
Example #15
0
 /**
  *  Maps property name to "addTo" form, e.g. "property_name" => "addToPropertyName"
  *  @param string
  *  @return string
  */
 function mapPropertyToAddToMethod($property)
 {
     return 'addTo' . lmb_camel_case($property);
 }
 function _formRelationManyToMany($local_table, $relation_table)
 {
     $local_relation_column_name = $this->_aggrements_resolver->makeRelationColumnNameFromTable($local_table->getName());
     $related_tables = $this->_aggrements_resolver->getManyToManyRelatedTablesFromRelationTable($relation_table);
     $foreign_table = $related_tables[0] == $local_table->getName() ? $this->_db_info->getTable($related_tables[1]) : $this->_db_info->getTable($related_tables[0]);
     return array(lmb_plural($foreign_table->getName()) => array('field' => $local_relation_column_name, 'foreign_field' => $this->_aggrements_resolver->makeRelationColumnNameFromTable($foreign_table), 'table' => $relation_table->getName(), 'class' => lmb_camel_case($foreign_table->getName())));
 }
Example #17
0
 function createController($controller_name)
 {
     $class_name = lmb_camel_case($controller_name) . 'Controller';
     if (!class_exists($class_name)) {
         $file = $this->toolkit->findFileByAlias("{$class_name}.class.php", lmb_env_get('LIMB_CONTROLLERS_INCLUDE_PATH'), 'controller');
         lmb_require($file);
     }
     return new $class_name();
 }
 protected function _getClass($template)
 {
     return str_replace('%', lmb_camel_case($this->driver), $template);
 }