-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Bidirectional Relationships convenience method (#161)
* Fix Key::resolveParentKey traversal process * add customFormat method to Field class * add Bidirectional trait * Apply Bidirectional trait to Relationship, PostObject, Taxonomy, and User fields * add Bidirectional documentation to README * remove remnant of previous open PR * fix: order traits * chore: update bidirectional comment * chore: sort imports * docs: updated bidirectional * docs: bidirectional * docs: update order --------- Co-authored-by: Vincent Klaiber <[email protected]>
- Loading branch information
1 parent
fd50308
commit a910468
Showing
6 changed files
with
64 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright (c) Vincent Klaiber | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @see https://github.com/vinkla/extended-acf | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Extended\ACF\Fields\Settings; | ||
|
||
trait Bidirectional | ||
{ | ||
/** | ||
* Create a bidirectional relationship between two or more fields. This requires setting a custom key for each | ||
* related field using the `key` method and passing the keys of those related fields to this method. | ||
* @see https://www.advancedcustomfields.com/resources/bidirectional-relationships/ | ||
*/ | ||
public function bidirectional(array|string $keys): static | ||
{ | ||
$this->settings['bidirectional'] = 1; | ||
$this->settings['bidirectional_target'] = is_array($keys) ? $keys : [$keys]; | ||
|
||
return $this; | ||
} | ||
} |
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