Skip to content

Commit

Permalink
Merge pull request #37 from YouweGit/cleanup/objectBridgeDataClass
Browse files Browse the repository at this point in the history
[CLEANUP] Object bridge data class
  • Loading branch information
kjkooistra-youwe authored Nov 28, 2019
2 parents 25c577b + 5014a7e commit acd1f5b
Show file tree
Hide file tree
Showing 7 changed files with 459 additions and 448 deletions.
15 changes: 0 additions & 15 deletions Controller/ObjectBridgeController.php

This file was deleted.

3 changes: 1 addition & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('object_bridge');
$treeBuilder = new TreeBuilder('object_bridge');

// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
Expand Down
10 changes: 6 additions & 4 deletions EventListener/CopyEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Pimcore\Event\Model\DataObjectEvent;
use Pimcore\Model\DataObject;
use Pimcore\Model\Element;
use Pimcore\Model\Version;

/**
* Copy event listener
Expand All @@ -32,6 +31,7 @@ public function __construct()
/**
* @param DataObjectEvent $dataObjectEvent
* @return void
* @throws \Exception
*/
public function postCopy(DataObjectEvent $dataObjectEvent): void
{
Expand Down Expand Up @@ -62,7 +62,7 @@ protected function copyObjectBridgeDataObjects(DataObject\Concrete $dataObject,
$bridgeDataObjectsSetter = 'set' . ucfirst($objectBridge->getName());
unset($objectBridge);

if (!method_exists($dataObject, $bridgeDataObjectsGetter) || !method_exists($dataObject, $bridgeDataObjectsGetter)) {
if (!method_exists($dataObject, $bridgeDataObjectsGetter) || !method_exists($dataObject, $bridgeDataObjectsSetter)) {
return;
}

Expand All @@ -81,17 +81,18 @@ protected function copyObjectBridgeDataObjects(DataObject\Concrete $dataObject,
}

/**
* @param DataObject\Concrete $dataObject
* @param string $sourceDataObjectGetter
* @param DataObject\Concrete ...$bridgeDataObjects
* @return DataObject\Concrete[]
* @throws \Exception
*/
protected function copyBridgeDataObjects(
DataObject\Concrete $dataObject,
string $sourceDataObjectGetter,
DataObject\Concrete ...$bridgeDataObjects
): array {
$copiedBridgeDataObjects = [];
$i = 0;
foreach ($bridgeDataObjects as $bridgeDataObject) {
if (!$bridgeDataObject instanceof DataObject\Concrete) {
continue;
Expand Down Expand Up @@ -120,10 +121,11 @@ protected function copyBridgeDataObjects(
* @param DataObject\AbstractObject $target Folder to copy data object to
* @param DataObject\Concrete $source Data object to copy
* @return DataObject\Concrete
*
* @throws \Exception
*/
protected function copyAsChild(DataObject\AbstractObject $target, DataObject\Concrete $source): DataObject\Concrete
{
/* @var $new DataObject\Concrete */
$new = Element\Service::cloneMe($source);
$new->setId(null);

Expand Down
Loading

0 comments on commit acd1f5b

Please sign in to comment.