Permalink
Browse files

(minor) defaults for empty arrays, minor streamlining

  • Loading branch information...
1 parent 78cdc7a commit db8aa6fa82afc77b6881ee47814a0af47156e7d7 Bogdan Stancescu committed Mar 6, 2012
Showing with 16 additions and 15 deletions.
  1. +16 −15 include/classes/LPC_Object.php
@@ -1937,34 +1937,35 @@ function poreDataStructure()
{
$myClass=get_class($this);
// Default ID field
- if (empty($this->dataStructure['id_field'])) {
+ if (empty($this->dataStructure['id_field']))
$this->dataStructure['id_field']='id';
- }
- if (empty($this->dataStructure['table_name'])) {
+
+ if (empty($this->dataStructure['table_name']))
throw new RuntimeException("Malformed data structure: no table specified! (array key 'table_name' in \$dataStructure)");
- }
+
+ // Fill in default values for optional stuff
+ if (!isset($this->dataStructure['files']))
+ $this->dataStructure['files']=array();
+ if (!isset($this->dataStructure['depend']))
+ $this->dataStructure['depend']=array();
+
// We'll start by filling in the default field name for attributes
// which don't define it explicitly
$fields=$this->dataStructure['fields'];
$allFlags=array('NULL','sqlDate','forceSave','noLogging','trim');
foreach($fields as $attName=>$dataDef) {
- if (empty($fields[$attName]['fld_name'])) {
+ if (empty($fields[$attName]['fld_name']))
$fields[$attName]['fld_name']=$attName;
- }
- if (!isset($fields[$attName]['flags'])) {
+
+ if (!isset($fields[$attName]['flags']))
$fields[$attName]['flags']=array();
- }
- foreach($allFlags as $flag1) {
- if (!isset($fields[$attName]['flags'][$flag1])) {
+
+ foreach($allFlags as $flag1)
+ if (!isset($fields[$attName]['flags'][$flag1]))
$fields[$attName]['flags'][$flag1]=false;
- }
- }
}
$this->dataStructure['fields']=$fields;
- if (!isset($this->dataStructure['depend'])) {
- $this->dataStructure['depend']=array();
- }
// Now we need to work on the dependencies. But first let's read in
// the foreign dependencies, if any.
$foreignDeps=LPC_Foreign_dependency_manager::getDependencies($myClass);

0 comments on commit db8aa6f

Please sign in to comment.