Skip to content

Instantly share code, notes, and snippets.

@slave2zeros
Created November 23, 2015 19:52
Show Gist options
  • Save slave2zeros/6662cde158662f001b65 to your computer and use it in GitHub Desktop.
Save slave2zeros/6662cde158662f001b65 to your computer and use it in GitHub Desktop.
RYANs-iMac:website rgallagher$ git diff
diff --git a/src/Eduguide/GoalBundle/Traits/Controller/GoalAuthoring.php b/src/Eduguide/GoalBundle/Traits/Controller/GoalAuthoring.php
index 95bc879..85ff3bb 100644
--- a/src/Eduguide/GoalBundle/Traits/Controller/GoalAuthoring.php
+++ b/src/Eduguide/GoalBundle/Traits/Controller/GoalAuthoring.php
@@ -286,7 +286,25 @@ trait GoalAuthoring
$activityAssociation->setEntityId($entity->getId());
$activityAssociation->setActivityEntity($entity);
- $newActivity = $clone ? clone $activity : $activity;
+ /*
+ * Activity::__clone() removes steps because we have an ActivityCloner service.
+ * That service works with ActivityAssociations.
+ * So here we need to do a bit more work.
+ */
+ if ($clone) {
+ $steps = $activity->getSteps();
+ $newActivity = clone $activity;
+
+ /** @var Step $step */
+ foreach ($steps as $step) {
+ $newStep = clone $step;
+ $newStep->setActivity($newActivity);
+ $newActivity->addStep($newStep);
+ }
+ } else {
+ $newActivity = $activity;
+ }
+
$newActivity->setParent($activity);
$activityAssociation->setActivity($newActivity);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment