Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
View Class Reference
Inheritance diagram for View:
AbstractHelper CustomerNameGenerationInterface

Public Member Functions

 __construct (\Magento\Framework\App\Helper\Context $context, CustomerMetadataInterface $customerMetadataService)
 
 getCustomerName (CustomerInterface $customerData)
 
- Public Member Functions inherited from AbstractHelper
 __construct (Context $context)
 
 isModuleOutputEnabled ($moduleName=null)
 

Protected Attributes

 $_customerMetadataService
 
- Protected Attributes inherited from AbstractHelper
 $_moduleName
 
 $_request
 
 $_moduleManager
 
 $_logger
 
 $_urlBuilder
 
 $_httpHeader
 
 $_eventManager
 
 $_remoteAddress
 
 $urlEncoder
 
 $urlDecoder
 
 $scopeConfig
 
 $_cacheConfig
 

Additional Inherited Members

- Protected Member Functions inherited from AbstractHelper
 _getRequest ()
 
 _getModuleName ()
 
 _getUrl ($route, $params=[])
 

Detailed Description

Customer helper for view.

Definition at line 15 of file View.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\App\Helper\Context  $context,
CustomerMetadataInterface  $customerMetadataService 
)

Initialize dependencies.

Parameters
\Magento\Framework\App\Helper\Context$context
CustomerMetadataInterface$customerMetadataService

Definition at line 28 of file View.php.

31  {
32  $this->_customerMetadataService = $customerMetadataService;
33  parent::__construct($context);
34  }

Member Function Documentation

◆ getCustomerName()

getCustomerName ( CustomerInterface  $customerData)

{Concatenate all customer name parts into full customer name.

Parameters
CustomerInterface$customerData
Returns
string
Since
100.1.0
}

Implements CustomerNameGenerationInterface.

Definition at line 39 of file View.php.

40  {
41  $name = '';
42  $prefixMetadata = $this->_customerMetadataService->getAttributeMetadata('prefix');
43  if ($prefixMetadata->isVisible() && $customerData->getPrefix()) {
44  $name .= $customerData->getPrefix() . ' ';
45  }
46 
47  $name .= $customerData->getFirstname();
48 
49  $middleNameMetadata = $this->_customerMetadataService->getAttributeMetadata('middlename');
50  if ($middleNameMetadata->isVisible() && $customerData->getMiddlename()) {
51  $name .= ' ' . $customerData->getMiddlename();
52  }
53 
54  $name .= ' ' . $customerData->getLastname();
55 
56  $suffixMetadata = $this->_customerMetadataService->getAttributeMetadata('suffix');
57  if ($suffixMetadata->isVisible() && $customerData->getSuffix()) {
58  $name .= ' ' . $customerData->getSuffix();
59  }
60  return $name;
61  }
$customerData
if(!isset($_GET['name'])) $name
Definition: log.php:14

Field Documentation

◆ $_customerMetadataService

$_customerMetadataService
protected

Definition at line 20 of file View.php.


The documentation for this class was generated from the following file: