/** * @param \Spryker\Zed\Gui\Communication\Table\TableConfiguration $config * * @return \Propel\Runtime\Collection\ObjectCollection */ protected function prepareData(TableConfiguration $config) { $query = $this->customerQueryContainer->queryAddresses()->filterByFkCustomer($this->idCustomer)->leftJoinCountry('country')->withColumn('country.name', self::COL_COMPANY); $lines = $this->runQuery($query, $config); $customer = $this->customerQueryContainer->queryCustomers()->findOneByIdCustomer($this->idCustomer); $defaultBillingAddress = $defaultShippingAddress = false; if ($customer !== null) { $customer = $customer->toArray(); $defaultBillingAddress = !empty($customer[self::DEFAULT_BILLING_ADDRESS]) ? $customer[self::DEFAULT_BILLING_ADDRESS] : false; $defaultShippingAddress = !empty($customer[self::DEFAULT_SHIPPING_ADDRESS]) ? $customer[self::DEFAULT_SHIPPING_ADDRESS] : false; } if (!empty($lines)) { foreach ($lines as $key => $value) { $id = !empty($value[SpyCustomerAddressTableMap::COL_ID_CUSTOMER_ADDRESS]) ? $value[SpyCustomerAddressTableMap::COL_ID_CUSTOMER_ADDRESS] : false; $tags = []; if (is_bool($id) === false && $id === $defaultBillingAddress) { $tags[] = '<span class="label label-danger" title="Default billing address">BILLING</span>'; } if (is_bool($id) === false && $id === $defaultShippingAddress) { $tags[] = '<span class="label label-danger" title="Default shipping address">SHIPPING</span>'; } $lines[$key][SpyCustomerAddressTableMap::COL_ADDRESS1] = (!empty($tags) ? implode(' ', $tags) . ' ' : '') . $lines[$key][SpyCustomerAddressTableMap::COL_ADDRESS1]; $lines[$key][self::ACTIONS] = $this->buildLinks($value); } } return $lines; }
/** * @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer * * @return \Generated\Shared\Transfer\AddressesTransfer */ public function getAddresses(CustomerTransfer $customerTransfer) { $entities = $this->queryContainer->queryAddresses()->joinCountry()->filterByFkCustomer($customerTransfer->getIdCustomer())->find(); return $this->entityCollectionToTransferCollection($entities); }