Code Duplication    Length = 34-34 lines in 5 locations

src/cli/Database/Base/Channel.php 1 location

@@ 600-633 (lines=34) @@
597
     * @throws PropelException
598
     * @see doSave()
599
     */
600
    public function save(ConnectionInterface $con = null)
601
    {
602
        if ($this->isDeleted()) {
603
            throw new PropelException("You cannot save an object that has been deleted.");
604
        }
605
606
        if ($con === null) {
607
            $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME);
608
        }
609
610
        return $con->transaction(function () use ($con) {
611
            $isInsert = $this->isNew();
612
            $ret = $this->preSave($con);
613
            if ($isInsert) {
614
                $ret = $ret && $this->preInsert($con);
615
            } else {
616
                $ret = $ret && $this->preUpdate($con);
617
            }
618
            if ($ret) {
619
                $affectedRows = $this->doSave($con);
620
                if ($isInsert) {
621
                    $this->postInsert($con);
622
                } else {
623
                    $this->postUpdate($con);
624
                }
625
                $this->postSave($con);
626
                ChannelTableMap::addInstanceToPool($this);
627
            } else {
628
                $affectedRows = 0;
629
            }
630
631
            return $affectedRows;
632
        });
633
    }
634
635
    /**
636
     * Performs the work of inserting or updating the row in the database.

src/cli/Database/Base/Connection.php 1 location

@@ 728-761 (lines=34) @@
725
     * @throws PropelException
726
     * @see doSave()
727
     */
728
    public function save(ConnectionInterface $con = null)
729
    {
730
        if ($this->isDeleted()) {
731
            throw new PropelException("You cannot save an object that has been deleted.");
732
        }
733
734
        if ($con === null) {
735
            $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME);
736
        }
737
738
        return $con->transaction(function () use ($con) {
739
            $isInsert = $this->isNew();
740
            $ret = $this->preSave($con);
741
            if ($isInsert) {
742
                $ret = $ret && $this->preInsert($con);
743
            } else {
744
                $ret = $ret && $this->preUpdate($con);
745
            }
746
            if ($ret) {
747
                $affectedRows = $this->doSave($con);
748
                if ($isInsert) {
749
                    $this->postInsert($con);
750
                } else {
751
                    $this->postUpdate($con);
752
                }
753
                $this->postSave($con);
754
                ConnectionTableMap::addInstanceToPool($this);
755
            } else {
756
                $affectedRows = 0;
757
            }
758
759
            return $affectedRows;
760
        });
761
    }
762
763
    /**
764
     * Performs the work of inserting or updating the row in the database.

src/cli/Database/Base/Instance.php 1 location

@@ 556-589 (lines=34) @@
553
     * @throws PropelException
554
     * @see doSave()
555
     */
556
    public function save(ConnectionInterface $con = null)
557
    {
558
        if ($this->isDeleted()) {
559
            throw new PropelException("You cannot save an object that has been deleted.");
560
        }
561
562
        if ($con === null) {
563
            $con = Propel::getServiceContainer()->getWriteConnection(InstanceTableMap::DATABASE_NAME);
564
        }
565
566
        return $con->transaction(function () use ($con) {
567
            $isInsert = $this->isNew();
568
            $ret = $this->preSave($con);
569
            if ($isInsert) {
570
                $ret = $ret && $this->preInsert($con);
571
            } else {
572
                $ret = $ret && $this->preUpdate($con);
573
            }
574
            if ($ret) {
575
                $affectedRows = $this->doSave($con);
576
                if ($isInsert) {
577
                    $this->postInsert($con);
578
                } else {
579
                    $this->postUpdate($con);
580
                }
581
                $this->postSave($con);
582
                InstanceTableMap::addInstanceToPool($this);
583
            } else {
584
                $affectedRows = 0;
585
            }
586
587
            return $affectedRows;
588
        });
589
    }
590
591
    /**
592
     * Performs the work of inserting or updating the row in the database.

src/cli/Database/Base/Subscription.php 1 location

@@ 873-906 (lines=34) @@
870
     * @throws PropelException
871
     * @see doSave()
872
     */
873
    public function save(ConnectionInterface $con = null)
874
    {
875
        if ($this->isDeleted()) {
876
            throw new PropelException("You cannot save an object that has been deleted.");
877
        }
878
879
        if ($con === null) {
880
            $con = Propel::getServiceContainer()->getWriteConnection(SubscriptionTableMap::DATABASE_NAME);
881
        }
882
883
        return $con->transaction(function () use ($con) {
884
            $isInsert = $this->isNew();
885
            $ret = $this->preSave($con);
886
            if ($isInsert) {
887
                $ret = $ret && $this->preInsert($con);
888
            } else {
889
                $ret = $ret && $this->preUpdate($con);
890
            }
891
            if ($ret) {
892
                $affectedRows = $this->doSave($con);
893
                if ($isInsert) {
894
                    $this->postInsert($con);
895
                } else {
896
                    $this->postUpdate($con);
897
                }
898
                $this->postSave($con);
899
                SubscriptionTableMap::addInstanceToPool($this);
900
            } else {
901
                $affectedRows = 0;
902
            }
903
904
            return $affectedRows;
905
        });
906
    }
907
908
    /**
909
     * Performs the work of inserting or updating the row in the database.

src/cli/Database/Base/User.php 1 location

@@ 617-650 (lines=34) @@
614
     * @throws PropelException
615
     * @see doSave()
616
     */
617
    public function save(ConnectionInterface $con = null)
618
    {
619
        if ($this->isDeleted()) {
620
            throw new PropelException("You cannot save an object that has been deleted.");
621
        }
622
623
        if ($con === null) {
624
            $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME);
625
        }
626
627
        return $con->transaction(function () use ($con) {
628
            $isInsert = $this->isNew();
629
            $ret = $this->preSave($con);
630
            if ($isInsert) {
631
                $ret = $ret && $this->preInsert($con);
632
            } else {
633
                $ret = $ret && $this->preUpdate($con);
634
            }
635
            if ($ret) {
636
                $affectedRows = $this->doSave($con);
637
                if ($isInsert) {
638
                    $this->postInsert($con);
639
                } else {
640
                    $this->postUpdate($con);
641
                }
642
                $this->postSave($con);
643
                UserTableMap::addInstanceToPool($this);
644
            } else {
645
                $affectedRows = 0;
646
            }
647
648
            return $affectedRows;
649
        });
650
    }
651
652
    /**
653
     * Performs the work of inserting or updating the row in the database.