/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $this->users = $this->user->findAll(); $this->organization = $this->getReference('default_organization'); $this->loadCalendars(); $this->connectCalendars(); }
/** * Get the attribute collection * * @return JsonResponse */ public function indexAction() { $attributes = $this->attributeRepository->findAll(); $filteredAttributes = $this->collectionFilter->filterCollection($attributes, 'pim.internal_api.attribute.view'); $normalizedAttributes = $this->normalizer->normalize($filteredAttributes, 'internal_api'); return new JsonResponse($normalizedAttributes); }
/** * {@inheritdoc} */ public function getFormValue(array $converterAttributes, $value) { if ($value === null) { return $this->businessUnitRepository->findAll(); } return parent::getFormValue($converterAttributes, $value); }
protected function givenDatabaseIsClear() { if (0 !== count($this->items->findAll())) { $purger = new ORMPurger($this->entityManager); $purger->purge(); } }
/** * @return \Generator */ private function getEmoteGenerator() { /** @var Emote[] $emotes */ $emotes = $this->entityRepository->findAll(); foreach ($emotes as $emote) { (yield $emote); } }
/** * Get the family collection * * @return JsonResponse */ public function indexAction() { $families = $this->familyRepository->findAll(); $normalizedFamilies = []; foreach ($families as $family) { $normalizedFamilies[$family->getCode()] = $this->normalizer->normalize($family, 'json'); } return new JsonResponse($normalizedFamilies); }
/** * Reads all settings from database. * * @return void */ private function readSettings() { /** * @var \Ableron\Modules\Core\Model\Entities\SettingEntity $settingEntity */ foreach ($this->settingEntityRepository->findAll() as $settingEntity) { $this->settings->set($settingEntity->getName(), $settingEntity); } }
/** * Get attribute group collection * * @return JsonResponse */ public function indexAction() { $attributeGroups = $this->attributeGroupRepo->findAll(); $filteredAttrGroups = $this->collectionFilter->filterCollection($attributeGroups, 'pim.internal_api.attribute_group.view'); $normalizedAttrGroups = []; foreach ($filteredAttrGroups as $attributeGroup) { $normalizedAttrGroups[$attributeGroup->getCode()] = $this->normalizer->normalize($attributeGroup, 'json'); } return new JsonResponse($normalizedAttrGroups); }
/** * @return NotificationPluginConfiguration|null */ public function getConfigOrEmpty() { $result = $this->notificationPluginConfigurationRepository->findAll(); $config = null; if (count($result) > 0) { $config = $result[0]; } else { $config = new NotificationPluginConfiguration(); } return $config; }
/** * Reads event handlers from database. * * Event handlers can be stored in database, so they do not have to be * registered at the event manager manually during script execution. * * @return void */ private function readEventHandlers() { /** @var \Ableron\Modules\Core\Model\Entities\EventHandlerEntity $eventHandlerEntity */ foreach ($this->eventHandlerEntityRepository->findAll() as $eventHandlerEntity) { $this->registerEventHandler($eventHandlerEntity->getEventName(), ClassUtil::getInstance($eventHandlerEntity->getEventHandlerClass())); } }
function it_handles_a_find_all_query(FindAll $query, EntityRepository $repository, EntityManagerInterface $em) { $query->getEntityClass()->willReturn('Indigo\\Crud\\Stub\\Entity'); $repository->findAll()->shouldBeCalled(); $em->getRepository('Indigo\\Crud\\Stub\\Entity')->willReturn($repository); $this->handle($query); }
public function initialize(RequestConfiguration $requestConfiguration, MetadataInterface $metadataInterface, $resource, EntityRepository $repository) { if (!$requestConfiguration->isSortable()) { return; } $accessor = PropertyAccess::createPropertyAccessor(); $property = $requestConfiguration->getSortablePosition(); $strategy = $requestConfiguration->getSortingStrategy(); if ($strategy == self::STRATEGY_DESC_LAST || $strategy == self::STRATEGY_ASC_FIRST) { // target value is 0, and we need to move all other elements one up $existingResources = $repository->findAll(); if ($existingResources) { foreach ($existingResources as $existingResource) { if ($resource === $existingResource) { continue; } $value = $accessor->getValue($existingResource, $property); $accessor->setValue($existingResource, $property, $value + 1); } } $newValue = 0; } else { // Initial value is maximum of other elements + 1 $maxResource = $repository->createQueryBuilder('r')->orderBy('r.' . $property, 'desc')->setMaxResults(1)->getQuery()->getOneOrNullResult(); if (!$maxResource) { $newValue = 0; } else { $maxValue = $accessor->getValue($maxResource, $property); $newValue = $maxValue + 1; } } $accessor->setValue($resource, $property, $newValue); $this->em->flush(); }
public function findAll($published = false) { if (!$published) { return parent::findAll(); } else { return $this->getPublishedProjectsQuery(); } }
public function getItems() { $accessor = PropertyAccess::createPropertyAccessor(); $objects = $this->repository->findAll(); $items = []; foreach ($objects as $object) { $item = new Item(); $item->setValue($object); $properties = array(); foreach ($this->itemProperties as $itemProperty => $itemPropertyLabel) { $properties[$itemProperty] = $accessor->getValue($object, $itemProperty); } $item->setProperties($properties); $items[] = $item; } return $items; }
function it_returns_article_category_list(EntityRepository $repository) { $firstArticleCategory = new ArticleCategory(); $firstArticleCategory->setSlug('chrono-trigger'); $secondArticleCategory = new ArticleCategory(); $secondArticleCategory->setSlug('chrono-cross'); $repository->findAll()->willReturn([$firstArticleCategory, $secondArticleCategory]); $this->getAll()->shouldReturn([$firstArticleCategory, $secondArticleCategory]); }
public function __construct(Notifier $notifier, PercentageHelper $percentageHelper, EntityRepository $triggerRepository, EntityRepository $serviceRepository, NotificationLogService $notificationLogService, Comparator $comparator) { $this->notifier = $notifier; $this->percentageHelper = $percentageHelper; $this->triggers = $triggerRepository->findAll(); $this->serviceRepository = $serviceRepository; $this->notificationLogService = $notificationLogService; $this->comparator = $comparator; }
protected function execute(InputInterface $input, OutputInterface $output) { $app = $this->getProjectApplication(); $this->logger = $this->getLogger(); $this->regionService = $app['region.skyforge.service']; $this->regionService->setRegion($input->getOption('region')); $this->em = $app['orm.ems'][$this->regionService->getDbConnectionNameByRegion()]; $this->pantheonRepository = $this->em->getRepository('Erliz\\SkyforgeBundle\\Entity\\Pantheon'); if ($input->getOption('id')) { $this->updateCommunityDateStat($this->pantheonRepository->find($input->getOption('id')), $output); } else { /** @var Pantheon $community */ foreach ($this->pantheonRepository->findAll() as $community) { $this->updateCommunityDateStat($community, $output); } } $this->em->flush(); }
protected function connectCalendars() { /** @var \Oro\Bundle\UserBundle\Entity\User[] $users */ $users = $this->user->findAll(); // first user is admin, often /** @var \Oro\Bundle\UserBundle\Entity\User $admin */ $admin = $this->user->find(1); /** @var Calendar $calendarAdmin */ $calendarAdmin = $this->calendar->findDefaultCalendar($admin->getId(), $admin->getOrganization()->getId()); /** @var \Oro\Bundle\UserBundle\Entity\User $sale */ $sale = $this->user->findOneBy(['username' => 'sale']); /** @var Calendar $calendarSale */ $calendarSale = $this->calendar->findDefaultCalendar($sale->getId(), $sale->getOrganization()->getId()); /** @var \Oro\Bundle\UserBundle\Entity\User $market */ $market = $this->user->findOneBy(['username' => 'marketing']); /** @var Calendar $calendarMarket */ $calendarMarket = $this->calendar->findDefaultCalendar($market->getId(), $market->getOrganization()->getId()); $i = 0; while ($i <= 5) { //get random user $userId = mt_rand(2, count($users) - 1); $user = $users[$userId]; unset($users[$userId]); $users = array_values($users); if (in_array($user->getId(), [$admin->getId(), $sale->getId(), $market->getId()])) { //to prevent self assignment continue; } /** @var Calendar $calendar */ $calendar = $this->calendar->findDefaultCalendar($user->getId(), $user->getOrganization()->getId()); if (mt_rand(0, 1)) { $calendarProperty = new CalendarProperty(); $calendarProperty->setTargetCalendar($calendarAdmin)->setCalendarAlias('user')->setCalendar($calendar->getId()); $this->persist($this->container->get('doctrine.orm.entity_manager'), $calendarProperty); } if (mt_rand(0, 1)) { $calendarProperty = new CalendarProperty(); $calendarProperty->setTargetCalendar($calendarSale)->setCalendarAlias('user')->setCalendar($calendar->getId()); $this->persist($this->container->get('doctrine.orm.entity_manager'), $calendarProperty); } if (mt_rand(0, 1)) { $calendarProperty = new CalendarProperty(); $calendarProperty->setTargetCalendar($calendarMarket)->setCalendarAlias('user')->setCalendar($calendar->getId()); $this->persist($this->container->get('doctrine.orm.entity_manager'), $calendarProperty); } $this->persist($this->container->get('doctrine.orm.entity_manager'), $calendar); $i++; } $this->flush($this->container->get('doctrine.orm.entity_manager')); }
/** * * @return array */ public function getAllAsArray(Organisation $organisation = null) { $list = array(); if ($organisation) { $criteria = Criteria::create()->where(Criteria::expr()->eq('organisation', $organisation)); $list = parent::matching($criteria); } else { $list = parent::findAll(); } $res = array(); foreach ($list as $element) { $res[$element->getId()] = $element->getName(); } return $res; }
/** * Returns all the resource types introduced by plugins. * * @return array[ResourceType] */ public function findAll($filterEnabled = true) { if (!$filterEnabled) { return parent::findAll(); } $dql = ' SELECT rt, ma FROM Claroline\\CoreBundle\\Entity\\Resource\\ResourceType rt LEFT JOIN rt.actions ma LEFT JOIN rt.plugin p WHERE (CONCAT(p.vendorName, p.bundleName) IN (:bundles) OR rt.plugin is NULL) AND rt.isEnabled = true'; $query = $this->_em->createQuery($dql); $query->setParameter('bundles', $this->bundles); return $query->getResult(); }
protected function addQueuesToTemplate(EntityRepository $queueRepository) { global $container; /** @var Queue[] $queueDataCollection */ $queueDataCollection = $queueRepository->findAll(); $items = array(); /** @var QueueInterface $queue */ foreach ($queueDataCollection as $queueData) { $serviceName = sprintf('avisota.queue.%s', $queueData->getId()); $queue = $container[$serviceName]; $item['meta'] = $queueData; $item['queue'] = $queue; $items[] = $item; } $this->Template->items = $items; }
/** * Find all themes from given source * * @param string $from * @return array */ public function findAll() { // get installed versions $installed = array(); foreach (parent::findAll() as $theme) { $installed[$theme->getOffset()] = $theme; } $themes = $this->loader->findAll(); foreach ($themes as $theme) { $offset = $theme->getOffset(); if (isset($installed[$offset])) { $installedTheme = $installed[$offset]; $theme->setId($installedTheme->getId())->setInstalledVersion($installedTheme->getInstalledVersion()); } } return $themes; }
/** * * @return array */ public function getAllAsArray($criteria = null) { $list = array(); if ($criteria === null) { $list = parent::findAll(); } else { if ($criteria instanceof Criteria) { $list = parent::matching($criteria); } else { $list = parent::findBy($criteria); } } $res = array(); foreach ($list as $element) { $res[$element->getId()] = $element->getName(); } return $res; }
public function adsCheckerAction() { ini_set('ignore_user_abort', 1); ini_set('max_execution_time', 120); /**@var $campaign VkCampaigns*/ /**@var $vkAd VkAds*/ /**@var $vkAccount VkAccounts*/ /**@var $cabinet Cabinets*/ if (date('i') % 29 === 0 || date('i') % 30 === 0) { $vkAccounts = $this->vkAccountsRepository->findAll(); foreach ($vkAccounts as $vkAccount) { $vkApi = Vk\Core::getInstance()->apiVersion('5.5')->setToken($vkAccount->getAccessKey()); $cabinetsInVk = $vkApi->request('ads.getAccounts')->getResponse(); foreach ($cabinetsInVk as $cabinetInVk) { $vkCabinetCheck = $this->getObjectManager()->getRepository('\\Socnet\\Entity\\Cabinets')->findBy(['account_id' => $cabinetInVk->account_id, 'vk_account_id' => $vkAccount->getId()]); if (!$vkCabinetCheck) { $vkCabinetEntity = new Cabinets(); foreach ($cabinetInVk as $key => $value) { $vkCabinetEntity->set($key, $value); } $vkCabinetEntity->setVkUserId($vkAccount->getVkUserId()); $vkCabinetEntity->setVkAccountId($vkAccount->getId()); $this->getObjectManager()->persist($vkCabinetEntity); $params = ['account_id' => $cabinetInVk->account_id]; $clientsInVk = $vkApi->request('ads.getClients', $params)->getResponse(); foreach ($clientsInVk as $client) { $vkClientCheck = $this->getObjectManager()->getRepository('\\Socnet\\Entity\\VkClients')->findBy(['id' => $client->id]); if (!$vkClientCheck) { $vkClientsEntity = new VkClients(); $vkClientsEntity->setAccountId($cabinetInVk->account_id); $vkClientsEntity->setBidderAccountId($vkAccount->getId()); foreach ($client as $key => $value) { $vkClientsEntity->set($key, $value); } $this->getObjectManager()->persist($vkClientsEntity); } } } } } $this->getObjectManager()->flush(); } return true; }
protected function paginateObject(Request $request, EntityRepository $repository, $whereCriteria = null) { $curPage = $request->getRequestUri(); $page = $request->get('page', '1'); $maxr = $request->get('maxr', '10'); $skip = ($page - 1) * $maxr; $objects = $repository->findBy([], null, $maxr, $skip); $totalObjects = count($repository->findAll()); $payload = ["payload" => $objects]; $payload['pagination']['total'] = $totalObjects; $payload['pagination']['hasNext'] = false; $payload['pagination']['hasPrev'] = false; $payload['pagination']['currentPage'] = $page; $payload['pagination']['maxRecords'] = $maxr; if ($skip + $maxr < $totalObjects) { $payload['pagination']['nextPage'] = preg_replace("/page=\\d+/i", "page=" . ($page + 1), $curPage); $payload['pagination']['hasNext'] = true; } if ($skip > 0) { $payload['pagination']['prevPage'] = preg_replace("/page=\\d+/i", "page=" . ($page - 1), $curPage); $payload['pagination']['hasPrev'] = true; } return $payload; }
/** * @return array of categories */ public function findAllCategories() { return $this->repository->findAll(); }
/** * Returns all the groups by search. * * @param string $search * * @return array[Group] */ public function findAllGroupsBySearch($search) { $upperSearch = strtoupper(trim($search)); if ($search !== '') { $dql = ' SELECT g FROM Claroline\\CoreBundle\\Entity\\Group g WHERE UPPER(g.name) LIKE :search '; $query = $this->_em->createQuery($dql); $query->setParameter('search', "%{$upperSearch}%"); return $query->getResult(); } return parent::findAll(); }
protected function loadFromDB() { return $list = $this->repository->findAll(); }
/** * {@inheritdoc} */ public function findAll() { return new Collection(parent::findAll()); }
public function fetchAll() { return $this->repository->findAll(); }