Skip to content
Permalink
Browse files

BUG Fix php schema generation

  • Loading branch information
Christopher Joe
Christopher Joe committed Nov 2, 2016
1 parent 67f0030 commit 0901de2995686a315a279969d85e1743763b708e
Showing with 8 additions and 9 deletions.
  1. +1 −1 src/Assets/File.php
  2. +6 −8 src/Forms/FormField.php
  3. +1 −0 src/ORM/Versioning/ChangeSet.php
@@ -114,7 +114,7 @@ class File extends DataObject implements ShortcodeHandler, AssetContainer, Thumb
private static $db = array(
"Name" => "Varchar(255)",
"Title" => "Varchar(255)",
"File" =>"DBFile",
"File" => "DBFile",
// Only applies to files, doesn't inherit for folder
'ShowInSearch' => 'Boolean(1)',
);
@@ -1412,9 +1412,7 @@ public function getSchemaComponent() {
* @todo Add deep merging of arrays like `data` and `attributes`.
*/
public function setSchemaData($schemaData = []) {
$current = $this->getSchemaData();
$this->schemaData = array_merge($current, array_intersect_key($schemaData, $current));
$this->schemaData = array_merge($this->schemaData, $schemaData);
return $this;
}
@@ -1424,7 +1422,8 @@ public function setSchemaData($schemaData = []) {
* @return array
*/
public function getSchemaData() {
return array_replace_recursive($this->getSchemaDataDefaults(), $this->schemaData);
$defaults = $this->getSchemaDataDefaults();
return array_replace_recursive($defaults, array_intersect_key($this->schemaData, $defaults));
}
/**
@@ -1477,9 +1476,7 @@ public function getSchemaDataDefaults() {
* @todo Add deep merging of arrays like `data` and `attributes`.
*/
public function setSchemaState($schemaState = []) {
$current = $this->getSchemaState();
$this->schemaState = array_merge($current, array_intersect_key($schemaState, $current));
$this->schemaState = array_merge($this->schemaState, array_intersect_key($schemaState, $this->schemaState));
return $this;
}
@@ -1489,7 +1486,8 @@ public function setSchemaState($schemaState = []) {
* @return array
*/
public function getSchemaState() {
return array_merge($this->getSchemaStateDefaults(), $this->schemaState);
$defaults = $this->getSchemaStateDefaults();
return array_merge($defaults, array_intersect_key($this->schemaState, $defaults));
}
/**
@@ -399,6 +399,7 @@ public function getCMSFields() {
if ($this->isInDB()) {
$fields->addFieldToTab('Root.Main', ReadonlyField::create('State', $this->fieldLabel('State')));
}
$this->extend('updateCMSFields', $fields);
return $fields;
}

0 comments on commit 0901de2

Please sign in to comment.
You can’t perform that action at this time.