Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update related AbstractElements and allow to clear caches after popul…
…ation (#64) * Allow to index related AbstractElements and allow to clear caches after population * Fix infinite loop * Correct handling of auto save * phpstan and php-cs-fixer * Allow to filter related objects by event * revert changes and implemented event listener system instead * allow to supress events * re-evaluation of stopping event propagation * removed php stan baseline * php-cs-fixer * removed invalid negation * remove int backing and sort enums + corresponding match statements * rename boolean variables for readability --------- Co-authored-by: Linus Metzler <linus.metzler@cec.valantic.com>
- Loading branch information
Showing
13 changed files
with
207 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Valantic\ElasticaBridgeBundle\Enum; | ||
|
||
enum ElementInIndexOperation | ||
{ | ||
case INSERT; | ||
case UPDATE; | ||
case DELETE; | ||
case NOTHING; | ||
} |
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
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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Valantic\ElasticaBridgeBundle\Model\Event; | ||
|
||
interface ElasticaBridgeEvents | ||
{ | ||
public const PRE_REFRESH_ELEMENT = 'valantic.elastica_bridge.pre_refreshed_element'; | ||
public const POST_REFRESH_ELEMENT = 'valantic.elastica_bridge.post_refreshed_element'; | ||
public const PRE_REFRESH_ELEMENT_IN_INDEX = 'valantic.elastica_bridge.pre_refreshed_element_in_index'; | ||
public const POST_REFRESH_ELEMENT_IN_INDEX = 'valantic.elastica_bridge.post_refreshed_element_in_index'; | ||
} |
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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Valantic\ElasticaBridgeBundle\Model\Event; | ||
|
||
use Pimcore\Model\Element\AbstractElement; | ||
use Symfony\Contracts\EventDispatcher\Event; | ||
use Valantic\ElasticaBridgeBundle\Index\IndexInterface; | ||
|
||
class RefreshedElementEvent extends Event | ||
{ | ||
/** | ||
* @param array<IndexInterface> $indices | ||
*/ | ||
public function __construct( | ||
private readonly AbstractElement $element, | ||
private readonly array $indices, | ||
) {} | ||
|
||
public function getElement(): AbstractElement | ||
{ | ||
return $this->element; | ||
} | ||
|
||
/** | ||
* @return array<IndexInterface> | ||
*/ | ||
public function getIndices(): array | ||
{ | ||
return $this->indices; | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Valantic\ElasticaBridgeBundle\Model\Event; | ||
|
||
use Elastica\Index; | ||
use Pimcore\Model\Element\AbstractElement; | ||
use Symfony\Contracts\EventDispatcher\Event; | ||
use Valantic\ElasticaBridgeBundle\Enum\ElementInIndexOperation; | ||
use Valantic\ElasticaBridgeBundle\Index\IndexInterface; | ||
|
||
class RefreshedElementInIndexEvent extends Event | ||
{ | ||
public function __construct( | ||
public readonly AbstractElement $element, | ||
public readonly IndexInterface $index, | ||
public readonly Index $elasticaIndex, | ||
public readonly ElementInIndexOperation $operation, | ||
) {} | ||
|
||
public function getElement(): AbstractElement | ||
{ | ||
return $this->element; | ||
} | ||
|
||
public function getIndex(): IndexInterface | ||
{ | ||
return $this->index; | ||
} | ||
|
||
public function getElasticaIndex(): Index | ||
{ | ||
return $this->elasticaIndex; | ||
} | ||
|
||
public function getOperation(): ElementInIndexOperation | ||
{ | ||
return $this->operation; | ||
} | ||
} |
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