public function setDefaultConfig($key, $value, $type, $section = "default") { $valueArray = new \Doctrine\Common\Collections\ArrayCollection(); $valueArray->set('value', $value); $valueArray->set('section', $section); $valueArray->set('key', $key); $valueArray->set('type', $type); $this->configList->set($section . '.' . $key, $valueArray); }
public function denormalize(array $input, $context = null) { $collection = new \Doctrine\Common\Collections\ArrayCollection(); foreach ($array as $key => $value) { $collection->set($key, parent::normalize($input)); } return new PersistentCollection($this->getEntityManager(), $this->getClassMetadata()->getName(), $collection); }
protected function getUsersInSelectionExtractor() { return function (array $selection) { $Users = new \Doctrine\Common\Collections\ArrayCollection(); foreach ($selection as $record) { /* @var $record record_adapter */ foreach ($record->get_caption()->get_fields() as $caption_field) { foreach ($caption_field->get_values() as $value) { if (!$value->getVocabularyType()) { continue; } if ($value->getVocabularyType()->getType() !== 'User') { continue; } $user = $value->getRessource(); $Users->set($user->getId(), $user); } } } return $Users; }; }
/** * @return bool|mixed|string */ public function repositorySearch() { $searchTerm = $this->request->post('term', ''); $availableExtensions = new \Doctrine\Common\Collections\ArrayCollection(); $unregisteredExtensions = $this->registryManager->getUnregisteredExtensions(); $installedExtensions = $this->db->getRepository('\\Fraym\\Registry\\Entity\\Registry')->findBy(array(), array('name' => 'asc')); $extensions = $this->registryManager->repositoryRequest('listModules', array('searchTerm' => $searchTerm, 'offset' => 0, 'limit' => 20)); foreach ($installedExtensions as $installedExtension) { $availableExtensions->set($installedExtension->repositoryKey, $installedExtension); } foreach ($unregisteredExtensions as $unregisteredExtension) { $availableExtensions->set($unregisteredExtension['repositoryKey'], $unregisteredExtension); } $this->view->assign('availableExtensions', $availableExtensions); $this->view->assign('extensions', $extensions ?: array()); return $this->template->fetch('RepositorySearch'); }
/** * @return bool|mixed|string */ public function repositorySearch() { $searchTerm = $this->request->post('term', ''); $extensions = $this->registryManager->searchPackage($searchTerm); $availableExtensions = new \Doctrine\Common\Collections\ArrayCollection(); $unregisteredExtensions = $this->registryManager->getUnregisteredExtensions(); $installedExtensions = $this->db->getRepository('\\Fraym\\Registry\\Entity\\Registry')->findBy([], ['name' => 'asc']); foreach ($installedExtensions as $installedExtension) { $availableExtensions->set($installedExtension->repositoryKey, $installedExtension); } foreach ($unregisteredExtensions as $unregisteredExtension) { $availableExtensions->set($unregisteredExtension['repositoryKey'], $unregisteredExtension); } $this->view->assign('availableExtensions', $availableExtensions); $this->view->assign('extensions', $extensions ?: []); return $this->view->fetch('RepositorySearch'); }
/** * @param null $children * @return \Doctrine\Common\Collections\ArrayCollection */ public function getActiveAndVisibleChildren($children = null) { $childrenCollection = new \Doctrine\Common\Collections\ArrayCollection(); if ($children === null) { $children = $this->children; } foreach ($children as $child) { if ($child->active === true && $child->visible === true) { $childrenCollection->set($child->id, $child); } } return $childrenCollection; }
/** * @param \SimpleXMLElement $obj * @param null $parent * @return \Doctrine\Common\Collections\ArrayCollection */ protected function getItems(\SimpleXMLElement $obj, $parent = null) { $returnChildren = new \Doctrine\Common\Collections\ArrayCollection(); foreach ($obj->children() as $objData) { $id = $this->blockParser->getXmlAttr($objData, 'id'); $menuItemTranslation = $this->db->createQueryBuilder()->select("menu, translation")->from('\\Fraym\\Menu\\Entity\\MenuItemTranslation', 'translation')->join('translation.menuItem', 'menu')->where('menu.id = :id AND translation.locale = :localeId AND translation.active = 1')->setParameter('id', $id)->setParameter('localeId', $this->route->getCurrentMenuItemTranslation()->locale->id)->getQuery()->getOneOrNullResult(); $this->db->free(); if ($menuItemTranslation) { $menuItem = clone $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItem')->findOneById($menuItemTranslation->menuItem->id); $children = $this->getItems($objData, $menuItem); $menuItem->parent = $parent; $menuItem->children = $children; $returnChildren->set($menuItem->id, $menuItem); } } return $returnChildren; }
/** * @return \Doctrine\Common\Collections\ArrayCollection */ public function getTranslationLanguages() { $translationLanguages = new \Doctrine\Common\Collections\ArrayCollection(); if (!($id = $this->getRequest()->get('id'))) { return false; } /** @var $pageManager PageManagerInterface */ $pageManager = $this->getContainer()->get('networking_init_cms.page_manager'); /** @var $page PageInterface */ $page = $pageManager->findById($id); $translatedLocales = $page->getAllTranslations(); $originalLocale = $page->getLocale(); foreach ($this->languages as $language) { if ($language['locale'] == $originalLocale) { continue; } if ($translatedLocales->containsKey($language['locale'])) { $translationLanguages->set($language['locale'], array('short_label' => $language['short_label'], 'translation' => $translatedLocales->get($language['locale']), 'label' => \Locale::getDisplayLanguage($language['locale']))); } else { $translationLanguages->set($language['locale'], array('short_label' => $language['short_label'], 'translation' => false, 'label' => \Locale::getDisplayLanguage($language['locale']))); } } return $translationLanguages; }