public function getSessionsAction() { $manager = $this->getModelManager(); /** @var Repository $sessionRepository */ $sessionRepository = $manager->getRepository(Session::class); $query = $sessionRepository->getSessionsListQuery($this->Request()->getParam('filter', []), $this->Request()->getParam('sort', []), $this->Request()->getParam('limit', 25), $this->Request()->getParam('start', 0))->getQuery(); $query->setHydrationMode(\Doctrine\ORM\AbstractQuery::HYDRATE_ARRAY); $paginator = $manager->createPaginator($query); //returns the total count of the query $total = $paginator->count(); //returns the customer data $data = $paginator->getIterator()->getArrayCopy(); foreach ($data as $key => $row) { $data[$key]['fileUrl'] = urlencode($row['fileName']); $data[$key]['fileName'] = $row['fileName']; $data[$key]['fileSize'] = DataHelper::formatFileSize($row['fileSize']); } $this->View()->assign(['success' => true, 'data' => $data, 'total' => $total]); }
/** * @param array $record * @param boolean $newCustomer * @param array $billing * @return array */ protected function prepareShipping(array &$record, $newCustomer, array $billing) { if ($this->shippingMap === null) { $columns = $this->getShippingColumns(); foreach ($columns as $column) { $map = DataHelper::generateMappingFromColumns($column); if (empty($map)) { continue; } $this->shippingMap[$map[0]] = $map[1]; } } $shippingData = []; //use shipping as billing if ($newCustomer && empty($record['shippingFirstname']) && empty($params['shippingLastname'])) { foreach ($this->shippingMap as $mapKey => $addressKey) { if (!isset($record[$mapKey]) && isset($billing[$addressKey])) { $shippingData[$addressKey] = $billing[$addressKey]; unset($record[$mapKey]); } } return $shippingData; } foreach ($record as $key => $value) { //prepares the attributes if (preg_match('/^attrShipping/', $key)) { $newKey = lcfirst(preg_replace('/^attrShipping/', '', $key)); $shippingData['attribute'][$newKey] = $value; unset($record[$key]); } elseif (isset($this->shippingMap[$key])) { $shippingData[$this->shippingMap[$key]] = $value; unset($record[$key]); } } return $shippingData; }