Example #1
0
 /**
  * @return ArrayCollection
  */
 protected function generateArchiveCollection()
 {
     $collection = new ArrayCollection();
     $custodianRepo = new CustodianRepository();
     $advisorCodeRepo = new AdvisorCodeRepository();
     foreach ($custodianRepo->findAll() as $custodian) {
         $codes = $advisorCodeRepo->findBy(array('custodian_id' => $custodian->getId()));
         foreach ($codes as $code) {
             $archive = new Archive();
             $archive->setDate($this->getDate());
             $archive->setCustodian($custodian->getShortName());
             $archive->setCustodianName($custodian->getName());
             $archive->setAdvisorCode($code->getName());
             $archive->setType('data');
             $collection->add($archive);
             $realized = clone $archive;
             $realized->setType('realized');
             $collection->add($realized);
             $unrealized = clone $archive;
             $unrealized->setType('unrealized');
             $collection->add($unrealized);
         }
     }
     return $collection;
 }
Example #2
0
 /**
  * @param array $argv
  * @return array
  * @throws \Exception
  */
 protected function loadFilePaths($argv)
 {
     $codeRepo = new AdvisorCodeRepo();
     $custodianRepo = new CustodianRepo();
     $paths = array();
     $codeName = isset($argv[3]) ? trim($argv[3]) : null;
     if ($codeName == null) {
         foreach ($custodianRepo->findAll() as $custodian) {
             $codes = $codeRepo->findBy(array('custodian_id' => $custodian->getId()));
             foreach ($codes as $code) {
                 $paths[] = $this->getFilePath($custodian->getShortName(), $code->getName());
             }
         }
         return $paths;
     }
     if (null == ($code = $codeRepo->findOneBy(array('name' => $codeName)))) {
         throw new \Exception("Advisor code [{$codeName}] not found");
     }
     if (null == ($custodian = $custodianRepo->find($code->getCustodianId()))) {
         throw new \Exception("Custodian by advisor code [{$codeName}] not found");
     }
     $paths[] = $this->getFilePath($custodian->getShortName(), $code->getName());
     return $paths;
 }