本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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('Кудато что то записалось');
}
示例5: isRemovable
/**
* @return bool
*/
public function isRemovable()
{
$ok = true;
$ok = $ok && $this->applications->isEmpty();
$ok = $ok && $this->fundraisers->isEmpty();
return $ok;
}
示例6: isEmpty
public function isEmpty()
{
if (null === $this->entries) {
$this->__load___();
}
return $this->entries->isEmpty();
}
示例7: getValue
/**
* {@inheritdoc}
*/
public function getValue()
{
if (!$this->valueCollection->isEmpty()) {
return $this->valueCollection;
} else {
return parent::getValue();
}
}
示例8: isRemovable
public function isRemovable()
{
$removable = true;
if (!$this->requirements->isEmpty()) {
$removable = false;
}
return $removable;
}
示例9: isRemovable
public function isRemovable()
{
$removable = true;
if (!$this->capacities->isEmpty()) {
$removable = false;
}
return $removable;
}
示例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());
}
示例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));
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}