Exemplo n.º 1
0
 /**
  * 
  * Class constructor
  * @param ContainerInterface
  *
  */
 public function __construct(ContainerInterface $container)
 {
     $this->container = $container;
     $this->doctrine = $this->container->get('doctrine');
     $this->em = $this->doctrine->getManager();
     $this->repo = $this->doctrine->getRepository('UKMecoBundle:Transaction');
 }
Exemplo n.º 2
0
 /**
  * 
  * Class constructor
  * @param ContainerInterface
  *
  */
 public function __construct(ContainerInterface $container)
 {
     $this->container = $container;
     $this->doctrine = $this->container->get('doctrine');
     $this->em = $this->doctrine->getManager();
     $this->repo = $this->doctrine->getRepository('UKMecoBundle:SubProject');
     $this->environment = $this->container->get('kernel')->getEnvironment();
 }
Exemplo n.º 3
0
 /**
  * 
  * Class constructor
  * @param ContainerInterface
  *
  */
 public function __construct(ContainerInterface $container)
 {
     $this->container = $container;
     $this->doctrine = $this->container->get('doctrine');
     $this->em = $this->doctrine->getManager();
     $this->budgetRepo = $this->doctrine->getRepository('UKMecoBundle:Budget');
     $this->projectRepo = $this->doctrine->getRepository('UKMecoBundle:Project');
     $this->subProjectRepo = $this->doctrine->getRepository('UKMecoBundle:SubProject');
     $this->projectAllocatedAmountRepo = $this->doctrine->getRepository('UKMecoBundle:ProjectAllocatedAmount');
     $this->subProjectAllocatedAmountRepo = $this->doctrine->getRepository('UKMecoBundle:SubProjectAllocatedAmount');
     $this->transactionRepo = $this->doctrine->getRepository('UKMecoBundle:Transaction');
 }
Exemplo n.º 4
0
 /**
  * Set Allocated Amount
  *
  * @param project
  * @param integer year
  * @param integer amount
  * @return AllocatedAmount
  */
 public function setAllocatedAmount($project, $year, $amount)
 {
     $this->_validate($project);
     if (!is_numeric($year) || !is_integer($year)) {
         throw new Exception('Given year is not an integer! Given ' . gettype($year) . ' "' . $year . '"');
     }
     if (!is_numeric($amount) || !is_integer($amount)) {
         throw new Exception('Given amount is not an integer! Given ' . gettype($amount) . ' "' . $amount . '"');
     }
     $allocatedAmountRepo = $this->doctrine->getRepository('UKMecoBundle:ProjectAllocatedAmount');
     $allocatedAmount = $allocatedAmountRepo->findOneBy(array('project' => $project, 'year' => $year));
     if (is_null($allocatedAmount)) {
         $allocatedAmount = new ProjectAllocatedAmount();
         $allocatedAmount->setProject($project);
         $allocatedAmount->setYear($year);
     }
     // TODO: Delete from DB if amount == 0
     $allocatedAmount->setAmount($amount);
     $this->_persistAndFlush($allocatedAmount);
     return $allocatedAmount;
 }