public function __construct($totalResults = null, $startIndex = null, $itemsPerPage = null, array $entries = array()) { parent::__construct($entries); $this->setTotalResults($totalResults); $this->setStartIndex($startIndex); $this->setItemsPerPage($itemsPerPage); }
public function toArray() { $array = []; foreach (parent::toArray() as $item) { $name = $item->find($this->getAttributeName()); if (!empty($name)) { $array[] = ['field' => $this->getAttributeName(), 'name' => $name, 'value' => $item->find('@count')]; } } return $array; }
/** * Implements SearchQueueIteratorAbstract::valid(). * * Fetches an item that is scheduled for indexing, populates a message * object that can be sent to the index queue. * * We only have to check the timeout because the document limit should have * been taken care of in the SearchCollectionAbstract::fetchScheduledItems() * method. */ public function valid() { $log = $this->_agent->getLogger(); $context = array('collection' => $this->_collection->getId()); if (!$this->timedOut()) { list(, $item) = each($this->_scheduledItems); if ($item !== null) { // Build queue message and store it in a class property. $message = $this->_agent->getQueue()->newMessage(); $message->setCollection($this->_collection); $this->_collection->buildQueueMessage($message, $item); $this->_currentMessage = $message; // Log a debug message. $context['item'] = $message->getBody(); $log->debug('Fetched item scheduled for indexing', $context); return true; } } else { $context['timeout'] = $this->_agent->getTimeout(); $log->info('Fetching operation timed out', $context); } return false; }
/** * Constructor * * @param array $collection Collection * @param string $attribute_property Name of the attribute property * @param string $value_property Name of the value property * @return AttributeCollection * @access public */ public function __construct(array $collection, $attribute_property, $value_property) { $this->attribute_field = $attribute_property; $this->value_field = $value_property; parent::__construct($collection); }