/** * @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; }
/** * @return array */ protected function createEmailConstraints() { $emailConstraints = [new NotBlank(), new Required(), new Email()]; $customerQuery = $this->customerQueryContainer->queryCustomers(); $emailConstraints[] = new Callback(['methods' => [function ($email, ExecutionContextInterface $context) use($customerQuery) { if ($customerQuery->findByEmail($email)->count() > 0) { $context->addViolation('Email is already used'); } }]]); return $emailConstraints; }
/** * @return \Orm\Zed\Customer\Persistence\SpyCustomerQuery */ protected function prepareQuery() { $query = $this->customerQueryContainer->queryCustomers()->leftJoinBillingAddress()->withColumn(SpyCustomerAddressTableMap::COL_ZIP_CODE, self::COL_ZIP_CODE)->withColumn(SpyCustomerAddressTableMap::COL_CITY, self::COL_CITY)->withColumn(SpyCustomerAddressTableMap::COL_FK_COUNTRY, self::COL_FK_COUNTRY); return $query; }