Merge pull request #499 from romainneutron/fix-1309

[3.8] Fix #1309 : Stories can not be removed
This commit is contained in:
Romain Neutron
2013-07-11 15:27:55 -07:00
3 changed files with 8 additions and 8 deletions

View File

@@ -218,14 +218,14 @@ class Records implements ControllerProviderInterface
$deleted[] = $element->getRecord($app)->get_serialize_key(); $deleted[] = $element->getRecord($app)->get_serialize_key();
} }
$attachedStories = $StoryWZRepository->findByRecord($record); $attachedStories = $StoryWZRepository->findByRecord($app, $record);
foreach ($attachedStories as $attachedStory) { foreach ($attachedStories as $attachedStory) {
$app['EM']->remove($attachedStory); $app['EM']->remove($attachedStory);
} }
$record->delete();
$deleted[] = $record->get_serialize_key(); $deleted[] = $record->get_serialize_key();
$record->delete();
} catch (\Exception $e) { } catch (\Exception $e) {
} }

View File

@@ -107,7 +107,7 @@ class StoryWZRepository extends EntityRepository
return $story; return $story;
} }
public function findByRecord(\record_adapter $Story) public function findByRecord(Application $app, \record_adapter $Story)
{ {
$dql = 'SELECT s FROM Entities\StoryWZ s WHERE s.sbas_id = :sbas_id $dql = 'SELECT s FROM Entities\StoryWZ s WHERE s.sbas_id = :sbas_id
AND s.record_id = :record_id'; AND s.record_id = :record_id';
@@ -122,7 +122,7 @@ class StoryWZRepository extends EntityRepository
foreach ($stories as $key => $story) { foreach ($stories as $key => $story) {
try { try {
$record = $story->getRecord(); $record = $story->getRecord($app);
} catch (NotFoundHttpException $e) { } catch (NotFoundHttpException $e) {
$this->getEntityManager()->remove($story); $this->getEntityManager()->remove($story);
$this->getEntityManager()->flush(); $this->getEntityManager()->flush();
@@ -133,7 +133,7 @@ class StoryWZRepository extends EntityRepository
return $stories; return $stories;
} }
public function findByDatabox(\databox $databox) public function findByDatabox(Application $app, \databox $databox)
{ {
$dql = 'SELECT s FROM Entities\StoryWZ s WHERE s.sbas_id = :sbas_id'; $dql = 'SELECT s FROM Entities\StoryWZ s WHERE s.sbas_id = :sbas_id';
@@ -146,7 +146,7 @@ class StoryWZRepository extends EntityRepository
foreach ($stories as $key => $story) { foreach ($stories as $key => $story) {
try { try {
$record = $story->getRecord(); $record = $story->getRecord($app);
} catch (NotFoundHttpException $e) { } catch (NotFoundHttpException $e) {
$this->getEntityManager()->remove($story); $this->getEntityManager()->remove($story);
$this->getEntityManager()->flush(); $this->getEntityManager()->flush();

View File

@@ -452,7 +452,7 @@ class databox extends base
$n+=50; $n+=50;
} }
foreach ($this->app['EM']->getRepository('\Entities\StoryWZ')->findByDatabox($this) as $story) { foreach ($this->app['EM']->getRepository('\Entities\StoryWZ')->findByDatabox($this->app, $this) as $story) {
$this->app['EM']->remove($story); $this->app['EM']->remove($story);
} }