当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayCollection::map方法代码示例

本文整理汇总了PHP中Doctrine\Common\Collections\ArrayCollection::map方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayCollection::map方法的具体用法?PHP ArrayCollection::map怎么用?PHP ArrayCollection::map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\Common\Collections\ArrayCollection的用法示例。


在下文中一共展示了ArrayCollection::map方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getParentPagesQuery

 /**
  * @param $locale
  * @param null $id
  * @param bool $showHome
  * @param bool $showChildren
  * @return \Doctrine\ORM\QueryBuilder|mixed
  */
 public function getParentPagesQuery($locale, $id = null, $showHome = false, $showChildren = false)
 {
     $qb = $this->createQueryBuilder('p');
     if (!$showHome) {
         $qb->where($qb->expr()->isNull('p.isHome') . ' OR p.isHome <> 1');
     }
     if ($id) {
         if (!$showChildren) {
             /** @var $page PageInterface */
             $page = $this->find($id);
             $collection = new ArrayCollection($page->getAllChildren());
             $childrenIds = $collection->map(function (PageInterface $p) {
                 return $p->getId();
             });
             if ($childrenIds->count()) {
                 $qb->andWhere($qb->expr()->notIn('p.id', $childrenIds->toArray()));
             }
         }
         $qb->andWhere($qb->expr()->neq('p.id', $id));
     }
     $qb->andWhere('p.locale = :locale');
     $qb->orderBy('p.path', 'ASC');
     $qb->setParameter(':locale', $locale);
     return $qb;
 }
开发者ID:lzdv,项目名称:init-cms-bundle,代码行数:32,代码来源:PageManager.php

示例2: load

 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     if (!$this->isEnabled()) {
         return;
     }
     $limit = $this->container->getParameter('fixtures_product_limit');
     $faker = $this->getFakerGenerator();
     $names = [];
     for ($i = 0; $i < $limit; $i++) {
         $sentence = $faker->unique()->sentence(3);
         $name = substr($sentence, 0, strlen($sentence) - 1);
         $names[$name] = $name;
     }
     $products = new ArrayCollection();
     foreach ($names as $name) {
         $products->add($this->createRandomProduct($name, $manager));
     }
     $manager->flush();
     $products->map(function (ProductInterface $product) {
         $product->getCategories()->map(function (CategoryInterface $category) {
             $category->setProductsCount($category->getProducts()->count());
             $category->setChildrenCount($category->getChildren()->count());
         });
     });
     $manager->flush();
 }
开发者ID:WellCommerce,项目名称:ProductBundle,代码行数:29,代码来源:LoadProductData.php

示例3: getKnownJobs

 /**
  * @return ArrayCollection|string[]
  */
 public function getKnownJobs()
 {
     $data = new ArrayCollection($this->findAll());
     return $data->map(function (CronJobInterface $o) {
         return $o->getCommand();
     });
 }
开发者ID:shapecode,项目名称:cron-bundle,代码行数:10,代码来源:CronJobRepository.php

