Retrieves all calendars for a container

@param type $container
@param type $count
182896
public static function getCalendars($container, $count = false) {
		if (!$container instanceof ElggEntity) {
			return false;
		}

		$options = array(
			'type' => 'object',
			'subtype' => 'calendar',
			'container_guid' => $container->guid,
			'limit' => false
		);

		if ($count) {
			$options['count'] = true;
			return elgg_get_entities($options);
		}

		return new ElggBatch('elgg_get_entities', $options);
	}
984496
public function read($count)
    {
        $data = substr($this->content, $this->bytes_read, $count);
        $this->bytes_read  += $count;
        $this->lastAccessed = time();
        return $data;
    }
415392
static public function count($countable, $count, $message = null, $propertyPath = null)
        {
            if ($count !== count($countable)) {
                $message = $message ?: sprintf(
                    'List does not contain exactly "%d" elements.',
                    static::stringify($countable),
                    static::stringify($count)
                );

                throw static::createException($countable, $message, static::INVALID_COUNT, $propertyPath, array('count' => $count));
            }
        }
665738
public function chunk($count, callable $callback)
    {
        return $this->prepareQueryBuilder()->chunk($count, function (Collection $results) use ($callback) {
            $this->hydrateIntermediateRelations($results->all());

            return $callback($results);
        });
    }
357690
protected function callAfterCallbacks(Container $container)
	{
		foreach ($this->afterCallbacks as $callback)
		{
			$container->call($callback);
		}
	}
242650
public function select(string $pattern = '', int $count = 100): \Iterator
    {
        $iterator = null;
        while (true) {
            $ret = $this->handle->hScan($this->name, $iterator, $pattern, $count);
            if (false === $ret) {
                break;
            }
            foreach ($ret as $k => $v) {
                yield [$k => $v];
            }
        }
    }
26231
protected function listTasks($container)
    {
        $this->output->writeln('<comment>Available tasks:</comment>');

        foreach (array_keys($container->getTasks()) as $task) {
            $this->output->writeln("  <info>{$task}</info>");
        }
    }
344267
public function list_containers($object, $offset_start = 0, $quantity = 10)
    {
        switch ($object) {
            case self::CONTAINER_TYPE_PLAYLIST:

                $username = $this->get_user_name();

                $params = ['fields' => [
                        'description'
                        , 'id'
                        , 'name'
                    ],
                    'page' => ! $offset_start ? 1 : $offset_start];
                //add quantity
                if (! ! $quantity) {
                    $params["limit"] = $quantity;
                }
                $url = sprintf('/me/%ss', $object);
                $result = $this->_api->call($url, $params, $this->oauth_token);

                $container_collection = new Bridge_Api_ContainerCollection();

                $container_collection->set_items_per_page($result["limit"]);

                $total = sizeof($result["list"]);
                $current_page = $result["limit"];
                $total_page = null;

                $container_collection->set_total_items($total);
                $container_collection->set_current_page($current_page);
                $container_collection->set_total_page($total_page);

                foreach ($result['list'] as $entry) {
                    //get 1st image
                    $list_element = $this->list_containers_content($object, $entry['id'], ['thumbnail_medium_url'], 1);
                    $elements = $list_element->get_elements();
                    $first_element = array_shift($elements);
                    $thumbnail = $first_element instanceof Bridge_Api_Dailymotion_Element ? $first_element->get_thumbnail() : '';

                    $url = $this->get_url_playlist($entry['id'], $entry['name'], $username);

                    $container_collection->add_element(new Bridge_Api_Dailymotion_Container($entry, $object, $thumbnail, $url));
                }

                return $container_collection;
                break;

            default:
                throw new Bridge_Exception_ElementUnknown('Unknown element ' . $object);
                break;
        }
    }
536115
public function each(callable $callback, $count = 1000)
    {
        return $this->chunk($count, function ($results) use ($callback) {
            foreach ($results as $key => $value) {
                if ($callback($value, $key) === false) {
                    return false;
                }
            }
        });
    }
571157
public function getCollectionAction(Request $request, $start, $count, KeyWord $parent = null)
    {
        $results = [];

        $term = $request->query->get('term', null);
        $uids = array_filter(explode(',', $request->query->get('uids')));
        $preserveOrder = (boolean) $request->query->get('preserve_order');

        if (null !== $term) {
            $results = $this->getKeywordRepository()->getLikeKeyWords($term);
        } elseif (!empty($uids)) {
            $results = $this->getKeywordRepository()->findBy(['_uid' => $uids]);

            if ($preserveOrder === true) {
                $results = $this->sortByUids($uids, $results);
            }
        } else {
            $orderInfos = [
                'field' => '_leftnode',
                'dir' => 'asc',
            ];
            $results = $this->getKeywordRepository()->getKeyWords($parent, $orderInfos, array('start' => $start, 'limit' => $count));
        }

        $total = count($results);
        if ($results instanceof Paginator) {
            $results = iterator_to_array($results->getIterator());
        }

        return $this->addRangeToContent($this->createJsonResponse($results), $total, $start, count($results));
    }
449852
public function deleteDependents(Event $event, $ids, $count) {
        $pfk = $this->getPrimaryForeignKey();

        $this->getJunctionRepository()->deleteMany(function(Query $query) use ($pfk, $ids) {
            $query->where($pfk, $ids);
        });
    }
885907
protected function prepareOrderDiscount(OrderTransfer $orderTransfer, AbstractRequestContainer $container): AbstractRequestContainer
    {
        $arrayIt = $container->getIt() ?? [];
        $arrayId = $container->getId() ?? [];
        $arrayPr = $container->getPr() ?? [];
        $arrayNo = $container->getNo() ?? [];
        $arrayDe = $container->getDe() ?? [];
        $arrayVa = $container->getVa() ?? [];

        $key = count($arrayId) + 1;

        $arrayIt[$key] = PayoneApiConstants::INVOICING_ITEM_TYPE_VOUCHER;
        $arrayId[$key] = PayoneApiConstants::INVOICING_ITEM_TYPE_VOUCHER;
        $arrayPr[$key] = - $orderTransfer->getTotals()->getDiscountTotal();
        $arrayNo[$key] = 1;
        $arrayDe[$key] = 'Discount';

        $container->setIt($arrayIt);
        $container->setId($arrayId);
        $container->setPr($arrayPr);
        $container->setNo($arrayNo);
        $container->setDe($arrayDe);
        $container->setVa($arrayVa);

        return $container;
    }
1340011
private function readPoints($count)
    {
        $points = array();

        for ($i = 0; $i < $count; $i++) {
            $points[] = $this->point();
        }

        return $points;
    }
1104592
function listTemplates($count = 100, $offset = 0) {
		$query = array();

		$query["count"] = $count;
		$query["offset"] = $offset;

		return new DynamicResponseModel($this->processRestRequest('GET', "/templates", $query));
	}
832347
private function createSessions($count)
    {
        $args = [
            'database' => $this->database->name(),
            'session' => [
                'labels' => isset($this->config['labels']) ? $this->config['labels'] : []
            ]
        ];

        $promises = [];

        for ($i = 0; $i < $count; $i++) {
            $promises[] = $this->database->connection()->createSessionAsync($args);
        }

        $results = Promise\settle($promises)->wait();

        $sessions = [];

        foreach ($results as $result) {
            if ($result['state'] === 'fulfilled') {
                $name = $result['value']->getName();
                $sessions[] = [
                    'name' => $name,
                    'expiration' => $this->time() + SessionPoolInterface::SESSION_EXPIRATION_SECONDS
                ];
            }
        }

        return $sessions;
    }
