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


PHP ArrayCollection::isEmpty方法代码示例

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


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

示例1: processing

 /**
  * @param array $collection
  * @param MapInterface $map
  * @param ObjectFactoryInterface|string $factory
  * @param null $aggregator
  * @throws \InvalidArgumentException
  */
 public function processing(array $collection, MapInterface $map, $factory, $aggregator = null)
 {
     $this->aggregator = $aggregator;
     $this->collection = new ArrayCollection($collection);
     $this->map = $map;
     // Checking type of factory and then set as internal tool
     if (is_string($factory)) {
         $this->factory = $this->container->get($factory);
     } else {
         $this->factory = $factory;
     }
     if (count($collection) == 0) {
         throw new \InvalidArgumentException('Collection can\'t be null');
     }
     // Split collection to "new" and "exists"
     $this->ranking();
     // If collection "exists" not empty, then load items form database
     if (!$this->exists->isEmpty()) {
         $this->loadExistsObjects();
     }
     // If collection "new" not empty, then create new entities
     if (!$this->new->isEmpty()) {
         $this->createNewObjects();
     }
     // Clean internal "common" collection
     $this->collection->clear();
     // Clean aggregator
     $this->aggregator = null;
 }
开发者ID:Exanrus,项目名称:crm-bundle,代码行数:36,代码来源:ReverseCollectionTransformer.php

示例2: testLegacyChildClassOnSubmitCallParent

 /**
  * @group legacy
  */
 public function testLegacyChildClassOnSubmitCallParent()
 {
     $form = $this->getBuilder('name')->setData($this->collection)->addEventSubscriber(new TestClassExtendingMergeDoctrineCollectionListener())->getForm();
     $submittedData = array();
     $event = new FormEvent($form, $submittedData);
     $this->dispatcher->dispatch(FormEvents::SUBMIT, $event);
     $this->assertTrue($this->collection->isEmpty());
     $this->assertTrue(TestClassExtendingMergeDoctrineCollectionListener::$onBindCalled);
 }
开发者ID:symfony,项目名称:symfony,代码行数:12,代码来源:MergeDoctrineCollectionListenerTest.php

示例3: handle

 /**
  * Handle
  *
  * @param Transaction                         $transaction Transaction
  * @param CrudEntityInterface|ArrayCollection $data        Data
  * @param ConstraintViolationList|null        $violations  Violations
  *
  * @throws FeatureNotImplementedException
  *
  * @return CrudEntityInterface|CollectionResponse
  */
 public function handle(Transaction $transaction, $data, ConstraintViolationList $violations = null)
 {
     $this->errorBuilder->processViolations($violations);
     $this->errorBuilder->setTransactionErrors($transaction);
     $success = !$this->errorBuilder->hasErrors();
     $status = $success ? Transaction::STATUS_CREATED : Transaction::STATUS_CONFLICT;
     $transaction->setStatus($status);
     $transaction->setSuccess($success);
     if ($data instanceof ArrayCollection) {
         if ($data->isEmpty()) {
             $data = $this->handleEmptyCollection($transaction, $data);
         } else {
             $data = $this->handleCollection($transaction, $data);
         }
     } else {
         if ($data instanceof CrudEntityInterface) {
             $this->handleEntity($transaction, $data);
         } else {
             throw new FeatureNotImplementedException(get_class($data) . ' class is not supported by transactions (POST). Instance of ArrayCollection needed.');
         }
     }
     if (!$transaction->getSuccess()) {
         if ($data instanceof ArrayCollection) {
             $data->getItems()->clear();
         } else {
             $transaction->setRelatedIds(null);
             $data = new CollectionResponse(new ArrayCollection(array()));
             $data->setShowAssociations(true);
         }
     }
     return $data;
 }
