Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractSimpleObjectBuilder.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Framework\Api;
7 
13 {
17  protected $data;
18 
22  protected $objectFactory;
23 
28  {
29  $this->data = [];
30  $this->objectFactory = $objectFactory;
31  }
32 
38  public function create()
39  {
40  $dataObjectType = $this->_getDataObjectType();
41  $dataObject = $this->objectFactory->create($dataObjectType, ['data' => $this->data]);
42  $this->data = [];
43  return $dataObject;
44  }
45 
52  protected function _set($key, $value)
53  {
54  $this->data[$key] = $value;
55  return $this;
56  }
57 
63  protected function _getDataObjectType()
64  {
65  $currentClass = get_class($this);
66  $builderSuffix = 'Builder';
67  $dataObjectType = substr($currentClass, 0, -strlen($builderSuffix));
68  return $dataObjectType;
69  }
70 
76  public function getData()
77  {
78  return $this->data;
79  }
80 }
$value
Definition: gender.phtml:16