コード例 #1
0
ファイル: AddressTable.php プロジェクト: spryker/Customer
 /**
  * @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('&nbsp;', $tags) . '&nbsp;' : '') . $lines[$key][SpyCustomerAddressTableMap::COL_ADDRESS1];
             $lines[$key][self::ACTIONS] = $this->buildLinks($value);
         }
     }
     return $lines;
 }
コード例 #2
0
 /**
  * @param int|null $idCustomerAddress
  *
  * @return array
  */
 public function getData($idCustomerAddress = null)
 {
     if ($idCustomerAddress === null) {
         return [];
     }
     $addressEntity = $this->customerQueryContainer->queryAddress($idCustomerAddress)->findOne();
     return $addressEntity->toArray();
 }
コード例 #3
0
ファイル: Customer.php プロジェクト: spryker/Customer
 /**
  * @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer
  *
  * @return bool
  */
 public function tryAuthorizeCustomerByEmailAndPassword(CustomerTransfer $customerTransfer)
 {
     $result = false;
     $customerEntity = $this->queryContainer->queryCustomerByEmail($customerTransfer->getEmail())->findOne();
     if ($customerEntity !== null) {
         $result = $this->isValidPassword($customerEntity->getPassword(), $customerTransfer->getPassword());
     }
     return $result;
 }
コード例 #4
0
ファイル: CustomerForm.php プロジェクト: spryker/Customer
 /**
  * @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;
 }
コード例 #5
0
ファイル: Address.php プロジェクト: spryker/Customer
 /**
  * @param \Generated\Shared\Transfer\AddressTransfer $addressTransfer
  * @param \Orm\Zed\Customer\Persistence\SpyCustomer $customer
  *
  * @throws \Spryker\Zed\Customer\Business\Exception\AddressNotFoundException
  *
  * @return \Orm\Zed\Customer\Persistence\SpyCustomerAddress
  */
 protected function updateCustomerAddress(AddressTransfer $addressTransfer, SpyCustomer $customer)
 {
     $addressEntity = $this->queryContainer->queryAddressForCustomer($addressTransfer->getIdCustomerAddress(), $customer->getEmail())->findOne();
     if (!$addressEntity) {
         throw new AddressNotFoundException(sprintf('Address not found for ID `%s` and customer email `%s`.', $addressTransfer->getIdCustomerAddress(), $customer->getEmail()));
     }
     $fkCountry = $this->retrieveFkCountry($addressTransfer);
     $addressEntity->fromArray($addressTransfer->modifiedToArray());
     $addressEntity->setCustomer($customer);
     $addressEntity->setFkCountry($fkCountry);
     $addressEntity->save();
     return $addressEntity;
 }
コード例 #6
0
ファイル: CustomerTable.php プロジェクト: spryker/Customer
 /**
  * @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;
 }