src/Bidcoz/Bundle/CoreBundle/Entity/Campaign.php line 50

Open in your IDE?
  1. <?php
  2. namespace Bidcoz\Bundle\CoreBundle\Entity;
  3. use Bidcoz\Bundle\CoreBundle\Constants;
  4. use Bidcoz\Bundle\CoreBundle\Entity\Auction\Auction;
  5. use Bidcoz\Bundle\CoreBundle\Entity\Auction\BidNumber;
  6. use Bidcoz\Bundle\CoreBundle\Entity\Auction\FundANeed;
  7. use Bidcoz\Bundle\CoreBundle\Entity\Auction\Shop;
  8. use Bidcoz\Bundle\CoreBundle\Entity\Contact\CampaignDetail;
  9. use Bidcoz\Bundle\CoreBundle\Entity\Donation\CashDonation;
  10. use Bidcoz\Bundle\CoreBundle\Entity\Donation\CryptoWallet;
  11. use Bidcoz\Bundle\CoreBundle\Entity\Donation\DonationLevel;
  12. use Bidcoz\Bundle\CoreBundle\Entity\Donation\MembershipLevel;
  13. use Bidcoz\Bundle\CoreBundle\Entity\Procurement\Item;
  14. use Bidcoz\Bundle\CoreBundle\Entity\Purchase\Donation\PaddleRaiseDonationPurchase;
  15. use Bidcoz\Bundle\CoreBundle\Entity\Purchase\Purchase;
  16. use Bidcoz\Bundle\CoreBundle\Entity\Raffle\RaffleType;
  17. use Bidcoz\Bundle\CoreBundle\Entity\Registration\Registration;
  18. use Bidcoz\Bundle\CoreBundle\Entity\Registration\RegistrationType;
  19. use Bidcoz\Bundle\CoreBundle\Entity\Sponsorship\Sponsorship;
  20. use Bidcoz\Bundle\CoreBundle\Entity\Sponsorship\SponsorshipLevel;
  21. use Bidcoz\Bundle\CoreBundle\Entity\Ticket\SeatingChartImage;
  22. use Bidcoz\Bundle\CoreBundle\Entity\Ticket\Ticket;
  23. use Bidcoz\Bundle\CoreBundle\Entity\Ticket\TicketGroup;
  24. use Bidcoz\Bundle\CoreBundle\Entity\Ticket\TicketType;
  25. use Bidcoz\Bundle\CoreBundle\Entity\Transaction\Transaction;
  26. use Bidcoz\Bundle\CoreBundle\ObjectChange\ObjectChangeTrackable;
  27. use DateTime;
  28. use Doctrine\Common\Collections\ArrayCollection;
  29. use Doctrine\Common\Collections\Collection;
  30. use Doctrine\Inflector\InflectorFactory;
  31. use Doctrine\ORM\Event\PreFlushEventArgs;
  32. use Doctrine\ORM\Mapping as ORM;
  33. use JMS\Serializer\Annotation as Serialize;
  34. use Symfony\Component\Validator\Constraints as Assert;
  35. use Symfony\Component\Validator\Context\ExecutionContextInterface;
  36. /**
  37.  * @ORM\Entity(repositoryClass="CampaignRepository")
  38.  * @ORM\Table(
  39.  *      name="campaigns",
  40.  *      uniqueConstraints={
  41.  *          @ORM\UniqueConstraint(name="campaign_slug_org_id_uk",columns={"slug", "organization_id"})
  42.  *      },
  43.  * )
  44.  * @ORM\HasLifecycleCallbacks()
  45.  * @Serialize\ExclusionPolicy("all")
  46.  */
  47. class Campaign implements ThemeableObjectChangeTrackable
  48. {
  49.     public const FEE_USER         'user';
  50.     public const FEE_ORGANIZATION 'organization';
  51.     public const FEE_CHOICE       'choice';
  52.     public const TICKET_TYPE_GENERAL_ADMISSION 'general';
  53.     public const TICKET_TYPE_ASSIGNED          'assigned';
  54.     // const TICKET_TYPE_RESERVED          = 'reserved';
  55.     public const DEFAULT_TIMEZONE 'America/Chicago';
  56.     /**
  57.      * List of all available components
  58.      * keys names must be an underscore version
  59.      * of a Campaign's component property name without 'has_' prefix
  60.      * e.g. hasItemDonations --> item_donations.
  61.      *
  62.      * @var array
  63.      */
  64.     private static $components = [
  65.         'auction'        => 'Auction',
  66.         'sponsorship'    => 'Sponsor Ads',
  67.         'cash_donations' => 'Donation Booster',
  68.         'fund_drive'     => 'Appeal',
  69.         'procurement'    => 'Procurement',
  70.         'tickets'        => 'Tickets',
  71.         'registrations'  => 'Registrations',
  72.         'paddle_raise'   => 'Paddle Raise',
  73.         //TODO: Keep legacy name 'volunteers'.
  74.         //Needs proper refactoring. Used for Campaign::hasVolunteers in code and templates.
  75.         'volunteers'     => 'Crewup',
  76.     ];
  77.     public static function getComponentsList()
  78.     {
  79.         return self::$components;
  80.     }
  81.     /**
  82.      * @ORM\Id
  83.      * @ORM\Column(name="id", type="integer")
  84.      * @ORM\GeneratedValue(strategy="AUTO")
  85.      * @Serialize\Expose
  86.      * @Serialize\Groups({"Default", "API"})
  87.      */
  88.     protected ?int $id null;
  89.     /**
  90.      * @ORM\Column(name="name", type="text")
  91.      * @Assert\NotBlank
  92.      * @Serialize\Expose
  93.      * @Serialize\Groups({"Default", "API"})
  94.      */
  95.     protected $name;
  96.     /**
  97.      * @ORM\Column(name="slug", type="string", length=50);
  98.      * @Assert\NotBlank(message="Campaign URL is required")
  99.      * @Assert\Regex(pattern="/^[0-9a-z-]+$/", message="Campaign URL can only container lower-case letters, numbers and dashes")
  100.      * @Serialize\Expose
  101.      * @Serialize\Groups({"Default", "API"})
  102.      */
  103.     protected $slug;
  104.     /**
  105.      * @ORM\ManyToOne(targetEntity="Organization", inversedBy="campaigns")
  106.      * @ORM\JoinColumn(name="organization_id", referencedColumnName="id", onDelete="CASCADE")
  107.      * @Serialize\Expose
  108.      * @Serialize\Groups({"API"})
  109.      */
  110.     protected ?Organization $organization null;
  111.     /**
  112.      * @ORM\Column(name="active", type="boolean");
  113.      */
  114.     protected $active true;
  115.     /**
  116.      * @ORM\Column(name="description", type="text", nullable=true)
  117.      */
  118.     protected $description;
  119.     /**
  120.      * @ORM\Column(name="service_fee_type", type="text", length=20);
  121.      */
  122.     protected $feeType self::FEE_USER;
  123.     /**
  124.      * @ORM\Column(name="transaction_fee_passthrough", type="boolean", options={"default" : 0})
  125.      * @Serialize\Expose
  126.      */
  127.     protected $transactionFeePassthrough false;
  128.     /**
  129.      * @ORM\Column(name="collect_cc_info", type="boolean", options={"default" : 1})
  130.      * @Serialize\Expose
  131.      */
  132.     protected $collectCcInfo true;
  133.     /**
  134.      * @ORM\Column(name="details_title", type="text", nullable=true);
  135.      */
  136.     protected $detailsTitle;
  137.     /**
  138.      * @ORM\Column(name="details_body", type="text", nullable=true);
  139.      */
  140.     protected $detailsBody;
  141.     /**
  142.      * @ORM\Column(name="homepage_content", type="text", nullable=true);
  143.      */
  144.     protected $homepageContent;
  145.     /**
  146.      * @ORM\Embedded(class="VideoEmbed", columnPrefix="video_")
  147.      */
  148.     protected $video;
  149.     /**
  150.      * @ORM\Column(name="has_auction", type="boolean")
  151.      * @Serialize\Expose
  152.      */
  153.     protected $hasAuction false;
  154.     /**
  155.      * @ORM\Column(name="has_shop", type="boolean")
  156.      * @Serialize\Expose
  157.      */
  158.     protected $hasShop false;
  159.     /**
  160.      * @ORM\Column(name="has_fund_a_need", type="boolean")
  161.      * @Serialize\Expose
  162.      */
  163.     protected $hasFundANeed false;
  164.     /**
  165.      * @ORM\OneToOne(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Auction\Auction", mappedBy="campaign", orphanRemoval=true, cascade={"persist"})
  166.      */
  167.     protected ?Auction $auction null;
  168.     /**
  169.      * @ORM\OneToOne(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Auction\Shop", mappedBy="campaign", orphanRemoval=true, cascade={"persist"})
  170.      */
  171.     protected ?Shop $shop null;
  172.     /**
  173.      * @ORM\OneToOne(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Auction\FundANeed", mappedBy="campaign", orphanRemoval=true, cascade={"persist"})
  174.      */
  175.     protected ?FundANeed $fundANeed null;
  176.     /**
  177.      * @ORM\Column(name="has_sponsorship", type="boolean")
  178.      * @Assert\NotNull
  179.      */
  180.     protected $hasSponsorship false;
  181.     /**
  182.      * @ORM\Column(name="sponsorship_signup", type="boolean")
  183.      * @Assert\NotNull
  184.      */
  185.     protected $sponsorshipSignup true;
  186.     /**
  187.      * @var Collection|Sponsorship[]|null
  188.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Sponsorship\Sponsorship", mappedBy="campaign", orphanRemoval=true, cascade={"persist"})
  189.      */
  190.     protected ?Collection $sponsorships null;
  191.     /**
  192.      * @var Collection|SponsorshipLevel[]|null
  193.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Sponsorship\SponsorshipLevel", mappedBy="campaign", orphanRemoval=true, cascade={"persist"})
  194.      */
  195.     protected ?Collection $sponsorshipLevels null;
  196.     /**
  197.      * @ORM\Column(name="has_tickets", type="boolean")
  198.      * @Assert\NotNull
  199.      */
  200.     protected $hasTickets false;
  201.     /**
  202.      * @ORM\Column(name="self_check_in_date", type="datetime", nullable=true)
  203.      */
  204.     protected $selfCheckInDate;
  205.     /**
  206.      * @ORM\Column(name="ticket_type", type="string", length=8)
  207.      */
  208.     protected $ticketType self::TICKET_TYPE_GENERAL_ADMISSION;
  209.     /**
  210.      * @var Collection|SeatingChartImage[]|null
  211.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Ticket\SeatingChartImage", mappedBy="campaign", orphanRemoval=true, cascade={"persist"})
  212.      * @Serialize\Expose
  213.      */
  214.     protected ?Collection $seatingChartImages null;
  215.     /**
  216.      * @ORM\Column(name="ticket_quantity", type="integer", nullable=true);
  217.      * @Assert\NotNull
  218.      * @Assert\Range(min=0)
  219.      */
  220.     protected $ticketQuantity 0;
  221.     /**
  222.      * @ORM\Column(name="ticket_end", type="datetime", nullable=true);
  223.      */
  224.     protected $ticketEnd;
  225.     /**
  226.      * @var Collection|Ticket[]|null
  227.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Ticket\Ticket", mappedBy="campaign", orphanRemoval=true, cascade={"persist"})
  228.      */
  229.     protected ?Collection $tickets null;
  230.     /**
  231.      * @var Collection|TicketType[]|null
  232.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Ticket\TicketType", mappedBy="campaign", orphanRemoval=true, cascade={"persist"})
  233.      */
  234.     protected ?Collection $ticketTypes null;
  235.     /**
  236.      * @ORM\Column(name="ticket_display_name", type="text", length=20);
  237.      * @Serialize\Expose
  238.      */
  239.     protected $ticketDisplayName 'Ticket';
  240.     /**
  241.      * @ORM\Column(name="shop_display_name", type="text", length=20);
  242.      * @Serialize\Expose
  243.      */
  244.     protected $shopDisplayName 'Shop';
  245.     /**
  246.      * @ORM\Column(name="fundaneed_display_name", type="text", length=20);
  247.      * @Serialize\Expose
  248.      */
  249.     protected $fundANeedDisplayName 'Fund A Need';
  250.     /**
  251.      * @ORM\Column(name="crew_up_setup_display_name", type="text", length=20);
  252.      * @Serialize\Expose
  253.      */
  254.     protected $crewUpSetupDisplayName 'CrewUp';
  255.     /**
  256.      * @ORM\Column(name="crew_up_setup_text_description", type="text", length=1000);
  257.      * @Serialize\Expose
  258.      */
  259.     protected $crewUpSetupTextDescription 'Join our CrewUp for an opportunity to serve and support our mission.';
  260.     /**
  261.      * @ORM\Column(name="paddle_raise_display_name", type="text", length=20);
  262.      * @Serialize\Expose
  263.      */
  264.     protected $paddleRaiseDisplayName 'Paddle Raise';
  265.     /**
  266.      * @ORM\Column(name="raffle_display_name", type="text", length=20);
  267.      * @Serialize\Expose
  268.      */
  269.     protected $raffleDisplayName 'Raffle';
  270.     /**
  271.      * @ORM\Column(name="shop_goal", type="decimal", scale=2, precision=10);
  272.      * @Assert\Range(min=0)
  273.      */
  274.     protected $shopGoal 0;
  275.     /**
  276.      * @ORM\Column(name="fund_a_need_goal", type="decimal", scale=2, precision=10);
  277.      * @Assert\Range(min=0)
  278.      */
  279.     protected $fundANeedGoal 0;
  280.     /**
  281.      * @ORM\Column(name="paddle_raise_goal", type="decimal", scale=2, precision=10);
  282.      * @Assert\Range(min=0)
  283.      */
  284.     protected $paddleRaiseGoal 0;
  285.     /**
  286.      * @ORM\Column(name="external_purchase_display_name", type="text", length=20);
  287.      * @Serialize\Expose
  288.      */
  289.     protected $externalPurchaseDisplayName 'External';
  290.     /**
  291.      * @var Collection|Registration[]|null
  292.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Registration\Registration", mappedBy="campaign", orphanRemoval=true, cascade={"persist"})
  293.      */
  294.     protected ?Collection $registrations null;
  295.     /**
  296.      * @var Collection|Purchase[]|null
  297.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Purchase\Purchase", mappedBy="campaign", orphanRemoval=true, cascade={"persist", "remove"})
  298.      */
  299.     protected ?Collection $purchases null;
  300.     /**
  301.      * @var Collection|Transaction[]|null
  302.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Transaction\Transaction", mappedBy="campaign", cascade={"persist", "remove"})
  303.      */
  304.     protected ?Collection $transactions null;
  305.     /**
  306.      * @var Collection|CashDonation[]|null
  307.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Donation\CashDonation", mappedBy="campaign", cascade={"persist"})
  308.      */
  309.     protected ?Collection $donations null;
  310.     /**
  311.      * @var Collection|DonationLevel[]|null
  312.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Donation\DonationLevel", mappedBy="campaign", orphanRemoval=true, cascade={"persist"})
  313.      */
  314.     protected ?Collection $donationLevels null;
  315.     /**
  316.      * @ORM\Column(name="has_item_donations", type="boolean")
  317.      * @Assert\NotNull
  318.      */
  319.     protected $hasItemDonations false;
  320.     /**
  321.      * @ORM\Column(name="has_procurement", type="boolean")
  322.      * @Assert\NotNull
  323.      */
  324.     protected $hasProcurement false;
  325.     /**
  326.      * @var Collection|Item[]|null
  327.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Procurement\Item", mappedBy="campaign", cascade={"remove", "persist"})
  328.      */
  329.     protected ?Collection $donatedItems null;
  330.     /**
  331.      * @ORM\Column(name="has_cash_donations", type="boolean")
  332.      * @Assert\NotNull
  333.      */
  334.     protected $hasCashDonations false;
  335.     /**
  336.      * @ORM\Column(name="has_fund_drive", type="boolean")
  337.      * @Assert\NotNull
  338.      */
  339.     protected $hasFundDrive false;
  340.     /**
  341.      * @ORM\Column(name="fund_drive_name", type="string", length=255, nullable=true);
  342.      */
  343.     protected $fundDriveName;
  344.     /**
  345.      * @ORM\Column(name="fund_drive_begin", type="datetime", nullable=true);
  346.      */
  347.     protected $fundDriveBegin;
  348.     /**
  349.      * @ORM\Column(name="fund_drive_end", type="datetime", nullable=true);
  350.      */
  351.     protected $fundDriveEnd;
  352.     /**
  353.      * An arbitrary string to be displayed on your customer’s credit card statement.
  354.      *
  355.      * @ORM\Column(name="payment_notice", type="string", length=22, nullable=true);
  356.      * @Assert\Regex(
  357.      *     pattern="/[^<>\x22']/",
  358.      *     message="The statement description may not include < > "" ' characters"
  359.      * )
  360.      * @Assert\Length(max = 22)
  361.      */
  362.     protected $paymentNotice;
  363.     /**
  364.      * @var Collection|MembershipLevel[]|null
  365.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Donation\MembershipLevel", mappedBy="campaign", orphanRemoval=true, cascade={"persist"})
  366.      */
  367.     protected ?Collection $membershipLevels null;
  368.     /**
  369.      * @ORM\Column(name="has_membership", type="boolean")
  370.      * @Assert\NotNull
  371.      */
  372.     protected $hasMembership false;
  373.     /**
  374.      * @ORM\Column(name="membership_begin", type="datetime", nullable=true);
  375.      */
  376.     protected $membershipBegin;
  377.     /**
  378.      * @ORM\Column(name="membership_end", type="datetime", nullable=true);
  379.      */
  380.     protected $membershipEnd;
  381.     /**
  382.      * @ORM\Column(name="encourage_cash_donations", type="boolean")
  383.      * @Assert\NotNull
  384.      */
  385.     protected $encourageCashDonations true;
  386.     /**
  387.      * @ORM\Column(name="show_cash_donations", type="boolean")
  388.      * @Assert\NotNull
  389.      */
  390.     protected $showCashDonations true;
  391.     /**
  392.      * @ORM\Column(name="goal_cash_donations", type="decimal", scale=2, precision=10);
  393.      * @Assert\Range(min=0)
  394.      */
  395.     protected $cashDonationGoal 0;
  396.     /**
  397.      * @ORM\Column(name="goal_cash_donation_display", type="boolean")
  398.      * @Assert\NotNull
  399.      */
  400.     protected $displayCashDonationGoal false;
  401.     /**
  402.      * @ORM\Column(name="goal_cash_donation_display_progress", type="boolean")
  403.      * @Assert\NotNull
  404.      */
  405.     protected $displayCashDonationGoalProgress false;
  406.     /**
  407.      * @var Collection|CryptoWallet[]|null
  408.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Donation\CryptoWallet", mappedBy="campaign", orphanRemoval=true, cascade={"persist"})
  409.      */
  410.     protected ?Collection $cryptoWallets null;
  411.     /**
  412.      * @ORM\Column(name="has_registrations", type="boolean")
  413.      * @Serialize\Expose
  414.      */
  415.     protected $hasRegistrations false;
  416.     /**
  417.      * @var Collection|RaffleType[]|null
  418.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Raffle\RaffleType", mappedBy="campaign", orphanRemoval=true, cascade={"persist"})
  419.      */
  420.     protected ?Collection $raffleTypes null;
  421.     /**
  422.      * @var Collection|RegistrationType[]|null
  423.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Registration\RegistrationType", mappedBy="campaign", orphanRemoval=true, cascade={"persist"})
  424.      */
  425.     protected ?Collection $registrationTypes null;
  426.     /**
  427.      * @ORM\Column(name="require_registration_waiver", type="boolean")
  428.      * @Assert\NotNull
  429.      */
  430.     protected $requireRegistrationWaiver false;
  431.     /**
  432.      * @ORM\Column(name="registration_waiver", type="text", nullable=true);
  433.      */
  434.     protected $registrationWaiver;
  435.     /**
  436.      * @ORM\Column(name="registration_start", type="datetime", nullable=true);
  437.      */
  438.     protected $registrationStart;
  439.     /**
  440.      * @ORM\Column(name="registration_end", type="datetime", nullable=true);
  441.      */
  442.     protected $registrationEnd;
  443.     /**
  444.      * @ORM\Column(name="has_paddle_raise", type="boolean", nullable=true)
  445.      */
  446.     protected $hasPaddleRaise false;
  447.     /**
  448.      * @ORM\Column(name="show_paddle_raise_mobile", type="boolean", nullable=true)
  449.      */
  450.     protected $showPaddleRaiseMobileBtn false;
  451.     /**
  452.      * @ORM\Column(name="has_display_feeds", type="boolean", nullable=true)
  453.      */
  454.     protected $hasDisplayFeeds false;
  455.     /**
  456.      * @ORM\Column(name="has_volunteers", type="boolean", nullable=true)
  457.      */
  458.     protected $hasVolunteers false;
  459.     /**
  460.      * @ORM\Embedded(class="Theme", columnPrefix="campaign_")
  461.      * @Assert\Valid
  462.      */
  463.     protected ?Theme $theme null;
  464.     /**
  465.      * @ORM\ManyToOne(targetEntity="Image", cascade={"remove", "persist"})
  466.      * @ORM\JoinColumn(name="banner_image_id", referencedColumnName="id", onDelete="CASCADE")
  467.      * @Serialize\Expose
  468.      */
  469.     protected ?Image $bannerImage null;
  470.     /**
  471.      * @ORM\ManyToOne(targetEntity="Image", cascade={"remove", "persist"})
  472.      * @ORM\JoinColumn(name="logo_image_id", referencedColumnName="id", onDelete="CASCADE")
  473.      * @Serialize\Expose
  474.      */
  475.     protected ?Image $logo null;
  476.     /**
  477.      * @ORM\Column(name="timezone", type="string", length=100);
  478.      */
  479.     protected $timezone;
  480.     /**
  481.      * @ORM\Column(name="perpetual", type="boolean")
  482.      */
  483.     protected $perpetual false;
  484.     /**
  485.      * @ORM\Column(name="pay_by_check", type="boolean")
  486.      */
  487.     protected $payByCheck false;
  488.     /**
  489.      * @ORM\Column(name="hold_items_in_cart", type="boolean")
  490.      * @Serialize\Expose
  491.      */
  492.     protected $holdItemsInCart false;
  493.     /**
  494.      * @ORM\Column(name="allow_custom_payment_instructions", type="boolean")
  495.      */
  496.     protected $allowCustomPaymentInstructions false;
  497.     /**
  498.      * @ORM\Column(name="custom_payment_instructions", type="text", nullable=true)
  499.      */
  500.     protected $customPaymentInstructions;
  501.     /**
  502.      * @ORM\Column(name="donation_text", type="text", nullable=true)
  503.      */
  504.     protected $donationText;
  505.     /**
  506.      * @ORM\Column(name="sms_reply", type="string", length=20, nullable=true)
  507.      */
  508.     protected $smsReply;
  509.     /**
  510.      * @ORM\Column(name="has_raffle", type="boolean")
  511.      */
  512.     protected $hasRaffle false;
  513.     /**
  514.      * @ORM\Column(name="raffle_start", type="datetime", nullable=true);
  515.      */
  516.     protected $raffleStart;
  517.     /**
  518.      * @ORM\Column(name="raffle_end", type="datetime", nullable=true);
  519.      */
  520.     protected $raffleEnd;
  521.     /**
  522.      * @ORM\Column(name="raffle_show_winners_on_homepage", type="boolean", options={"default" : 0})
  523.      */
  524.     protected $raffleShowWinnersOnHomepage false;
  525.     /**
  526.      * @ORM\OneToOne(
  527.      *     targetEntity="Bidcoz\Bundle\CoreBundle\Entity\TwilioCampaign",
  528.      *     mappedBy="campaign",
  529.      *     orphanRemoval=true,
  530.      *     cascade={"persist", "refresh"}
  531.      * )
  532.      */
  533.     protected ?TwilioCampaign $twilioCampaign null;
  534.     /**
  535.      * Fees are stored in integer field in DB as (value * 100), e.g. 5% = 500.
  536.      *
  537.      * @ORM\Column(name="fees", type="smallint", options={"default":500})
  538.      * @Assert\Range(
  539.      *     min = 0,
  540.      *     max = 1000,
  541.      *     notInRangeMessage = "Fees must be between 0% and 10%"
  542.      * )
  543.      */
  544.     protected $fees 500;
  545.     /**
  546.      * @var Collection|CampaignDetail[]|null
  547.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Contact\CampaignDetail", mappedBy="campaign", orphanRemoval=true, cascade={"persist", "remove"})
  548.      */
  549.     protected ?Collection $campaignDetails null;
  550.     /**
  551.      * @var Collection|BidNumber[]|null
  552.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Auction\BidNumber", mappedBy="campaign", cascade={"persist", "remove"})
  553.      */
  554.     protected ?Collection $bidNumbers null;
  555.     /**
  556.      * @var Collection|TicketGroup[]|null
  557.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Ticket\TicketGroup", mappedBy="campaign", cascade={"persist", "remove"})
  558.      */
  559.     protected ?Collection $ticketGroups null;
  560.     /**
  561.      * @var Collection|ItemTemplate[]|null
  562.      * @ORM\OneToMany(targetEntity="Bidcoz\Bundle\CoreBundle\Entity\Email\ItemTemplate", mappedBy="campaign", cascade={"persist", "remove"})
  563.      */
  564.     protected ?Collection $itemTemplates null;
  565.     /**
  566.      * @ORM\Column(name="send_purchase_email", type="boolean")
  567.      * @Serialize\Expose
  568.      */
  569.     protected $sendPurchaseEmail true;
  570.     /**
  571.      * @ORM\Column(name="created_at", type="datetime")
  572.      * @Serialize\Expose
  573.      */
  574.     protected $createdAt;
  575.     public function __construct(Organization $organization)
  576.     {
  577.         $this->organization      $organization;
  578.         $this->sponsorships      = new ArrayCollection();
  579.         $this->tickets           = new ArrayCollection();
  580.         $this->ticketTypes       = new ArrayCollection();
  581.         $this->purchases         = new ArrayCollection();
  582.         $this->donations         = new ArrayCollection();
  583.         $this->registrationTypes = new ArrayCollection();
  584.         $this->raffleTypes       = new ArrayCollection();
  585.         $this->campaignDetails   = new ArrayCollection();
  586.         $this->theme             = new Theme();
  587.         $this->timezone          self::DEFAULT_TIMEZONE;
  588.         $this->createdAt         = new DateTime();
  589.     }
  590.     public function setId(?int $id): void
  591.     {
  592.         $this->id $id;
  593.     }
  594.     public function getId()
  595.     {
  596.         return $this->id;
  597.     }
  598.     public function setName($name)
  599.     {
  600.         $this->name $name;
  601.     }
  602.     public function getName()
  603.     {
  604.         return $this->name;
  605.     }
  606.     public function setSlug($slug)
  607.     {
  608.         $this->slug $slug;
  609.     }
  610.     public function getSlug()
  611.     {
  612.         return $this->slug;
  613.     }
  614.     public function getOrganization()
  615.     {
  616.         return $this->organization;
  617.     }
  618.     public function setOrganization(Organization $organization)
  619.     {
  620.         $this->organization $organization;
  621.     }
  622.     public function setActive($active)
  623.     {
  624.         $this->active $active;
  625.     }
  626.     public function isActive()
  627.     {
  628.         return $this->active;
  629.     }
  630.     public function setDescription($description)
  631.     {
  632.         $this->description $description;
  633.     }
  634.     public function getDescription()
  635.     {
  636.         return $this->description;
  637.     }
  638.     public function setFeeType(string $feeType)
  639.     {
  640.         $this->feeType $feeType;
  641.     }
  642.     public function getFeeType()
  643.     {
  644.         return $this->feeType;
  645.     }
  646.     public function isUserChoiceFeeType(): bool
  647.     {
  648.         return self::FEE_CHOICE == $this->getFeeType();
  649.     }
  650.     public function setTransactionFeePassthrough(bool $transactionFeePassthrough)
  651.     {
  652.         $this->transactionFeePassthrough $transactionFeePassthrough;
  653.     }
  654.     public function getTransactionFeePassthrough(): bool
  655.     {
  656.         return $this->transactionFeePassthrough;
  657.     }
  658.     public function setCollectCcInfo(bool $collectCcInfo)
  659.     {
  660.         $this->collectCcInfo $collectCcInfo;
  661.     }
  662.     public function getCollectCcInfo(): bool
  663.     {
  664.         return $this->collectCcInfo && ($this->hasAuction() || $this->hasTickets());
  665.     }
  666.     public static function getFeeChoices(Organization $organization null)
  667.     {
  668.         return [
  669.             self::FEE_USER   => 'Require Users to pay Fee',
  670.             self::FEE_CHOICE => 'Offer Users the option to decline Fee',
  671.         ];
  672.     }
  673.     public function getCurrency()
  674.     {
  675.         return $this->organization->getCurrency();
  676.     }
  677.     public function isOver()
  678.     {
  679.         $now = new DateTime();
  680.         return $now $this->campaignEnd;
  681.     }
  682.     /**
  683.      * @Assert\Callback
  684.      */
  685.     public function ensureFundDriveDatesValid(ExecutionContextInterface $context)
  686.     {
  687.         if ($this->fundDriveBegin && $this->fundDriveEnd && $this->fundDriveBegin $this->fundDriveEnd) {
  688.             $context->buildViolation('Appeal Start must be before Appeal End')
  689.                 ->atPath('fundDriveBegin')
  690.                 ->addViolation();
  691.         }
  692.     }
  693.     /**
  694.      * @Assert\Callback
  695.      */
  696.     public function ensureMembershipDatesValid(ExecutionContextInterface $context)
  697.     {
  698.         if ($this->membershipBegin && $this->membershipEnd && $this->membershipBegin $this->membershipEnd) {
  699.             $context->buildViolation('Membership Start must be before Membership End')
  700.                 ->atPath('membershipBegin')
  701.                 ->addViolation();
  702.         }
  703.     }
  704.     public function setHasAuction($hasAuction)
  705.     {
  706.         $this->hasAuction $hasAuction;
  707.     }
  708.     public function getHasAuction()
  709.     {
  710.         return $this->hasAuction;
  711.     }
  712.     public function hasAuction()
  713.     {
  714.         return $this->hasAuction;
  715.     }
  716.     public function auctionAvailable(): bool
  717.     {
  718.         if (!$this->hasAuction) {
  719.             return false;
  720.         }
  721.         return $this->getAuction()->isAvailable();
  722.     }
  723.     public function setHasShop($hasShop)
  724.     {
  725.         $this->hasShop $hasShop;
  726.     }
  727.     public function getHasShop()
  728.     {
  729.         return $this->hasShop;
  730.     }
  731.     public function hasShop()
  732.     {
  733.         return $this->hasShop;
  734.     }
  735.     public function shopAvailable(): bool
  736.     {
  737.         return $this->hasShop;
  738.     }
  739.     public function setHasFundANeed($hasFundANeed)
  740.     {
  741.         $this->hasFundANeed $hasFundANeed;
  742.     }
  743.     public function getHasFundANeed()
  744.     {
  745.         return $this->hasFundANeed;
  746.     }
  747.     public function hasFundANeed()
  748.     {
  749.         return $this->hasFundANeed;
  750.     }
  751.     public function fundANeedAvailable(): bool
  752.     {
  753.         return $this->hasFundANeed;
  754.     }
  755.     public function setAuction(?Auction $auction): void
  756.     {
  757.         $this->auction $auction;
  758.     }
  759.     public function getAuction(): ?Auction
  760.     {
  761.         return $this->auction && Auction::class == get_class($this->auction)
  762.             ? $this->auction
  763.             null;
  764.     }
  765.     public function setShop(?Shop $shop)
  766.     {
  767.         $this->shop $shop;
  768.     }
  769.     public function getShop(): ?Shop
  770.     {
  771.         return $this->shop;
  772.     }
  773.     public function setFundANeed(?FundANeed $fundANeed)
  774.     {
  775.         $this->fundANeed $fundANeed;
  776.     }
  777.     public function getFundANeed(): ?FundANeed
  778.     {
  779.         return $this->fundANeed;
  780.     }
  781.     public function setHasSponsorship($hasSponsorship)
  782.     {
  783.         $this->hasSponsorship $hasSponsorship;
  784.     }
  785.     public function getHasSponsorship()
  786.     {
  787.         return $this->hasSponsorship;
  788.     }
  789.     public function setSponsorshipSignup($sponsorshipSignup)
  790.     {
  791.         $this->sponsorshipSignup $sponsorshipSignup;
  792.     }
  793.     public function getSponsorshipSignup()
  794.     {
  795.         return $this->sponsorshipSignup;
  796.     }
  797.     public function setHasTickets($hasTickets)
  798.     {
  799.         $this->hasTickets $hasTickets;
  800.     }
  801.     public function getHasTickets()
  802.     {
  803.         return $this->hasTickets;
  804.     }
  805.     public function hasTickets()
  806.     {
  807.         return $this->hasTickets;
  808.     }
  809.     public function setTicketType($ticketType)
  810.     {
  811.         $this->ticketType $ticketType;
  812.     }
  813.     public function getTicketType()
  814.     {
  815.         return $this->ticketType ?: self::TICKET_TYPE_GENERAL_ADMISSION;
  816.     }
  817.     public static function getTicketTypeChoices()
  818.     {
  819.         return [
  820.             self::TICKET_TYPE_GENERAL_ADMISSION => 'General Admission',
  821.             // self::TICKET_TYPE_RESERVED          => 'Reserved Seating',
  822.             self::TICKET_TYPE_ASSIGNED          => 'Assigned Seating',
  823.         ];
  824.     }
  825.     public function hasSelfCheckIn()
  826.     {
  827.         return null !== $this->selfCheckInDate;
  828.     }
  829.     public function setSelfCheckInDate(DateTime $selfCheckInDate null)
  830.     {
  831.         $this->selfCheckInDate $selfCheckInDate;
  832.     }
  833.     public function getSelfCheckInDate()
  834.     {
  835.         return $this->selfCheckInDate;
  836.     }
  837.     public function selfCheckInAvailable(): bool
  838.     {
  839.         $now = new DateTime();
  840.         return $this->hasSelfCheckIn() && $now $this->getSelfCheckInDate();
  841.     }
  842.     public function hasTicketAssignment()
  843.     {
  844.         return in_array($this->getTicketType(), [
  845.             // self::TICKET_TYPE_RESERVED,
  846.             self::TICKET_TYPE_ASSIGNED,
  847.         ]);
  848.     }
  849.     public function isReservedSeating()
  850.     {
  851.         // return self::TICKET_TYPE_RESERVED === $this->getTicketType();
  852.         return;
  853.     }
  854.     public function getSeatingChartImages()
  855.     {
  856.         return $this->seatingChartImages;
  857.     }
  858.     public function addSeatingChartImage(SeatingChartImage $image)
  859.     {
  860.         if (!$this->seatingChartImages->contains($image)) {
  861.             $this->seatingChartImages->add($image);
  862.         }
  863.     }
  864.     public function removeSeatingChartImage(SeatingChartImage $image)
  865.     {
  866.         if ($this->seatingChartImages->contains($image)) {
  867.             $this->seatingChartImages->removeElement($image);
  868.         }
  869.     }
  870.     public function setPrimarySeatingChartImage(SeatingChartImage $image)
  871.     {
  872.         foreach ($this->seatingChartImages as $i) {
  873.             $i->setPrimary(false);
  874.         }
  875.         $image->setPrimary(true);
  876.     }
  877.     public function getPrimarySeatingChartImage()
  878.     {
  879.         $filtered $this->getSeatingChartImages()->filter(function ($image) {
  880.             return $image->isPrimary();
  881.         });
  882.         return $filtered->first();
  883.     }
  884.     public function setTicketQuantity($ticketQuantity)
  885.     {
  886.         $this->ticketQuantity $ticketQuantity;
  887.     }
  888.     public function getTicketQuantity()
  889.     {
  890.         return $this->ticketQuantity;
  891.     }
  892.     public function setTicketEnd(DateTime $date)
  893.     {
  894.         $this->ticketEnd $date;
  895.     }
  896.     public function getTicketEnd()
  897.     {
  898.         return $this->ticketEnd;
  899.     }
  900.     public function setDetailsTitle($detailsTitle)
  901.     {
  902.         $this->detailsTitle $detailsTitle;
  903.     }
  904.     public function getDetailsTitle()
  905.     {
  906.         return $this->detailsTitle;
  907.     }
  908.     public function setDetailsBody($detailsBody)
  909.     {
  910.         $this->detailsBody $detailsBody;
  911.     }
  912.     public function getDetailsBody()
  913.     {
  914.         return $this->detailsBody;
  915.     }
  916.     public function setHomepageContent($homepageContent)
  917.     {
  918.         $this->homepageContent $homepageContent;
  919.     }
  920.     public function getHomepageContent()
  921.     {
  922.         return $this->homepageContent;
  923.     }
  924.     public function setVideo(VideoEmbed $video)
  925.     {
  926.         $this->video $video;
  927.     }
  928.     public function getVideo()
  929.     {
  930.         return $this->video;
  931.     }
  932.     public function ticketsAvailable()
  933.     {
  934.         // TODO
  935.         return true;
  936.     }
  937.     public function getTickets()
  938.     {
  939.         return $this->tickets;
  940.     }
  941.     public function getTicketTypes()
  942.     {
  943.         return $this->ticketTypes;
  944.     }
  945.     public function addTicketType(TicketType $ticketType): void
  946.     {
  947.         if (!$this->ticketTypes->contains($ticketType)) {
  948.             $this->ticketTypes->add($ticketType);
  949.         }
  950.     }
  951.     public function removeTicketType(TicketType $ticketType): void
  952.     {
  953.         if ($this->ticketTypes->contains($ticketType)) {
  954.             $this->ticketTypes->removeElement($ticketType);
  955.         }
  956.     }
  957.     public function setTicketDisplayName(string $ticketDisplayName)
  958.     {
  959.         $this->ticketDisplayName $ticketDisplayName;
  960.     }
  961.     public function getTicketDisplayName(): string
  962.     {
  963.         return $this->ticketDisplayName;
  964.     }
  965.     public function setShopDisplayName(string $shopDisplayName)
  966.     {
  967.         $this->shopDisplayName $shopDisplayName;
  968.     }
  969.     public function getShopDisplayName(): string
  970.     {
  971.         return $this->shopDisplayName;
  972.     }
  973.     public function setFundANeedDisplayName(string $fundANeedDisplayName)
  974.     {
  975.         $this->fundANeedDisplayName $fundANeedDisplayName;
  976.     }
  977.     public function getPaddleRaiseDisplayName(): string
  978.     {
  979.         return $this->paddleRaiseDisplayName;
  980.     }
  981.     public function setPaddleRaiseDisplayName(string $paddleRaiseDisplayName)
  982.     {
  983.         $this->paddleRaiseDisplayName $paddleRaiseDisplayName;
  984.     }
  985.     public function getRaffleDisplayName(): string
  986.     {
  987.         return $this->raffleDisplayName;
  988.     }
  989.     public function setRaffleDisplayName(string $raffleDisplayName)
  990.     {
  991.         $this->raffleDisplayName $raffleDisplayName;
  992.     }
  993.     public function getFundANeedDisplayName(): string
  994.     {
  995.         return $this->fundANeedDisplayName;
  996.     }
  997.     public function setExternalPurchaseDisplayName(string $externalPurchaseDisplayName)
  998.     {
  999.         $this->externalPurchaseDisplayName $externalPurchaseDisplayName;
  1000.     }
  1001.     public function getExternalPurchaseDisplayName(): string
  1002.     {
  1003.         return $this->externalPurchaseDisplayName;
  1004.     }
  1005.     public function setHasItemDonations($hasItemDonations)
  1006.     {
  1007.         $this->hasItemDonations $hasItemDonations;
  1008.     }
  1009.     public function getHasItemDonations()
  1010.     {
  1011.         return $this->hasProcurement && $this->hasItemDonations;
  1012.     }
  1013.     public function setHasProcurement($hasProcurement)
  1014.     {
  1015.         $this->hasProcurement $hasProcurement;
  1016.     }
  1017.     public function getHasProcurement()
  1018.     {
  1019.         return $this->hasProcurement;
  1020.     }
  1021.     public function setHasCashDonations($hasCashDonations)
  1022.     {
  1023.         $this->hasCashDonations $hasCashDonations;
  1024.     }
  1025.     public function getHasCashDonations()
  1026.     {
  1027.         return $this->hasCashDonations;
  1028.     }
  1029.     public function hasCashDonations()
  1030.     {
  1031.         return $this->hasCashDonations;
  1032.     }
  1033.     public function setHasFundDrive($hasFundDrive)
  1034.     {
  1035.         $this->hasFundDrive $hasFundDrive;
  1036.     }
  1037.     public function getHasFundDrive()
  1038.     {
  1039.         return $this->hasFundDrive;
  1040.     }
  1041.     public function isFundDriveEnabled()
  1042.     {
  1043.         $now = new DateTime();
  1044.         return $this->hasFundDrive                                   &&
  1045.             (!$this->fundDriveBegin || $this->fundDriveBegin $now) &&
  1046.             (!$this->fundDriveEnd   || $this->fundDriveEnd $now);
  1047.     }
  1048.     public function hasFundDrive()
  1049.     {
  1050.         return $this->hasFundDrive;
  1051.     }
  1052.     public function setFundDriveName($fundDriveName)
  1053.     {
  1054.         $this->fundDriveName $fundDriveName;
  1055.     }
  1056.     public function getFundDriveName()
  1057.     {
  1058.         return $this->fundDriveName;
  1059.     }
  1060.     public function setFundDriveBegin(DateTime $fundDriveBegin null)
  1061.     {
  1062.         $this->fundDriveBegin $fundDriveBegin;
  1063.     }
  1064.     public function getFundDriveBegin()
  1065.     {
  1066.         return $this->fundDriveBegin;
  1067.     }
  1068.     public function setFundDriveEnd(DateTime $fundDriveEnd null)
  1069.     {
  1070.         $this->fundDriveEnd $fundDriveEnd;
  1071.     }
  1072.     public function getFundDriveEnd()
  1073.     {
  1074.         return $this->fundDriveEnd;
  1075.     }
  1076.     public function setPaymentNotice($paymentNotice)
  1077.     {
  1078.         $this->paymentNotice $paymentNotice;
  1079.     }
  1080.     public function getPaymentNotice()
  1081.     {
  1082.         return $this->paymentNotice;
  1083.     }
  1084.     public function getDonationLevels(): ?Collection
  1085.     {
  1086.         return $this->donationLevels;
  1087.     }
  1088.     public function setDonationLevels(?Collection $donationLevels): void
  1089.     {
  1090.         $this->donationLevels $donationLevels;
  1091.     }
  1092.     public function getMembershipLevels()
  1093.     {
  1094.         return $this->membershipLevels;
  1095.     }
  1096.     public function setHasMembership($hasMembership)
  1097.     {
  1098.         $this->hasMembership $hasMembership;
  1099.     }
  1100.     public function getHasMembership()
  1101.     {
  1102.         return $this->hasMembership;
  1103.     }
  1104.     public function isMembershipEnabled()
  1105.     {
  1106.         $now = new DateTime();
  1107.         return $this->hasMembership                                &&
  1108.         (!$this->membershipBegin || $this->membershipBegin $now) &&
  1109.         (!$this->membershipEnd   || $this->membershipEnd $now);
  1110.     }
  1111.     public function hasMembership()
  1112.     {
  1113.         return $this->hasMembership;
  1114.     }
  1115.     public function setMembershipBegin(DateTime $membershipBegin null)
  1116.     {
  1117.         $this->membershipBegin $membershipBegin;
  1118.     }
  1119.     public function getMembershipBegin()
  1120.     {
  1121.         return $this->membershipBegin;
  1122.     }
  1123.     public function setMembershipEnd(DateTime $membershipEnd null)
  1124.     {
  1125.         $this->membershipEnd $membershipEnd;
  1126.     }
  1127.     public function getMembershipEnd()
  1128.     {
  1129.         return $this->membershipEnd;
  1130.     }
  1131.     public function setEncourageCashDonations($encourageCashDonations)
  1132.     {
  1133.         $this->encourageCashDonations $encourageCashDonations;
  1134.     }
  1135.     public function getEncourageCashDonations()
  1136.     {
  1137.         return $this->encourageCashDonations;
  1138.     }
  1139.     public function setShowCashDonations($showCashDonations)
  1140.     {
  1141.         $this->showCashDonations $showCashDonations;
  1142.     }
  1143.     public function getShowCashDonations()
  1144.     {
  1145.         return $this->showCashDonations;
  1146.     }
  1147.     public function setCashDonationGoal($cashDonationGoal)
  1148.     {
  1149.         $this->cashDonationGoal $cashDonationGoal;
  1150.     }
  1151.     public function getCashDonationGoal()
  1152.     {
  1153.         return $this->cashDonationGoal;
  1154.     }
  1155.     public function setDisplayCashDonationGoal($displayCashDonationGoal)
  1156.     {
  1157.         $this->displayCashDonationGoal $displayCashDonationGoal;
  1158.     }
  1159.     public function getDisplayCashDonationGoal()
  1160.     {
  1161.         return $this->displayCashDonationGoal;
  1162.     }
  1163.     public function setDisplayCashDonationGoalProgress($displayCashDonationGoalProgress)
  1164.     {
  1165.         $this->displayCashDonationGoalProgress $displayCashDonationGoalProgress;
  1166.     }
  1167.     public function getDisplayCashDonationGoalProgress()
  1168.     {
  1169.         return $this->displayCashDonationGoalProgress;
  1170.     }
  1171.     public function getRaffleTypes()
  1172.     {
  1173.         return $this->raffleTypes;
  1174.     }
  1175.     public function setRaffleTypes($raffleTypes): void
  1176.     {
  1177.         $this->raffleTypes $raffleTypes;
  1178.     }
  1179.     public function addRaffleType(RaffleType $raffleType): void
  1180.     {
  1181.         $this->raffleTypes->add($raffleType);
  1182.     }
  1183.     public function removeRaffleType(RaffleType $raffleType): void
  1184.     {
  1185.         $this->raffleTypes->removeElement($raffleType);
  1186.     }
  1187.     public function getActiveRaffles()
  1188.     {
  1189.         return $this->raffleTypes->filter(function (RaffleType $raffleType) {
  1190.             return $raffleType->isActive();
  1191.         });
  1192.     }
  1193.     public function setHasRegistrations($hasRegistrations)
  1194.     {
  1195.         $this->hasRegistrations $hasRegistrations;
  1196.     }
  1197.     public function getHasRegistrations()
  1198.     {
  1199.         return $this->hasRegistrations;
  1200.     }
  1201.     public function getRegistrationTypes()
  1202.     {
  1203.         return $this->registrationTypes;
  1204.     }
  1205.     public function getCryptoWallets()
  1206.     {
  1207.         return $this->cryptoWallets;
  1208.     }
  1209.     public function setRequireRegistrationWaiver($requireRegistrationWaiver)
  1210.     {
  1211.         $this->requireRegistrationWaiver $requireRegistrationWaiver;
  1212.     }
  1213.     public function getRequireRegistrationWaiver()
  1214.     {
  1215.         return $this->requireRegistrationWaiver;
  1216.     }
  1217.     public function setRegistrationWaiver($registrationWaiver)
  1218.     {
  1219.         $this->registrationWaiver $registrationWaiver;
  1220.     }
  1221.     public function getRegistrationWaiver()
  1222.     {
  1223.         return $this->registrationWaiver;
  1224.     }
  1225.     public function setRegistrationStart($registrationStart)
  1226.     {
  1227.         $this->registrationStart $registrationStart;
  1228.     }
  1229.     public function getRegistrationStart()
  1230.     {
  1231.         return $this->registrationStart;
  1232.     }
  1233.     public function setRegistrationEnd($registrationEnd)
  1234.     {
  1235.         $this->registrationEnd $registrationEnd;
  1236.     }
  1237.     public function getRegistrationEnd()
  1238.     {
  1239.         return $this->registrationEnd;
  1240.     }
  1241.     public function isRegistrationActive()
  1242.     {
  1243.         $now = new DateTime();
  1244.         return $now >= $this->registrationStart && $now <= $this->registrationEnd;
  1245.     }
  1246.     public function setHasPaddleRaise($hasPaddleRaise)
  1247.     {
  1248.         $this->hasPaddleRaise $hasPaddleRaise;
  1249.     }
  1250.     public function getHasPaddleRaise()
  1251.     {
  1252.         return $this->hasPaddleRaise;
  1253.     }
  1254.     public function hasPaddleRaise()
  1255.     {
  1256.         return $this->hasPaddleRaise;
  1257.     }
  1258.     public function setShowPaddleRaiseMobileBtn($showPaddleRaiseMobileBtn)
  1259.     {
  1260.         $this->showPaddleRaiseMobileBtn $showPaddleRaiseMobileBtn;
  1261.     }
  1262.     public function getShowPaddleRaiseMobileBtn()
  1263.     {
  1264.         return $this->showPaddleRaiseMobileBtn;
  1265.     }
  1266.     public function setHasDisplayFeeds($hasDisplayFeeds)
  1267.     {
  1268.         $this->hasDisplayFeeds $hasDisplayFeeds;
  1269.     }
  1270.     public function getHasDisplayFeeds()
  1271.     {
  1272.         return $this->hasDisplayFeeds;
  1273.     }
  1274.     public function setHasVolunteers(bool $hasVolunteers)
  1275.     {
  1276.         $this->hasVolunteers $hasVolunteers;
  1277.     }
  1278.     public function getHasVolunteers(): bool
  1279.     {
  1280.         return (bool) $this->hasVolunteers;
  1281.     }
  1282.     public function setTheme(?Theme $theme)
  1283.     {
  1284.         $this->theme $theme;
  1285.     }
  1286.     public function getTheme()
  1287.     {
  1288.         return $this->theme;
  1289.     }
  1290.     public function setBannerImage(?Image $image)
  1291.     {
  1292.         $this->bannerImage $image;
  1293.     }
  1294.     public function removeBannerImage(): void
  1295.     {
  1296.         $this->bannerImage null;
  1297.     }
  1298.     public function getBannerImage(): ?Image
  1299.     {
  1300.         return $this->bannerImage;
  1301.     }
  1302.     public function setLogo(?Image $image null)
  1303.     {
  1304.         $this->logo $image;
  1305.     }
  1306.     public function removeLogo()
  1307.     {
  1308.         $this->logo null;
  1309.     }
  1310.     public function getLogo()
  1311.     {
  1312.         return $this->logo;
  1313.     }
  1314.     public function isUrlEditable(): bool
  1315.     {
  1316.         // TODO
  1317.         return !$this->isPerpetual();
  1318.         if (!$this->id) {
  1319.             return true;
  1320.         }
  1321.     }
  1322.     public function getCreatedAt()
  1323.     {
  1324.         return $this->createdAt;
  1325.     }
  1326.     /**
  1327.      * @Assert\Callback
  1328.      */
  1329.     public function isReservedSlug(ExecutionContextInterface $context)
  1330.     {
  1331.         if (!preg_match('#'.Constants::RESERVED_CAMPAIGN_SLUG_REGEX.'#'$this->slug)) {
  1332.             $context->buildViolation('This is a reserved url.')
  1333.                 ->atPath('slug')
  1334.                 ->addViolation();
  1335.         }
  1336.     }
  1337.     public function setPerpetual($perpetual)
  1338.     {
  1339.         $this->perpetual $perpetual;
  1340.     }
  1341.     public function isPerpetual()
  1342.     {
  1343.         return $this->perpetual;
  1344.     }
  1345.     public function setPayByCheck($payByCheck)
  1346.     {
  1347.         $this->payByCheck $payByCheck;
  1348.     }
  1349.     public function isPayByCheck(): bool
  1350.     {
  1351.         return (bool) $this->payByCheck;
  1352.     }
  1353.     public function setHoldItemsInCart(bool $holdItemsInCart)
  1354.     {
  1355.         $this->holdItemsInCart $holdItemsInCart;
  1356.     }
  1357.     public function getHoldItemsInCart(): bool
  1358.     {
  1359.         return (bool) $this->holdItemsInCart;
  1360.     }
  1361.     public function isUseFastList(): bool
  1362.     {
  1363.         // TODO - Currently ONLY CHG, can add db flag later
  1364.         return 'chg' === $this->organization->getSlug();
  1365.     }
  1366.     public function isExternalPaymentAllowed(): bool
  1367.     {
  1368.         return $this->organization->isEnableCustomizations();
  1369.     }
  1370.     public function setAllowCustomPaymentInstructions(bool $allowCustomPaymentInstructions)
  1371.     {
  1372.         $this->allowCustomPaymentInstructions $allowCustomPaymentInstructions;
  1373.     }
  1374.     public function getAllowCustomPaymentInstructions(): bool
  1375.     {
  1376.         return (bool) $this->allowCustomPaymentInstructions;
  1377.     }
  1378.     public function setCustomPaymentInstructions(string $customPaymentInstructions)
  1379.     {
  1380.         $this->customPaymentInstructions $customPaymentInstructions;
  1381.     }
  1382.     public function getCustomPaymentInstructions()
  1383.     {
  1384.         return $this->customPaymentInstructions;
  1385.     }
  1386.     public function showCustomPaymentInstructions(): bool
  1387.     {
  1388.         return (bool) $this->allowCustomPaymentInstructions && $this->customPaymentInstructions;
  1389.     }
  1390.     public function setDonationText(string $donationText null)
  1391.     {
  1392.         $this->donationText $donationText;
  1393.     }
  1394.     public function getDonationText()
  1395.     {
  1396.         return $this->donationText;
  1397.     }
  1398.     public function isLocked()
  1399.     {
  1400.         return in_array($this->slug, ['donate']);
  1401.     }
  1402.     public function isHidden()
  1403.     {
  1404.         return in_array($this->slug, ['tryit']);
  1405.     }
  1406.     public function getCampaign()
  1407.     {
  1408.         return $this;
  1409.     }
  1410.     public function getObjectName()
  1411.     {
  1412.         return 'Campaign';
  1413.     }
  1414.     public function setTimeZone($timezone)
  1415.     {
  1416.         $this->timezone $timezone;
  1417.     }
  1418.     public function getTimezone()
  1419.     {
  1420.         return $this->timezone ?: self::DEFAULT_TIMEZONE;
  1421.     }
  1422.     public function getTrackedParams()
  1423.     {
  1424.         return [
  1425.             'slug'             => 'URL',
  1426.             'feeType'          => 'Fee Type',
  1427.             'hasAuction'       => 'Has Auction',
  1428.             'hasSponsorship'   => 'Has Sponsorship',
  1429.             'hasTickets'       => 'Has Tickets',
  1430.             'hasItemDonations' => 'Has Item Donations',
  1431.             'hasCashDonations' => 'Has Cash Donations',
  1432.         ];
  1433.     }
  1434.     public function hasComponent($component)
  1435.     {
  1436.         if (!isset(self::$components[$component])) {
  1437.             return false;
  1438.         }
  1439.         $property InflectorFactory::create()->build()->camelize('has_'.$component);
  1440.         return $property && isset($this->$property) && $this->$property;
  1441.     }
  1442.     public function setSmsReply(string $smsReply)
  1443.     {
  1444.         $this->smsReply $smsReply;
  1445.     }
  1446.     public function getSmsReply()
  1447.     {
  1448.         return $this->smsReply;
  1449.     }
  1450.     public function setHasRaffle($hasRaffle)
  1451.     {
  1452.         $this->hasRaffle $hasRaffle;
  1453.     }
  1454.     public function getHasRaffle()
  1455.     {
  1456.         return $this->hasRaffle;
  1457.     }
  1458.     public function setRaffleStart(DateTime $raffleStart)
  1459.     {
  1460.         $this->raffleStart $raffleStart;
  1461.     }
  1462.     public function getRaffleStart()
  1463.     {
  1464.         return $this->raffleStart;
  1465.     }
  1466.     public function setRaffleEnd(DateTime $raffleEnd)
  1467.     {
  1468.         $this->raffleEnd $raffleEnd;
  1469.     }
  1470.     public function getRaffleEnd()
  1471.     {
  1472.         return $this->raffleEnd;
  1473.     }
  1474.     public function isRaffleActive(): bool
  1475.     {
  1476.         $now = new DateTime();
  1477.         return $this->hasRaffle && $now $this->raffleStart && $now $this->raffleEnd;
  1478.     }
  1479.     public function setRaffleShowWinnersOnHomepage(bool $raffleShowWinnersOnHomepage)
  1480.     {
  1481.         $this->raffleShowWinnersOnHomepage $raffleShowWinnersOnHomepage;
  1482.     }
  1483.     public function getRaffleShowWinnersOnHomepage(): bool
  1484.     {
  1485.         return $this->raffleShowWinnersOnHomepage;
  1486.     }
  1487.     public function getTwilioCampaign()
  1488.     {
  1489.         return $this->twilioCampaign;
  1490.     }
  1491.     public function setTwilioCampaign($twilioCampaign)
  1492.     {
  1493.         $this->twilioCampaign $twilioCampaign;
  1494.     }
  1495.     public function hasTwilioCampaign()
  1496.     {
  1497.         return (bool) $this->twilioCampaign && $this->twilioCampaign->getId();
  1498.     }
  1499.     /**
  1500.      * @ORM\PreFlush
  1501.      */
  1502.     public function checkTwilioCampaign(PreFlushEventArgs $event)
  1503.     {
  1504.         $em $event->getEntityManager();
  1505.         if ($this->getTwilioCampaign() && empty($this->getTwilioCampaign()->getNumber())) {
  1506.             $em->remove($this->getTwilioCampaign());
  1507.             $this->setTwilioCampaign(null);
  1508.         }
  1509.     }
  1510.     // Fees are stored in integer field as value * 100, e.g. 5% = 500
  1511.     public function getFees()
  1512.     {
  1513.         return $this->fees 100;
  1514.     }
  1515.     public function setFees($fees)
  1516.     {
  1517.         $this->fees = (int) round($fees 100);
  1518.     }
  1519.     /**
  1520.      * @return Collection|CampaignDetail[]|null
  1521.      */
  1522.     public function getCampaignDetails(): ?Collection
  1523.     {
  1524.         return $this->campaignDetails;
  1525.     }
  1526.     public function setCampaignDetails(?Collection $campaignDetails): void
  1527.     {
  1528.         $this->campaignDetails $campaignDetails;
  1529.     }
  1530.     public function addCampaignDetail(CampaignDetail $campaignDetail): void
  1531.     {
  1532.         $this->campaignDetails->add($campaignDetail);
  1533.         $campaignDetail->setCampaign($this);
  1534.     }
  1535.     public function removeCampaignDetail(CampaignDetail $campaignDetail): void
  1536.     {
  1537.         $this->campaignDetails->removeElement($campaignDetail);
  1538.         $campaignDetail->setCampaign(null);
  1539.     }
  1540.     public function getSponsorships(): ?Collection
  1541.     {
  1542.         return $this->sponsorships;
  1543.     }
  1544.     public function setSponsorships(?Collection $sponsorships): void
  1545.     {
  1546.         $this->sponsorships $sponsorships;
  1547.     }
  1548.     public function addSponsorship(Sponsorship $sponsorship): void
  1549.     {
  1550.         if (!$this->sponsorships->contains($sponsorship)) {
  1551.             $this->sponsorships->add($sponsorship);
  1552.             $sponsorship->setCampaign($this);
  1553.         }
  1554.     }
  1555.     public function removeSponsorship(Sponsorship $sponsorship): void
  1556.     {
  1557.         if ($this->sponsorships->contains($sponsorship)) {
  1558.             $this->sponsorships->removeElement($sponsorship);
  1559.             $sponsorship->setCampaign(null);
  1560.         }
  1561.     }
  1562.     public function getSponsorshipLevels(): ?Collection
  1563.     {
  1564.         return $this->sponsorshipLevels;
  1565.     }
  1566.     public function setSponsorshipLevels(?Collection $sponsorshipLevels): void
  1567.     {
  1568.         $this->sponsorshipLevels $sponsorshipLevels;
  1569.     }
  1570.     public function getRegistrations(): ?Collection
  1571.     {
  1572.         return $this->registrations;
  1573.     }
  1574.     public function setRegistrations(?Collection $registrations): void
  1575.     {
  1576.         $this->registrations $registrations;
  1577.     }
  1578.     /**
  1579.      * @return Collection|Purchase[]|null
  1580.      */
  1581.     public function getPurchases(): ?Collection
  1582.     {
  1583.         return $this->purchases;
  1584.     }
  1585.     public function getPaddleRaiseDonationPurchases(): ?Collection
  1586.     {
  1587.         $purchases = new ArrayCollection();
  1588.         foreach ($this->purchases as $purchase) {
  1589.             if ($purchase instanceof PaddleRaiseDonationPurchase) {
  1590.                 $purchases->add($purchase);
  1591.             }
  1592.         }
  1593.         return $purchases;
  1594.     }
  1595.     public function setPurchases(?Collection $purchases): void
  1596.     {
  1597.         $this->purchases $purchases;
  1598.     }
  1599.     public function addPurchase(Purchase $purchase): void
  1600.     {
  1601.         if (!$this->purchases->contains($purchase)) {
  1602.             $this->purchases->add($purchase);
  1603.             $purchase->setCampaign($this);
  1604.         }
  1605.     }
  1606.     public function removePurchase(Purchase $purchase): void
  1607.     {
  1608.         if ($this->purchases->contains($purchase)) {
  1609.             $this->purchases->removeElement($purchase);
  1610.             $purchase->setCampaign(null);
  1611.         }
  1612.     }
  1613.     public function getTransactions(): ?Collection
  1614.     {
  1615.         return $this->transactions;
  1616.     }
  1617.     public function setTransactions(?Collection $transactions): void
  1618.     {
  1619.         $this->transactions $transactions;
  1620.     }
  1621.     public function addTransaction(Transaction $transaction): void
  1622.     {
  1623.         if (!$this->transactions->contains($transaction)) {
  1624.             $this->transactions->add($transaction);
  1625.         }
  1626.     }
  1627.     public function removeTransaction(Transaction $transaction): void
  1628.     {
  1629.         if ($this->transactions->contains($transaction)) {
  1630.             $this->transactions->removeElement($transaction);
  1631.         }
  1632.     }
  1633.     public function getDonations(): ?Collection
  1634.     {
  1635.         return $this->donations;
  1636.     }
  1637.     public function setDonations(?Collection $donations): void
  1638.     {
  1639.         $this->donations $donations;
  1640.     }
  1641.     public function getDonatedItems(): ?Collection
  1642.     {
  1643.         return $this->donatedItems;
  1644.     }
  1645.     public function setDonatedItems(?Collection $donatedItems): void
  1646.     {
  1647.         $this->donatedItems $donatedItems;
  1648.     }
  1649.     public function getBidNumbers(): ?Collection
  1650.     {
  1651.         return $this->bidNumbers;
  1652.     }
  1653.     public function setBidNumbers(?Collection $bidNumbers): void
  1654.     {
  1655.         $this->bidNumbers $bidNumbers;
  1656.     }
  1657.     public function addBidNumber(BidNumber $bidNumber): void
  1658.     {
  1659.         if (!$this->bidNumbers->contains($bidNumber)) {
  1660.             $this->bidNumbers->add($bidNumber);
  1661.         }
  1662.     }
  1663.     public function removeBidNumber(BidNumber $bidNumber): void
  1664.     {
  1665.         if ($this->bidNumbers->contains($bidNumber)) {
  1666.             $this->bidNumbers->removeElement($bidNumber);
  1667.         }
  1668.     }
  1669.     public function getTicketGroups(): ?Collection
  1670.     {
  1671.         return $this->ticketGroups;
  1672.     }
  1673.     public function setTicketGroups(?Collection $ticketGroups): void
  1674.     {
  1675.         $this->ticketGroups $ticketGroups;
  1676.     }
  1677.     public function addTicketGroup(TicketGroup $ticketGroup): void
  1678.     {
  1679.         if (!$this->ticketGroups->contains($ticketGroup)) {
  1680.             $this->ticketGroups->add($ticketGroup);
  1681.         }
  1682.     }
  1683.     public function removeTicketGroup(TicketGroup $ticketGroup): void
  1684.     {
  1685.         if ($this->ticketGroups->contains($ticketGroup)) {
  1686.             $this->ticketGroups->removeElement($ticketGroup);
  1687.         }
  1688.     }
  1689.     public function setShopGoal($goal)
  1690.     {
  1691.         $this->shopGoal $goal;
  1692.     }
  1693.     public function getShopGoal()
  1694.     {
  1695.         return $this->shopGoal;
  1696.     }
  1697.     public function setFundANeedGoal($goal)
  1698.     {
  1699.         $this->fundANeedGoal $goal;
  1700.     }
  1701.     public function getFundANeedGoal()
  1702.     {
  1703.         return $this->fundANeedGoal;
  1704.     }
  1705.     public function setPaddleRaiseGoal($goal)
  1706.     {
  1707.         $this->paddleRaiseGoal $goal;
  1708.     }
  1709.     public function getPaddleRaiseGoal()
  1710.     {
  1711.         return $this->paddleRaiseGoal;
  1712.     }
  1713.     public function setSendPurchaseEmail(bool $sendPurchaseEmail)
  1714.     {
  1715.         $this->sendPurchaseEmail $sendPurchaseEmail;
  1716.     }
  1717.     public function getSendPurchaseEmail(): bool
  1718.     {
  1719.         return $this->sendPurchaseEmail;
  1720.     }
  1721.     public function getCrewUpSetupDisplayName(): string
  1722.     {
  1723.         return $this->crewUpSetupDisplayName;
  1724.     }
  1725.     public function setCrewUpSetupDisplayName(string $crewUpSetupDisplayName): self
  1726.     {
  1727.         $this->crewUpSetupDisplayName $crewUpSetupDisplayName;
  1728.         return $this;
  1729.     }
  1730.     public function getCrewUpSetupTextDescription(): ?string
  1731.     {
  1732.         return ($this->crewUpSetupTextDescription === null || $this->crewUpSetupTextDescription === '')
  1733.             ? null
  1734.             $this->crewUpSetupTextDescription;
  1735.     }
  1736.     public function setCrewUpSetupTextDescription(?string $crewUpSetupTextDescription): self
  1737.     {
  1738.         $this->crewUpSetupTextDescription = ($crewUpSetupTextDescription === '' null $crewUpSetupTextDescription);
  1739.         return $this;
  1740.     }
  1741. }