示例4: map

 public function map(Closure $func)
 {
     if (null === $this->entries) {
         $this->__load___();
     }
     return $this->entries->map($func);
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:7,代码来源:AggregateEntryCollection.php

示例5: __toString

 /**
  * Returns headers collection as string.
  *
  * @todo: Should implement SerializableInterface
  * So we can call serializer on it. Without this freaky __toString method.
  *
  * This is shit. No time. Have to have working prototype.
  *
  * @return string
  */
 public function __toString()
 {
     /**
      * Walk through array and make it strings
      *
      * @var ArrayCollection
      */
     $collection = $this->collection->map(function ($element) {
         return $element->stringify();
     });
     /**
      * Each header in new line, Use Stringify thingy?
      */
     return implode("\n\r", $collection->toArray());
 }
开发者ID:wotek,项目名称:response-builder,代码行数:25,代码来源:Fields.php

示例6: getVoteSum

 /**
  * Returns a summary of the votes up/down/total
  *
  * @return \stdClass
  */
 public function getVoteSum()
 {
     $votesStats = new \stdClass();
     $votesStats->up = 0;
     $votesStats->down = 0;
     $votesStats->total = 0;
     $counter = function ($vote) use($votesStats) {
         if ($vote->getValue()) {
             $votesStats->up++;
         } else {
             $votesStats->down++;
         }
         $votesStats->total += $vote->getValue();
     };
     $this->votes->map($counter);
     return $votesStats;
 }
开发者ID:rdohms,项目名称:fixthatcode.com,代码行数:22,代码来源:Comment.php

示例7: getMemberUids

 /**
  * @return ArrayCollection
  *
  * @Assert\NotBlank()
  */
 public function getMemberUids()
 {
     return $this->memberUids->map(function ($member) {
         return $member->get();
     })->getValues();
 }
开发者ID:LenticularCloud,项目名称:Cloud-Ldap-Admin,代码行数:11,代码来源:PosixGroup.php

示例8: getView

 /**
  * Get view
  *
  * @return object
  */
 public function getView()
 {
     try {
         $view = new ArticleView(array('number' => $this->number, 'language' => $this->language->getCode(), 'languageId' => $this->language->getId(), 'title' => $this->name, 'updated' => $this->updated, 'published' => $this->published, 'indexed' => $this->indexed, 'onFrontPage' => $this->onFrontPage, 'onSection' => $this->onSection, 'type' => $this->type, 'webcode' => $this->getWebcode(), 'publication_number' => $this->publication ? $this->publication->getId() : null, 'issue_number' => $this->issue ? $this->issue->getNumber() : null, 'section_number' => $this->section ? $this->section->getNumber() : null, 'keywords' => array_filter(explode(',', $this->keywords))));
     } catch (EntityNotFoundException $e) {
         return new ArticleView();
     }
     $view->authors = $this->authors->map(function ($author) {
         return $author->getView()->name;
     })->toArray();
     $view->topics = $this->topics->map(function ($topic) {
         return $topic->getView()->name;
     })->toArray();
     $this->addFields($view);
     return $view;
 }
开发者ID:alvsgithub,项目名称:Newscoop,代码行数:21,代码来源:Article.php

示例9: testReferenceMany

 public function testReferenceMany()
 {
     $colPush = new ArrayCollection(array(new GH453ReferencedDocument(), new GH453ReferencedDocument(), new GH453ReferencedDocument()));
     $colSet = $colPush->map(function ($v) {
         return clone $v;
     });
     $colSetArray = $colPush->map(function ($v) {
         return clone $v;
     });
     $colAddToSet = $colPush->map(function ($v) {
         return clone $v;
     });
     $dm = $this->dm;
     $colPush->forAll(function ($k, $v) use($dm) {
         $dm->persist($v);
         return true;
     });
     $colSet->forAll(function ($k, $v) use($dm) {
         $dm->persist($v);
         return true;
     });
     $colSetArray->forAll(function ($k, $v) use($dm) {
         $dm->persist($v);
         return true;
     });
     $colAddToSet->forAll(function ($k, $v) use($dm) {
         $dm->persist($v);
         return true;
     });
     $doc = new GH453Document();
     $doc->referenceManyPush = $colPush;
     $doc->referenceManySet = $colSet;
     $doc->referenceManySetArray = $colSetArray;
     $doc->referenceManyAddToSet = $colAddToSet;
     $this->dm->persist($doc);
     $this->dm->flush();
     $this->dm->clear();
     // No need to assert the value of the referenced document structure
     $this->assertBsonArray($doc->id, 'referenceManyPush');
     $this->assertBsonArray($doc->id, 'referenceManySet');
     $this->assertBsonArray($doc->id, 'referenceManySetArray');
     $this->assertBsonArray($doc->id, 'referenceManyAddToSet');
     // Check that the value is changed properly
     unset($colPush[1], $colSet[1], $colSetArray[1], $colAddToSet[1]);
     $doc->referenceManyPush = $colPush;
     $doc->referenceManySet = $colSet;
     $doc->referenceManySetArray = $colSetArray;
     $doc->referenceManyAddToSet = $colAddToSet;
     /* Merging must be done after re-assigning the collections, as the
      * referenced documents must be re-persisted through the merge cascade.
      */
     $doc = $this->dm->merge($doc);
     $this->dm->flush();
     $this->dm->clear();
     $this->assertBsonArray($doc->id, 'referenceManyPush');
     $this->assertBsonObject($doc->id, 'referenceManySet');
     $this->assertBsonArray($doc->id, 'referenceManySetArray');
     $this->assertBsonArray($doc->id, 'referenceManyAddToSet');
 }
开发者ID:Wizkunde,项目名称:mongodb-odm,代码行数:59,代码来源:GH453Test.php

示例10: toBatch

 /**
  * @param ArrayCollection $emails
  *
  * @return string[]
  */
 protected function toBatch(ArrayCollection $emails, $deep = true)
 {
     return $emails->map(function ($email) use($deep) {
         return array('email' => $deep ? array('email' => $email) : $email, 'email_type' => 'html');
     })->toArray();
 }
开发者ID:Ravetracer,项目名称:www,代码行数:11,代码来源:MailChimpUpdateParticipantsListCommand.php

示例11: getGroupsCode

 /**
  * @param ArrayCollection $groups
  *
  * @return array
  */
 protected function getGroupsCode(ArrayCollection $groups)
 {
     return $groups->map(function (GroupInterface $group) {
         return $group->getCode();
     })->toArray();
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:11,代码来源:AddToGroups.php

示例12: getLocaleCodes

 /**
  * {@inheritdoc}
  */
 public function getLocaleCodes()
 {
     return $this->locales->map(function ($locale) {
         return $locale->getCode();
     })->toArray();
 }
开发者ID:qrz-io,项目名称:pim-community-dev,代码行数:9,代码来源:Channel.php

示例13: getMembers

 /**
  * @return array
  * @Assert\Count(min="1",minMessage="member not set")
  */
 public function getMembers()
 {
     return $this->members->map(function ($value) {
         return $value->get();
     })->getValues();
 }
开发者ID:LenticularCloud,项目名称:Cloud-Ldap-Admin,代码行数:10,代码来源:GroupOfNames.php

示例14: combinePasswdAndGroup

 /**
  * Combine the Passwd and Group collections
  *
  * @param object $passwd The passwd collection
  * @param object $group The group collection
  *
  * @return object The userInfo collection
  */
 private function combinePasswdAndGroup(Collection $passwd, Collection $group)
 {
     $userInfo = new Collection();
     /**
      * Iterate over all the users in the passwd collection
      */
     $passwd->map(function ($user) use($group, $userInfo) {
         /**
          * Get the groups this user is a member of
          */
         $groupItems = $group->filter(function ($group) use($user) {
             if (in_array($user["username"], $group["users"])) {
                 return true;
             }
             return false;
         });
         /**
          * Get only the group names and store them
          */
         $groups = [];
         foreach ($groupItems as $groupItem) {
             if ($groupItem["name"] != "") {
                 $groups[] = $groupItem["name"];
             }
         }
         /**
          * Add the secondary groups to the user's groups array
          */
         $user["groups"] = $groups;
         /**
          * Get the main group for the current user
          */
         $mainGroup = $this->getGroupById($user["gid"])["name"];
         /**
          * Add the user's main group to the groups list if it isn't already
          */
         if (!in_array($mainGroup, $user["groups"])) {
             $user["groups"][] = $mainGroup;
         }
         /**
          * Finally, add the user to the userInfo collection
          */
         $userInfo->add($user);
     });
     return $userInfo;
 }
开发者ID:breaker1,项目名称:passwd,代码行数:54,代码来源:Passwd.php

示例15: map

 function map(\Closure $func)
 {
     return $this->fields->map($func);
 }
开发者ID:tomaszhanc,项目名称:form-field-bundle,代码行数:4,代码来源:FieldCollection.php


注:本文中的Doctrine\Common\Collections\ArrayCollection::map方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。