partition() public method

{@inheritDoc}
public partition ( Closure $p )
$p Closure
 public function partition(Closure $p)
 {
     if (null === $this->entries) {
         $this->__load___();
     }
     return $this->entries->partition($p);
 }
示例#2
0
 /**
  * Fetchs current user baskets
  *
  * @param  Application $app
  * @param  Request     $request
  * @return Response
  */
 public function getBaskets(Application $app, Request $request)
 {
     $selectedBasketId = trim($request->get('courChuId', ''));
     $baskets = new ArrayCollection($app['EM']->getRepository('Phraseanet:Basket')->findActiveByUser($app['authentication']->getUser()));
     $selectedBasket = null;
     if ('' === $selectedBasketId && $baskets->count() > 0) {
         $selectedBasketId = $baskets->first()->getId();
     }
     if ('' !== $selectedBasketId) {
         $selectedBasket = $app['converter.basket']->convert($selectedBasketId);
         $app['acl.basket']->isOwner($selectedBasket, $app['authentication']->getUser());
     }
     $basketCollections = $baskets->partition(function ($key, $basket) {
         return null !== $basket->getPusher();
     });
     return $app['twig']->render('client/baskets.html.twig', ['total_baskets' => $baskets->count(), 'user_baskets' => $basketCollections[1], 'recept_user_basket' => $basketCollections[0], 'selected_basket' => $selectedBasket, 'selected_basket_elements' => $selectedBasket ? $selectedBasket->getElements() : new ArrayCollection()]);
 }
示例#3
0
 /**
  * Partitions this collection in two collections according to a predicate.
  * Keys are preserved in the resulting collections.
  *
  * @param Closure $p The predicate on which to partition.
  *
  * @return array An array with two elements. The first element contains the collection
  *               of elements where the predicate returned TRUE, the second element
  *               contains the collection of elements where the predicate returned FALSE.
  */
 public function partition(Closure $p)
 {
     return $this->collection->partition($p);
 }
 /** {@inheritDoc} */
 public function partition(Closure $p)
 {
     $this->initialize();
     return $this->collection->partition($p);
 }
 function partition(\Closure $p)
 {
     return $this->fields->partition($p);
 }