mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1639 from open-sausages/pulls/4.0/many-many-through
API Update for DataObjectSchema changes
This commit is contained in:
commit
ae9e05c99d
@ -8,6 +8,7 @@ use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Object;
|
||||
use SilverStripe\Forms\DateField;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\Versioning\Versioned;
|
||||
|
||||
@ -212,8 +213,9 @@ abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFil
|
||||
break;
|
||||
|
||||
default:
|
||||
if($sng->hasDatabaseField($name)) {
|
||||
$filter = $sng->dbObject($name)->defaultSearchFilter();
|
||||
$field = $sng->dbObject($name);
|
||||
if($field) {
|
||||
$filter = $field->defaultSearchFilter();
|
||||
$filter->setValue($val);
|
||||
$query = $query->alterDataQuery(array($filter, 'apply'));
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace SilverStripe\CMS\Model;
|
||||
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
use SilverStripe\ORM\ManyManyList;
|
||||
use SilverStripe\ORM\Versioning\Versioned;
|
||||
@ -168,7 +169,10 @@ class SiteTreeLinkTracking extends DataExtension {
|
||||
}
|
||||
|
||||
// Update the "LinkTracking" many_many
|
||||
if($record->ID && $record->manyManyComponent('LinkTracking') && ($tracker = $record->LinkTracking())) {
|
||||
if($record->ID
|
||||
&& $record->getSchema()->manyManyComponent(get_class($record), 'LinkTracking')
|
||||
&& ($tracker = $record->LinkTracking())
|
||||
) {
|
||||
$tracker->removeByFilter(array(
|
||||
sprintf('"FieldName" = ? AND "%s" = ?', $tracker->getForeignKey())
|
||||
=> array($fieldName, $record->ID)
|
||||
@ -180,7 +184,10 @@ class SiteTreeLinkTracking extends DataExtension {
|
||||
}
|
||||
|
||||
// Update the "ImageTracking" many_many
|
||||
if($record->ID && $record->manyManyComponent('ImageTracking') && ($tracker = $record->ImageTracking())) {
|
||||
if($record->ID
|
||||
&& $record->getSchema()->manyManyComponent(get_class($record), 'ImageTracking')
|
||||
&& ($tracker = $record->ImageTracking())
|
||||
) {
|
||||
$tracker->removeByFilter(array(
|
||||
sprintf('"FieldName" = ? AND "%s" = ?', $tracker->getForeignKey())
|
||||
=> array($fieldName, $record->ID)
|
||||
@ -208,7 +215,7 @@ class SiteTreeLinkTracking extends DataExtension {
|
||||
$this->owner->HasBrokenFile = false;
|
||||
|
||||
// Build a list of HTMLText fields
|
||||
$allFields = $this->owner->db();
|
||||
$allFields = DataObject::getSchema()->fieldSpecs($this->owner);
|
||||
$htmlFields = array();
|
||||
foreach($allFields as $field => $fieldSpec) {
|
||||
$fieldObj = $this->owner->dbObject($field);
|
||||
|
@ -87,7 +87,7 @@ class VirtualPage extends Page {
|
||||
}
|
||||
|
||||
// Diff db with non-virtual fields
|
||||
$fields = array_keys($record->db());
|
||||
$fields = array_keys(static::getSchema()->fieldSpecs($record));
|
||||
$nonVirtualFields = $this->getNonVirtualisedFields();
|
||||
return array_diff($fields, $nonVirtualFields);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user