what is MagentoFrameworkDataObject do
can anyone explain what is MagentoFrameworkDataObject
do.
I use it but I don't understand its core purpose Or which tables it deals with
magento2
add a comment |
can anyone explain what is MagentoFrameworkDataObject
do.
I use it but I don't understand its core purpose Or which tables it deals with
magento2
add a comment |
can anyone explain what is MagentoFrameworkDataObject
do.
I use it but I don't understand its core purpose Or which tables it deals with
magento2
can anyone explain what is MagentoFrameworkDataObject
do.
I use it but I don't understand its core purpose Or which tables it deals with
magento2
magento2
asked 7 hours ago
Yomna MansourYomna Mansour
969
969
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
MagentoFrameworkDataObject
is the equivalent of Varien_Object
from magento 1.
To put it short, it is a glorified array.
Long version:
It is basically a wrapper over an array that allows you to set/get/unset values in that array in a OOP way.
It also offers other shortcuts.
For example $array['missing'] will throw an exception if the key 'missing' is missing.
using the DataObject you can call $obj->getMissing()
or $obj->getData('missing')
will return null if the missing
key is missing in the array.
One other useful thing about it is that objects are passed by reference and arrays are passed by value.
So if you pass a DataObject
as a parameter to a method and you change it inside the method, it will stay changed when the method is done.
This class does not deal with tables, but most of the models that deal with tables extend DataObject.
add a comment |
DataObject is Universal data container with array access implementation. it holds the data for easy manipulations. and it is implemented by ArrayAccess. it contains getters/setters. This is constructor code.
/**
* Constructor
*
* By default is looking for first argument as array and assigns it as object attributes
* This behavior may change in child classes
*
* @param array $data
*/
public function __construct(array $data = )
{
$this->_data = $data;
}
it holds the data while creating object. you can create by empty data using addData(..) you can append data.
some of useful methods
public function toArray(array $keys = )
public function toXml(...)
public function convertToJson(array $keys = )
Using DataObject you can use callback functions
public function serialize(...)
Usage examples:
$types[$type] = new MagentoFrameworkDataObject(
[
'id' => $type,
'cache_type' => $node['label'],
'description' => $node['description'],
'tags' => $typeTags,
'status' => (int)$this->_cacheState->isEnabled($type),
]
);
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f258139%2fwhat-is-magento-framework-dataobject-do%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
MagentoFrameworkDataObject
is the equivalent of Varien_Object
from magento 1.
To put it short, it is a glorified array.
Long version:
It is basically a wrapper over an array that allows you to set/get/unset values in that array in a OOP way.
It also offers other shortcuts.
For example $array['missing'] will throw an exception if the key 'missing' is missing.
using the DataObject you can call $obj->getMissing()
or $obj->getData('missing')
will return null if the missing
key is missing in the array.
One other useful thing about it is that objects are passed by reference and arrays are passed by value.
So if you pass a DataObject
as a parameter to a method and you change it inside the method, it will stay changed when the method is done.
This class does not deal with tables, but most of the models that deal with tables extend DataObject.
add a comment |
MagentoFrameworkDataObject
is the equivalent of Varien_Object
from magento 1.
To put it short, it is a glorified array.
Long version:
It is basically a wrapper over an array that allows you to set/get/unset values in that array in a OOP way.
It also offers other shortcuts.
For example $array['missing'] will throw an exception if the key 'missing' is missing.
using the DataObject you can call $obj->getMissing()
or $obj->getData('missing')
will return null if the missing
key is missing in the array.
One other useful thing about it is that objects are passed by reference and arrays are passed by value.
So if you pass a DataObject
as a parameter to a method and you change it inside the method, it will stay changed when the method is done.
This class does not deal with tables, but most of the models that deal with tables extend DataObject.
add a comment |
MagentoFrameworkDataObject
is the equivalent of Varien_Object
from magento 1.
To put it short, it is a glorified array.
Long version:
It is basically a wrapper over an array that allows you to set/get/unset values in that array in a OOP way.
It also offers other shortcuts.
For example $array['missing'] will throw an exception if the key 'missing' is missing.
using the DataObject you can call $obj->getMissing()
or $obj->getData('missing')
will return null if the missing
key is missing in the array.
One other useful thing about it is that objects are passed by reference and arrays are passed by value.
So if you pass a DataObject
as a parameter to a method and you change it inside the method, it will stay changed when the method is done.
This class does not deal with tables, but most of the models that deal with tables extend DataObject.
MagentoFrameworkDataObject
is the equivalent of Varien_Object
from magento 1.
To put it short, it is a glorified array.
Long version:
It is basically a wrapper over an array that allows you to set/get/unset values in that array in a OOP way.
It also offers other shortcuts.
For example $array['missing'] will throw an exception if the key 'missing' is missing.
using the DataObject you can call $obj->getMissing()
or $obj->getData('missing')
will return null if the missing
key is missing in the array.
One other useful thing about it is that objects are passed by reference and arrays are passed by value.
So if you pass a DataObject
as a parameter to a method and you change it inside the method, it will stay changed when the method is done.
This class does not deal with tables, but most of the models that deal with tables extend DataObject.
answered 6 hours ago
Marius♦Marius
164k28312663
164k28312663
add a comment |
add a comment |
DataObject is Universal data container with array access implementation. it holds the data for easy manipulations. and it is implemented by ArrayAccess. it contains getters/setters. This is constructor code.
/**
* Constructor
*
* By default is looking for first argument as array and assigns it as object attributes
* This behavior may change in child classes
*
* @param array $data
*/
public function __construct(array $data = )
{
$this->_data = $data;
}
it holds the data while creating object. you can create by empty data using addData(..) you can append data.
some of useful methods
public function toArray(array $keys = )
public function toXml(...)
public function convertToJson(array $keys = )
Using DataObject you can use callback functions
public function serialize(...)
Usage examples:
$types[$type] = new MagentoFrameworkDataObject(
[
'id' => $type,
'cache_type' => $node['label'],
'description' => $node['description'],
'tags' => $typeTags,
'status' => (int)$this->_cacheState->isEnabled($type),
]
);
add a comment |
DataObject is Universal data container with array access implementation. it holds the data for easy manipulations. and it is implemented by ArrayAccess. it contains getters/setters. This is constructor code.
/**
* Constructor
*
* By default is looking for first argument as array and assigns it as object attributes
* This behavior may change in child classes
*
* @param array $data
*/
public function __construct(array $data = )
{
$this->_data = $data;
}
it holds the data while creating object. you can create by empty data using addData(..) you can append data.
some of useful methods
public function toArray(array $keys = )
public function toXml(...)
public function convertToJson(array $keys = )
Using DataObject you can use callback functions
public function serialize(...)
Usage examples:
$types[$type] = new MagentoFrameworkDataObject(
[
'id' => $type,
'cache_type' => $node['label'],
'description' => $node['description'],
'tags' => $typeTags,
'status' => (int)$this->_cacheState->isEnabled($type),
]
);
add a comment |
DataObject is Universal data container with array access implementation. it holds the data for easy manipulations. and it is implemented by ArrayAccess. it contains getters/setters. This is constructor code.
/**
* Constructor
*
* By default is looking for first argument as array and assigns it as object attributes
* This behavior may change in child classes
*
* @param array $data
*/
public function __construct(array $data = )
{
$this->_data = $data;
}
it holds the data while creating object. you can create by empty data using addData(..) you can append data.
some of useful methods
public function toArray(array $keys = )
public function toXml(...)
public function convertToJson(array $keys = )
Using DataObject you can use callback functions
public function serialize(...)
Usage examples:
$types[$type] = new MagentoFrameworkDataObject(
[
'id' => $type,
'cache_type' => $node['label'],
'description' => $node['description'],
'tags' => $typeTags,
'status' => (int)$this->_cacheState->isEnabled($type),
]
);
DataObject is Universal data container with array access implementation. it holds the data for easy manipulations. and it is implemented by ArrayAccess. it contains getters/setters. This is constructor code.
/**
* Constructor
*
* By default is looking for first argument as array and assigns it as object attributes
* This behavior may change in child classes
*
* @param array $data
*/
public function __construct(array $data = )
{
$this->_data = $data;
}
it holds the data while creating object. you can create by empty data using addData(..) you can append data.
some of useful methods
public function toArray(array $keys = )
public function toXml(...)
public function convertToJson(array $keys = )
Using DataObject you can use callback functions
public function serialize(...)
Usage examples:
$types[$type] = new MagentoFrameworkDataObject(
[
'id' => $type,
'cache_type' => $node['label'],
'description' => $node['description'],
'tags' => $typeTags,
'status' => (int)$this->_cacheState->isEnabled($type),
]
);
edited 7 hours ago
answered 7 hours ago
Naisa purushothamNaisa purushotham
1619
1619
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f258139%2fwhat-is-magento-framework-dataobject-do%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown