what is MagentoFrameworkDataObject do












2















can anyone explain what is MagentoFrameworkDataObject do.
I use it but I don't understand its core purpose Or which tables it deals with










share|improve this question



























    2















    can anyone explain what is MagentoFrameworkDataObject do.
    I use it but I don't understand its core purpose Or which tables it deals with










    share|improve this question

























      2












      2








      2


      1






      can anyone explain what is MagentoFrameworkDataObject do.
      I use it but I don't understand its core purpose Or which tables it deals with










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 7 hours ago









      Yomna MansourYomna Mansour

      969




      969






















          2 Answers
          2






          active

          oldest

          votes


















          2














          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.






          share|improve this answer































            1














            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),
            ]
            );





            share|improve this answer

























              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
              });


              }
              });














              draft saved

              draft discarded


















              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









              2














              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.






              share|improve this answer




























                2














                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.






                share|improve this answer


























                  2












                  2








                  2







                  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.






                  share|improve this answer













                  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.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 6 hours ago









                  MariusMarius

                  164k28312663




                  164k28312663

























                      1














                      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),
                      ]
                      );





                      share|improve this answer






























                        1














                        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),
                        ]
                        );





                        share|improve this answer




























                          1












                          1








                          1







                          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),
                          ]
                          );





                          share|improve this answer















                          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),
                          ]
                          );






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 7 hours ago

























                          answered 7 hours ago









                          Naisa purushothamNaisa purushotham

                          1619




                          1619






























                              draft saved

                              draft discarded




















































                              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.




                              draft saved


                              draft discarded














                              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





















































                              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







                              Popular posts from this blog

                              GameSpot

                              日野市

                              Tu-95轟炸機