1211486
public function endingDailyAfterCount($count)
    {
        if (false == is_int($count) || $count <= 0) {
            throw new \InvalidArgumentException('Ending daily after count must be a positive number!');
        }

        if (null == $this->startTimeOfDay) {
            throw new \InvalidArgumentException('You must set the startDailyAt() before calling this endingDailyAfterCount()!');
        }

        $today = new \DateTime();
        $startTimeOfDayDate = $this->getTimeOfDayForDate($today, $this->startTimeOfDay);
        $maxEndTimeOfDayDate = (clone $today)->setTime(23, 59, 59);
        $remainingSecondsInDay = ((int) $maxEndTimeOfDayDate->format('U')) - ((int) $startTimeOfDayDate->format('U'));

        if ($this->intervalUnit == IntervalUnit::SECOND) {
            $intervalInSeconds = $this->interval;
        } elseif ($this->intervalUnit == IntervalUnit::MINUTE) {
            $intervalInSeconds = $this->interval * 60;
        } elseif ($this->intervalUnit == IntervalUnit::HOUR) {
            $intervalInSeconds = $this->interval * 60 * 24;
        } else {
            throw new \InvalidArgumentException(sprintf('The IntervalUnit is invalid for this trigger: "%s"', $this->intervalUnit));
        }

        if ($remainingSecondsInDay - $intervalInSeconds <= 0) {
            throw new \InvalidArgumentException('The startTimeOfDay is too late with given Interval and IntervalUnit values.');
        }

        $maxNumOfCount = ($remainingSecondsInDay / $intervalInSeconds);
        if ($count > $maxNumOfCount) {
            throw new \InvalidArgumentException(sprintf('The given count is too large!: count: "%s", max: "%s"', $count, $maxNumOfCount));
        }

        $incrementInSeconds = ($count - 1) * $intervalInSeconds;
        $endTimeOfDayDate = clone $startTimeOfDayDate;
        $endTimeOfDayDate->add(new \DateInterval(sprintf('PT%dS', $incrementInSeconds)));

        if ($endTimeOfDayDate > $maxEndTimeOfDayDate) {
            throw new \InvalidArgumentException(sprintf('The given count is too large!: count: "%s", max: "%s"', $count, $maxNumOfCount));
        }

        $this->endTimeOfDay = $endTimeOfDayDate;

        return $this;
    }
102841
public function getItems($count = null, $start = 0)
    {
        $columns = [];

        foreach ($this->columns as $key => $value) {
            $columns[] = $this->applyTableAlias($value);
        }

        $builder = $this->connection->createQueryBuilder();
        $builder
            ->select(empty($columns) ? $this->applyTableAlias('*') : $columns)
            ->from($this->tableName, $this->tableAlias)
        ;

        $builder = $this->applyConditions($builder);
        $builder = $this->applyOrdering($builder);

        if (!is_null($count)) {
            $builder
                ->setMaxResults($count)
                ->setFirstResult($start)
            ;
        }

        $this->dispatcher->dispatch('onQueryDatabase', new QueryDatabaseEvent($this->entityClass, $builder));

        try {
            $rows = $builder
                ->execute()
                ->fetchAll(\PDO::FETCH_ASSOC)
            ;
        } catch (SyntaxErrorException $e) {
            throw new InvalidOperatorException($e->getMessage(), 0, $e);
        } catch (DBALException $e) {
            throw new EntityNotFoundException();
        }

        foreach ($this->patterns as $column => $pattern) {
            $column = $this->stripTableAlias($column);
            $rows   = array_filter(
                $rows,
                function ($row) use ($column, $pattern) {
                    return preg_match("~{$pattern}~", $row[$column]);
                }
            );
        }

        if (empty($rows)) {
            return [];
        }

        if (empty($this->columns)) {
            $rows = $this->castToEntity($rows);
        }

        if (count($this->columns) == 1 && $this->columns[0] != '*') {
            $result = [];

            foreach ($rows as $match) {
                $result[] = $match[$this->columns[0]];
            }

            return $result;
        }

        return array_values($rows);
    }