开发者ID:RuslanZavacky,项目名称:EcentriaRestBundle,代码行数:43,代码来源:TransactionPostHandler.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getContainer()->get('doctrine.orm.entity_manager');
     $sources = $em->getRepository('MDSSiteBundle:Source')->findAll();
     $json = new ArrayCollection();
     $flag = '';
     foreach ($sources as $source) {
         try {
             $url = parse_url($source->getSrc());
             if ($flag !== $url['host']) {
                 $flag = $url['host'];
                 $src = $url['scheme'] . '://' . $url['host'] . ':' . $url['port'] . '/status-json.xsl';
                 $json->add(json_decode(file_get_contents($src)));
             }
         } catch (\Exception $e) {
             return false;
         }
     }
     if (!$json->isEmpty()) {
         foreach ($json as $value) {
             $source = $value->icestats->source;
             foreach ($source as $sourcevalue) {
                 //Получили тут все трансляции в массив
                 //Теперь нужно найти одинаковые по ключу и посчитать
                 //нужные данные (listeners) уникальные тут listenurl
                 $allsource[] = $sourcevalue;
             }
         }
         if (count($allsource)) {
             file_put_contents(__DIR__ . '/../../../../web/stats.txt', serialize($allsource));
         }
     }
     $output->writeln('Кудато что то записалось');
 }
开发者ID:Kolbasyatin,项目名称:mds,代码行数:34,代码来源:GetStatCommand.php

示例5: isRemovable

 /**
  * @return bool
  */
 public function isRemovable()
 {
     $ok = true;
     $ok = $ok && $this->applications->isEmpty();
     $ok = $ok && $this->fundraisers->isEmpty();
     return $ok;
 }
开发者ID:nuffer,项目名称:FundraisingDB,代码行数:10,代码来源:Provider.php

示例6: isEmpty

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

示例7: getValue

 /**
  * {@inheritdoc}
  */
 public function getValue()
 {
     if (!$this->valueCollection->isEmpty()) {
         return $this->valueCollection;
     } else {
         return parent::getValue();
     }
 }
开发者ID:xoptov,项目名称:dynamic-form-bundle,代码行数:11,代码来源:ObjectProperty.php

示例8: isRemovable

 public function isRemovable()
 {
     $removable = true;
     if (!$this->requirements->isEmpty()) {
         $removable = false;
     }
     return $removable;
 }
开发者ID:nuffer,项目名称:ProjectApp,代码行数:8,代码来源:Capacity.php

示例9: isRemovable

 public function isRemovable()
 {
     $removable = true;
     if (!$this->capacities->isEmpty()) {
         $removable = false;
     }
     return $removable;
 }
开发者ID:nuffer,项目名称:ProjectApp,代码行数:8,代码来源:Need.php

