|
| dispatchCopyFieldSetEvent ($fieldset, $aspect, $source, $target, $root, $targetIsArray) |
|
| _isFieldsetInputValid ($source, $target) |
|
| _getFieldsetFieldValue ($source, $code) |
|
| _setFieldsetFieldValue ($target, $targetCode, $value) |
|
| getAttributeValueFromExtensibleDataObject ($source, $code) |
|
| setAttributeValueFromExtensibleDataObject ($target, $code, $value) |
|
Definition at line 12 of file Copy.php.
◆ __construct()
- Parameters
-
\Magento\Framework\Event\ManagerInterface | $eventManager | |
\Magento\Framework\DataObject\Copy\Config | $fieldsetConfig | |
\Magento\Framework\Api\ExtensionAttributesFactory | $extensionAttributesFactory | |
Definition at line 36 of file Copy.php.
$extensionAttributesFactory
◆ _getFieldsetFieldValue()
_getFieldsetFieldValue |
( |
|
$source, |
|
|
|
$code |
|
) |
| |
|
protected |
Get value of source by code
- Parameters
-
- Returns
- mixed
- Exceptions
-
Definition at line 182 of file Copy.php.
191 $sourceArray =
$source->__toArray();
194 throw new \InvalidArgumentException(
195 'Source should be array, Magento Object, ExtensibleDataInterface, or AbstractSimpleObject' elseif(isset( $params[ 'redirect_parent']))
getAttributeValueFromExtensibleDataObject($source, $code)
◆ _isFieldsetInputValid()
_isFieldsetInputValid |
( |
|
$source, |
|
|
|
$target |
|
) |
| |
|
protected |
Check if source and target are valid input for converting using fieldset
- Parameters
-
array | \Magento\Framework\DataObject | $source | |
array | \Magento\Framework\DataObject | $target | |
- Returns
- bool
Definition at line 163 of file Copy.php.
166 $source instanceof \
Magento\Framework\Api\ExtensibleDataInterface ||
167 $source instanceof \
Magento\Framework\Api\AbstractSimpleObject) && (
168 is_array(
$target) ||
$target instanceof \Magento\Framework\DataObject ||
169 $target instanceof \Magento\Framework\Api\ExtensibleDataInterface ||
170 $target instanceof \Magento\Framework\Api\AbstractSimpleObject);
◆ _setFieldsetFieldValue()
_setFieldsetFieldValue |
( |
|
$target, |
|
|
|
$targetCode, |
|
|
|
$value |
|
) |
| |
|
protected |
Set value of target by code
- Parameters
-
mixed | $target | |
string | $targetCode | |
mixed | $value | |
- Returns
- mixed
- Exceptions
-
Definition at line 211 of file Copy.php.
213 $targetIsArray = is_array(
$target);
215 if ($targetIsArray) {
224 throw new \InvalidArgumentException(
225 'Source should be array, Magento Object, ExtensibleDataInterface, or AbstractSimpleObject' elseif(isset( $params[ 'redirect_parent']))
setAttributeValueFromExtensibleDataObject($target, $code, $value)
◆ copyFieldsetToTarget()
copyFieldsetToTarget |
( |
|
$fieldset, |
|
|
|
$aspect, |
|
|
|
$source, |
|
|
|
$target, |
|
|
|
$root = 'global' |
|
) |
| |
Copy data from object|array to object|array containing fields from fieldset matching an aspect.
Contents of $aspect are a field name in target object or array. If targetField attribute is not provided - will be used the same name as in the source object or array.
- Parameters
-
string | $fieldset | |
string | $aspect | |
array | \Magento\Framework\DataObject | $source | |
array | \Magento\Framework\DataObject | $target | |
string | $root | |
- Returns
- array|\Magento\Framework\DataObject|null the value of $target
- Exceptions
-
Definition at line 62 of file Copy.php.
67 $fields = $this->fieldsetConfig->getFieldset($fieldset, $root);
71 $targetIsArray = is_array(
$target);
74 if (empty($node[$aspect])) {
80 $targetCode = (string)$node[$aspect];
81 $targetCode = $targetCode ==
'*' ?
$code : $targetCode;
_isFieldsetInputValid($source, $target)
dispatchCopyFieldSetEvent($fieldset, $aspect, $source, $target, $root, $targetIsArray)
_getFieldsetFieldValue($source, $code)
_setFieldsetFieldValue($target, $targetCode, $value)
◆ dispatchCopyFieldSetEvent()
dispatchCopyFieldSetEvent |
( |
|
$fieldset, |
|
|
|
$aspect, |
|
|
|
$source, |
|
|
|
$target, |
|
|
|
$root, |
|
|
|
$targetIsArray |
|
) |
| |
|
protected |
Dispatch copy fieldset event
- Parameters
-
string | $fieldset | |
string | $aspect | |
array | \Magento\Framework\DataObject | $source | |
array | \Magento\Framework\DataObject | $target | |
string | $root | |
bool | $targetIsArray | |
- Returns
- \Magento\Framework\DataObject|mixed
Definition at line 102 of file Copy.php.
104 $eventName = sprintf(
'core_copy_fieldset_%s_%s', $fieldset, $aspect);
105 if ($targetIsArray) {
108 $this->eventManager->dispatch(
112 if ($targetIsArray) {
◆ getAttributeValueFromExtensibleDataObject()
getAttributeValueFromExtensibleDataObject |
( |
|
$source, |
|
|
|
$code |
|
) |
| |
|
protected |
Access the extension get method
- Parameters
-
\Magento\Framework\Api\ExtensibleDataInterface | $object | |
string | $code | |
- Returns
- mixed
- Exceptions
-
Definition at line 241 of file Copy.php.
243 $method =
'get' . str_replace(
' ',
'', ucwords(str_replace(
'_',
' ',
$code)));
246 if ($methodExists ==
true) {
252 throw new \InvalidArgumentException(
'Method in extension does not exist.');
255 if ($extensionMethodExists ==
true) {
258 throw new \InvalidArgumentException(
'Attribute in object does not exist.');
◆ getDataFromFieldset()
getDataFromFieldset |
( |
|
$fieldset, |
|
|
|
$aspect, |
|
|
|
$source, |
|
|
|
$root = 'global' |
|
) |
| |
Get data from object|array to object|array containing fields from fieldset matching an aspect.
- Parameters
-
string | $fieldset | |
string | $aspect | a field name |
array | \Magento\Framework\DataObject | $source | |
string | $root | |
- Returns
- array $data
@api
Definition at line 130 of file Copy.php.
135 $fields = $this->fieldsetConfig->getFieldset($fieldset, $root);
142 if (empty($node[$aspect])) {
148 $targetCode = (string)$node[$aspect];
149 $targetCode = $targetCode ==
'*' ?
$code : $targetCode;
_getFieldsetFieldValue($source, $code)
◆ setAttributeValueFromExtensibleDataObject()
setAttributeValueFromExtensibleDataObject |
( |
|
$target, |
|
|
|
$code, |
|
|
|
$value |
|
) |
| |
|
protected |
Access the extension set method
- Parameters
-
\Magento\Framework\Api\ExtensibleDataInterface | $object | |
string | $code | |
mixed | $value | |
- Returns
- null
- Exceptions
-
Definition at line 275 of file Copy.php.
277 $method =
'set' . str_replace(
' ',
'', ucwords(str_replace(
'_',
' ',
$code)));
280 if ($methodExists ==
true) {
289 if ($extensionMethodExists ==
true) {
293 throw new \InvalidArgumentException(
'Attribute in object does not exist.');
◆ $eventManager
◆ $extensionAttributesFactory
$extensionAttributesFactory |
|
protected |
◆ $fieldsetConfig
The documentation for this class was generated from the following file:
- vendor/magento/framework/DataObject/Copy.php