Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions
OperationElementBuilder Class Reference

Public Member Functions

 build ()
 
 withElementType ($elementType)
 
 withFields ($fields)
 
 withKey ($key)
 
 withType ($type)
 
 addElements ($elementsToAdd)
 
 addFields ($fieldsToAdd)
 
 withNestedElements ($nestedElements)
 

Static Public Member Functions

static buildOperationElementFields ($fields)
 

Detailed Description

Definition at line 11 of file OperationElementBuilder.php.

Member Function Documentation

◆ addElements()

addElements (   $elementsToAdd)

Adds a set of new Operation Elements to the nested metadata.

Parameters
array$elementsToAdd
Returns
OperationElementBuilder

Definition at line 140 of file OperationElementBuilder.php.

141  {
142  foreach ($elementsToAdd as $fieldKey => $metadata) {
143  $this->nestedMetadata[$fieldKey] = $metadata;
144  }
145 
146  return $this;
147  }

◆ addFields()

addFields (   $fieldsToAdd)

Adds a new set of fields (value => type) into an object parameter to be converted to Operation Elements.

Parameters
array$fieldsToAdd
Returns
OperationElementBuilder

Definition at line 155 of file OperationElementBuilder.php.

156  {
157  foreach ($fieldsToAdd as $fieldKey => $type) {
158  $this->fields[$fieldKey] = $type;
159  }
160 
161  return $this;
162  }
$type
Definition: item.phtml:13

◆ build()

build ( )

Build function which takes params defined by the user and returns a new Operation Element.

Returns
OperationElement

Definition at line 74 of file OperationElementBuilder.php.

75  {
76  return new OperationElement(
77  $this->key,
78  $this->type,
79  $this->elementType,
80  null,
81  $this->nestedElements,
82  array_merge($this->nestedMetadata, self::buildOperationElementFields($this->fields))
83  );
84  }

◆ buildOperationElementFields()

static buildOperationElementFields (   $fields)
static

Takes an array of fields (value => type) and returns an array of Operations Elements of type field.

Parameters
array$fields
Returns
array

Definition at line 182 of file OperationElementBuilder.php.

183  {
184  $operationElements = [];
185  foreach ($fields as $fieldName => $type) {
186  $operationElements[] = new OperationElement(
187  $fieldName,
188  $type,
189  null,
191  );
192  }
193 
194  return $operationElements;
195  }
$fields
Definition: details.phtml:14
$type
Definition: item.phtml:13

◆ withElementType()

withElementType (   $elementType)

Sets a new element type, overwrites any existing.

Parameters
string$elementType
Returns
OperationElementBuilder

Definition at line 92 of file OperationElementBuilder.php.

93  {
94  $this->elementType = $elementType;
95  return $this;
96  }

◆ withFields()

withFields (   $fields)

Set a new set of fields or operation elements

Parameters
array$fields
Returns
OperationElementBuilder

Definition at line 104 of file OperationElementBuilder.php.

105  {
106  $this->fields = $fields;
107  return $this;
108  }
$fields
Definition: details.phtml:14

◆ withKey()

withKey (   $key)

Sets a key for the operation element. See ref to param key for explanation.

Parameters
string$key
Returns
OperationElementBuilder

Definition at line 116 of file OperationElementBuilder.php.

117  {
118  $this->key = $key;
119  return $this;
120  }

◆ withNestedElements()

withNestedElements (   $nestedElements)

Sets an array nested elements to an object property.

Parameters
array$nestedElements
Returns
OperationElementBuilder

Definition at line 170 of file OperationElementBuilder.php.

171  {
172  $this->nestedElements = $nestedElements;
173  return $this;
174  }

◆ withType()

withType (   $type)

Sets a type for the operation element. See ref to param type for explanation.

Parameters
string$type
Returns
OperationElementBuilder

Definition at line 128 of file OperationElementBuilder.php.

129  {
130  $this->type = $type;
131  return $this;
132  }
$type
Definition: item.phtml:13

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