コード例 #1
0
 public function testGetAttributes()
 {
     $formAttributesMetadata = $this->_service->getAttributes('customer_address_edit');
     $this->assertCount(15, $formAttributesMetadata, "Invalid number of attributes for the specified form.");
     /** Check some fields of one attribute metadata */
     $attributeMetadata = $formAttributesMetadata['company'];
     $this->assertInstanceOf('Magento\\Customer\\Model\\Data\\AttributeMetadata', $attributeMetadata);
     $this->assertEquals('company', $attributeMetadata->getAttributeCode(), 'Attribute code is invalid');
     $this->assertNotEmpty($attributeMetadata->getValidationRules(), 'Validation rules are not set');
     $this->assertEquals('static', $attributeMetadata->getBackendType(), 'Backend type is invalid');
     $this->assertEquals('Company', $attributeMetadata->getFrontendLabel(), 'Frontend label is invalid');
 }
コード例 #2
0
ファイル: Form.php プロジェクト: pradeep-wagento/magento2
 /**
  * Retrieve attributes metadata for the form
  *
  * @return \Magento\Customer\Api\Data\AttributeMetadataInterface[]
  * @throws \LogicException For undefined entity type
  */
 public function getAttributes()
 {
     if (!isset($this->_attributes)) {
         if ($this->_entityType === \Magento\Customer\Api\CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER) {
             $this->_attributes = $this->_customerMetadataService->getAttributes($this->_formCode);
         } elseif ($this->_entityType === \Magento\Customer\Api\AddressMetadataInterface::ENTITY_TYPE_ADDRESS) {
             $this->_attributes = $this->_addressMetadataService->getAttributes($this->_formCode);
         } else {
             throw new \LogicException('Undefined entity type: ' . $this->_entityType);
         }
     }
     return $this->_attributes;
 }