/** * Gets the memberData from association.typo3.org and uses this data to * - update membership level and amount of caseStudies allowed in agency * - deactivates caseStudies if allowed amount is lower than activated caseStudies * * @return void */ protected function updateAgenciesByMemberDataAction() { $memberDataUtility = $this->objectManager->get('Tx_Typo3Agencies_Utility_MemberData'); $memberDataArray = $memberDataUtility->getAllMemberData(); foreach ($memberDataArray as $memberData) { $agency = $this->agencyRepository->findOneByCode($memberData['code']); if ($agency) { /** @var $agency Tx_Typo3Agencies_Domain_Model_Agency */ $approved = $memberData['isApproved'] == 1 ? true : false; $allowedCaseStudies = $approved ? (int) $memberData['caseStudies'] : 0; $agency->setApproved($approved); $agency->setCaseStudies($allowedCaseStudies); $agency->setMember($memberData['membershipLevel']); $references = $this->referenceRepository->findAllByAgency($agency); foreach ($references as $reference) { /** @var $reference Tx_Typo3Agencies_Domain_Model_Reference */ if ($allowedCaseStudies <= 0) { $reference->setDeactivated(true); } $allowedCaseStudies--; $this->referenceRepository->update($reference); } $this->agencyRepository->update($agency); } } $GLOBALS['TSFE']->clearPageCacheContent_pidList($this->clearCachePids); }
protected function removeNotSet(&$request, &$allowedCategories, &$allowedIndustries, &$allowedRevenues) { $arguments = $request->getArguments(); $categoryValue = 0; if ($arguments['filter']['category']) { $categoryValue = intval($arguments['filter']['category']); // 5 } $industryValue = 0; if ($arguments['filter']['industry']) { $industryValue = intval($arguments['filter']['industry']); // 4 } $revenueValue = 0; if ($arguments['filter']['revenue']) { $revenueValue = intval($arguments['filter']['revenue']); // 4 } $remove = array(); foreach ($allowedCategories as $uid => $category) { $count = $this->referenceRepository->countByOption($category->getUid(), $industryValue, $revenueValue, $this->showDeactivated); if ($count == 0) { $remove[$uid] = 'remove'; } } $allowedCategories = array_diff_key($allowedCategories, $remove); $remove = array(); foreach ($allowedIndustries as $uid => $industry) { $count = $this->referenceRepository->countByOption($categoryValue, $industry->getUid(), $revenueValue, $this->showDeactivated); if ($count == 0) { $remove[$uid] = 'remove'; } } $allowedIndustries = array_diff_key($allowedIndustries, $remove); $remove = array(); foreach ($allowedRevenues as $uid => $revenue) { $count = $this->referenceRepository->countByOption($categoryValue, $industryValue, $revenue->getUid(), $this->showDeactivated); if ($count == 0) { $remove[$uid] = 'remove'; } } $allowedRevenues = array_diff_key($allowedRevenues, $remove); }