-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #2980702 by bojanz: Allow conditions to optionally be aware of …
…the parent entity
- Loading branch information
Showing
8 changed files
with
107 additions
and
7 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
26 changes: 26 additions & 0 deletions
26
src/Plugin/Commerce/Condition/ParentEntityAwareInterface.php
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,26 @@ | ||
<?php | ||
|
||
namespace Drupal\commerce\Plugin\Commerce\Condition; | ||
|
||
use Drupal\Core\Entity\EntityInterface; | ||
|
||
/** | ||
* Defines the interface for conditions that depend on the parent entity. | ||
* | ||
* For example, an order condition needing access to the parent promotion. | ||
* | ||
* @see \Drupal\commerce\Plugin\Commerce\Condition\ParentEntityAwareTrait | ||
*/ | ||
interface ParentEntityAwareInterface { | ||
|
||
/** | ||
* Sets the parent entity. | ||
* | ||
* @param \Drupal\Core\Entity\EntityInterface $parent_entity | ||
* The parent entity. | ||
* | ||
* @return $this | ||
*/ | ||
public function setParentEntity(EntityInterface $parent_entity); | ||
|
||
} |
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 | ||
|
||
namespace Drupal\commerce\Plugin\Commerce\Condition; | ||
|
||
use Drupal\Core\Entity\EntityInterface; | ||
|
||
/** | ||
* Provides a trait for implementing ParentEntityAwareInterface. | ||
*/ | ||
trait ParentEntityAwareTrait { | ||
|
||
/** | ||
* The parent entity. | ||
* | ||
* @var \Drupal\Core\Entity\EntityInterface | ||
*/ | ||
protected $parentEntity; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setParentEntity(EntityInterface $parent_entity) { | ||
$this->parentEntity = $parent_entity; | ||
return $this; | ||
} | ||
|
||
} |