-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15400 from craftcms/feature/cms-1318-relation-fie…
…ld-improvements Relation field improvements
- Loading branch information
Showing
15 changed files
with
417 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* @link https://craftcms.com/ | ||
* @copyright Copyright (c) Pixel & Tonic, Inc. | ||
* @license https://craftcms.github.io/license/ | ||
*/ | ||
|
||
namespace craft\base; | ||
|
||
/** | ||
* RelationalFieldInterface defines the common interface to be implemented by field classes | ||
* which can store relation data. | ||
* | ||
* @author Pixel & Tonic, Inc. <support@pixelandtonic.com> | ||
* @since 5.3.0 | ||
*/ | ||
interface RelationalFieldInterface extends FieldInterface | ||
{ | ||
/** | ||
* Returns whether relations stored for the field should include the source element’s site ID. | ||
* | ||
* Note that this must be consistent across all instances of the same field. | ||
* | ||
* @return bool | ||
*/ | ||
public function localizeRelations(): bool; | ||
|
||
/** | ||
* Returns whether relations should be updated for the field. | ||
* | ||
* @param ElementInterface $element | ||
* @return bool | ||
*/ | ||
public function forceUpdateRelations(ElementInterface $element): bool; | ||
|
||
/** | ||
* Returns the related element IDs for this field. | ||
* | ||
* @param ElementInterface $element | ||
* @return int[] | ||
*/ | ||
public function getRelationTargetIds(ElementInterface $element): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
/** | ||
* @link https://craftcms.com/ | ||
* @copyright Copyright (c) Pixel & Tonic, Inc. | ||
* @license https://craftcms.github.io/license/ | ||
*/ | ||
|
||
namespace craft\base; | ||
|
||
/** | ||
* RelationalFieldTrait provides a base implementation for [[RelationalFieldInterface]]. | ||
* | ||
* @author Pixel & Tonic, Inc. <support@pixelandtonic.com> | ||
* @since 5.3.0 | ||
*/ | ||
trait RelationalFieldTrait | ||
{ | ||
public function localizeRelations(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public function forceUpdateRelations(ElementInterface $element): bool | ||
{ | ||
return false; | ||
} | ||
} |
Oops, something went wrong.