示例10: testIsEmpty

 /**
  * Tests IdentityWrapper->isEmpty()
  */
 public function testIsEmpty()
 {
     $this->assertFalse($this->identityWrapper->isEmpty());
     $this->assertFalse($this->wrappedCollection->isEmpty());
     $this->identityWrapper->clear();
     $this->assertTrue($this->identityWrapper->isEmpty());
     $this->assertTrue($this->wrappedCollection->isEmpty());
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:11,代码来源:IdentityWrapperTest.php

示例11: testReverseTransform

 /**
  * @dataProvider transformDataProvider
  *
  * @param mixed $expected
  * @param mixed $value
  */
 public function testReverseTransform($expected, $value)
 {
     if (!$expected) {
         $expected = new ArrayCollection();
     }
     $this->doctrineHelper->expects($expected->isEmpty() ? $this->never() : $this->exactly($expected->count()))->method('getEntityReference')->will($this->returnCallback(function () {
         return $this->createDataObject(func_get_arg(1));
     }));
     $this->assertEquals($expected, $this->transformer->reverseTransform($value));
 }
开发者ID:Maksold,项目名称:platform,代码行数:16,代码来源:EntityChangesetTransformerTest.php

示例12: setOrigin

 /**
  * Set email folder origin
  *
  * @param EmailOrigin $origin
  *
  * @return EmailFolder
  */
 public function setOrigin(EmailOrigin $origin)
 {
     $this->origin = $origin;
     if (!$this->subFolders->isEmpty()) {
         foreach ($this->subFolders as $subFolder) {
             $subFolder->setOrigin($origin);
         }
     }
     return $this;
 }
开发者ID:northdakota,项目名称:platform,代码行数:17,代码来源:EmailFolder.php

示例13: postAction

 /**
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function postAction(Request $request)
 {
     $imService = $this->get('network.store.im_service');
     $formatter = $this->container->get('sonata.formatter.pool');
     $user = $this->getUserAndCheckAccess();
     $text = $request->request->get('text', '');
     $files = $request->request->get('files');
     if (trim($text) == '') {
         return $this->errorJsonResponse('field \'text\' is empty');
     }
     $threadId = $request->request->get('threadId');
     $res = [];
     if ($threadId != null) {
         $thread = $imService->getThreadByIdAndUserIdOrThrow($threadId, $user->getId());
     } else {
         $recipientIds = $request->request->get('recipientId');
         if (!is_array($recipientIds) || empty($recipientIds)) {
             return $this->errorJsonResponse('field \'recipientId\' is empty or not array_type');
         }
         $recipientUsers = $this->getDoctrine()->getRepository('NetworkStoreBundle:User')->findBy(['id' => $recipientIds]);
         if (!$recipientUsers) {
             return $this->errorJsonResponse('users with given ids not found');
         }
         $recipientUsers = new ArrayCollection($recipientUsers);
         $recipientUsers->removeElement($user);
         // to be sure that client does not send yourself
         if ($recipientUsers->isEmpty()) {
             return $this->errorJsonResponse('users with given ids not found');
         }
         if ($recipientUsers->count() == 1) {
             $rUser = $recipientUsers[0];
             $res['topic'] = $rUser->getFirstName() . ' ' . $rUser->getLastName();
         }
         $topic = $request->request->get('topic', '');
         $thread = $imService->createDialogOrConference($user, $recipientUsers, $topic);
         if (!array_key_exists('topic', $res)) {
             $res['topic'] = $thread->getTopic();
         }
     }
     $post = $imService->createPost($user, $thread, $text, $files);
     $normalizedPost = $imService->normalizePost($post);
     $normalizedPost['text'] = $formatter->transform('markdown', $text);
     $res['post'] = $normalizedPost;
     $res['threadId'] = $thread->getId();
     foreach ($thread->getUsers() as $threadUser) {
         if ($user->getId() != $threadUser->getId()) {
             $msg = new ImMessage($thread->getId(), $threadUser->getId(), $normalizedPost);
             $imService->sendMessage($msg);
         }
     }
     if ($user->getId() == $post->getUser()->getId()) {
         $res['post']['editable'] = true;
     }
     return new JsonResponse($res);
 }
开发者ID:rotanov,项目名称:fefu-social-network,代码行数:60,代码来源:ThreadController.php

示例14: getRecipesByIngredients

 /**
  * @param ArrayCollection $ingredients
  * @param $offset
  * @param $limit
  *
  * @return array
  */
 public function getRecipesByIngredients($ingredients, $offset, $limit)
 {
     if ($ingredients->isEmpty()) {
         return $this->beforeReturn([], $offset, $limit);
     }
     $moreIngredients = $this->expandIngredients($ingredients);
     $ingIds = $moreIngredients->map(function ($i) {
         return $i->getId();
     })->toArray();
     $recipes = $this->beforeReturn($ingIds, $offset, $limit);
     return $recipes;
 }
开发者ID:vjaykoogu,项目名称:IcyFood,代码行数:19,代码来源:RecipeService.php

示例15: testSubmit

 /**
  * @dataProvider submitProvider
  *
  * @param $defaultData
  * @param $viewData
  * @param $submittedData
  * @param ArrayCollection $expected
  */
 public function testSubmit($defaultData, $viewData, $submittedData, ArrayCollection $expected)
 {
     $this->doctrineHelper->expects($expected->isEmpty() ? $this->never() : $this->exactly($expected->count()))->method('getEntityReference')->will($this->returnCallback(function () {
         return $this->createDataObject(func_get_arg(1));
     }));
     $form = $this->factory->create($this->type, $defaultData, ['class' => '\\stdClass']);
     $this->assertEquals($viewData, $form->getViewData());
     $form->submit($submittedData);
     $this->assertTrue($form->isValid());
     $data = $form->getData();
     $this->assertEquals($expected, $data);
 }
开发者ID:Maksold,项目名称:platform,代码行数:20,代码来源:EntityChangesetTypeTest.php


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