From dca50e81ce835cb8e2ed7de8d5c298eff7a8ea3f Mon Sep 17 00:00:00 2001 From: CedCommerce Date: Tue, 8 Sep 2015 21:33:07 +0530 Subject: [PATCH] updated composer --- Block/DevTool/BlockHandles.php | 36 ++-- Block/DevTool/Collections.php | 58 +++--- Block/DevTool/Models.php | 58 +++--- Block/DevTool/Request.php | 80 ++++---- .../Event/Invoker/InvokerDefault.php | 178 ++++++++-------- Model/Observer.php | 192 +++++++++--------- composer.json | 37 ++-- etc/frontend/events.xml | 34 ++-- readme.md | 150 +++++++------- .../templates/devtool/blockhandles.phtml | 76 +++---- .../templates/devtool/collections.phtml | 48 ++--- view/frontend/templates/devtool/models.phtml | 48 ++--- view/frontend/templates/devtool/request.phtml | 94 ++++----- 13 files changed, 544 insertions(+), 545 deletions(-) diff --git a/Block/DevTool/BlockHandles.php b/Block/DevTool/BlockHandles.php index 8b6e19c..2316ad3 100644 --- a/Block/DevTool/BlockHandles.php +++ b/Block/DevTool/BlockHandles.php @@ -1,19 +1,19 @@ -_devToolHelper->getBlockDetails(); - } - +_devToolHelper->getBlockDetails(); + } + } \ No newline at end of file diff --git a/Block/DevTool/Collections.php b/Block/DevTool/Collections.php index fe96a9a..3512188 100644 --- a/Block/DevTool/Collections.php +++ b/Block/DevTool/Collections.php @@ -1,29 +1,29 @@ -_devToolHelper = $context->getDevToolHelper(); - parent::__construct($context); - - } - /** - * Retrun all the details related to collection on a particular page load - */ - public function getCollectionDetails() - { - return $this->_devToolHelper->getDevToolData($this->_devToolHelper->_collectionKey); - } - - -} +_devToolHelper = $context->getDevToolHelper(); + parent::__construct($context); + + } + /** + * Retrun all the details related to collection on a particular page load + */ + public function getCollectionDetails() + { + return $this->_devToolHelper->getDevToolData($this->_devToolHelper->_collectionKey); + } + + +} diff --git a/Block/DevTool/Models.php b/Block/DevTool/Models.php index 0651b42..f502897 100644 --- a/Block/DevTool/Models.php +++ b/Block/DevTool/Models.php @@ -1,29 +1,29 @@ -_devToolHelper = $context->getDevToolHelper(); - parent::__construct($context); - - } - /** - * Retrun all the details related to Models on a particular page load - */ - public function getModelDetails() - { - return $this->_devToolHelper->getDevToolData($this->_devToolHelper->_modelKey); - } - - -} +_devToolHelper = $context->getDevToolHelper(); + parent::__construct($context); + + } + /** + * Retrun all the details related to Models on a particular page load + */ + public function getModelDetails() + { + return $this->_devToolHelper->getDevToolData($this->_devToolHelper->_modelKey); + } + + +} diff --git a/Block/DevTool/Request.php b/Block/DevTool/Request.php index 0a329dc..bf67623 100644 --- a/Block/DevTool/Request.php +++ b/Block/DevTool/Request.php @@ -1,40 +1,40 @@ -_devToolHelper = $context->getDevToolHelper(); - $this->_getVariables = $request->getParams(); - parent::__construct($context); - - } - /** - * Retrun all the details related to Module/Controller/Action on a particular page load - */ - public function getRequestDetails() - { - return $this->_devToolHelper->getDevToolData($this->_devToolHelper->_requestKey); - } - /** - * Retrun all the details related to GET ad POST variables on a particular page load - */ - public function getPostGetVariableDetails() - { - return $this->_getVariables; - } - - - -} +_devToolHelper = $context->getDevToolHelper(); + $this->_getVariables = $request->getParams(); + parent::__construct($context); + + } + /** + * Retrun all the details related to Module/Controller/Action on a particular page load + */ + public function getRequestDetails() + { + return $this->_devToolHelper->getDevToolData($this->_devToolHelper->_requestKey); + } + /** + * Retrun all the details related to GET ad POST variables on a particular page load + */ + public function getPostGetVariableDetails() + { + return $this->_getVariables; + } + + + +} diff --git a/Model/Framework/Event/Invoker/InvokerDefault.php b/Model/Framework/Event/Invoker/InvokerDefault.php index 9541d78..5d9be52 100644 --- a/Model/Framework/Event/Invoker/InvokerDefault.php +++ b/Model/Framework/Event/Invoker/InvokerDefault.php @@ -1,89 +1,89 @@ -_observerFactory = $observerFactory; - $this->_appState = $appState; - $this->_devHelper =$helper; - - } - - /** - * Dispatch event - * - * @param array $configuration - * @param Observer $observer - * @return void - */ - public function dispatch(array $configuration, Observer $observer) - { - - /** Check whether event observer is disabled */ - if (isset($configuration['disabled']) && true === $configuration['disabled']) { - return; - } - - if (isset($configuration['shared']) && false === $configuration['shared']) { - $object = $this->_observerFactory->create($configuration['instance']); - } else { - $object = $this->_observerFactory->get($configuration['instance']); - } - $this->_devHelper->setObserverDetails($configuration,get_class($object)); - $this->_callObserverMethod($object, $configuration['method'], $observer); - } - - /** - * Performs non-existent observer method calls protection - * - * @param object $object - * @param string $method - * @param Observer $observer - * @return $this - * @throws \LogicException - */ - protected function _callObserverMethod($object, $method, $observer) - { - if (method_exists($object, $method) && is_callable([$object, $method])) { - $object->{$method}($observer); - } elseif ($this->_appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) { - throw new \LogicException('Method "' . $method . '" is not defined in "' . get_class($object) . '"'); - } - return $this; - } -} +_observerFactory = $observerFactory; + $this->_appState = $appState; + $this->_devHelper =$helper; + + } + + /** + * Dispatch event + * + * @param array $configuration + * @param Observer $observer + * @return void + */ + public function dispatch(array $configuration, Observer $observer) + { + + /** Check whether event observer is disabled */ + if (isset($configuration['disabled']) && true === $configuration['disabled']) { + return; + } + + if (isset($configuration['shared']) && false === $configuration['shared']) { + $object = $this->_observerFactory->create($configuration['instance']); + } else { + $object = $this->_observerFactory->get($configuration['instance']); + } + $this->_devHelper->setObserverDetails($configuration,get_class($object)); + $this->_callObserverMethod($object, $configuration['method'], $observer); + } + + /** + * Performs non-existent observer method calls protection + * + * @param object $object + * @param string $method + * @param Observer $observer + * @return $this + * @throws \LogicException + */ + protected function _callObserverMethod($object, $method, $observer) + { + if (method_exists($object, $method) && is_callable([$object, $method])) { + $object->{$method}($observer); + } elseif ($this->_appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) { + throw new \LogicException('Method "' . $method . '" is not defined in "' . get_class($object) . '"'); + } + return $this; + } +} diff --git a/Model/Observer.php b/Model/Observer.php index b317df7..03a2586 100644 --- a/Model/Observer.php +++ b/Model/Observer.php @@ -1,97 +1,97 @@ -_devtoolData = $devtoolData; - $this->_registry = $registry; - } - - /* - * blocks , handles and template info is saved for current request - * via helpers - */ - public function setBlockname(\Magento\Framework\Event\Observer $observer) - { - if(!$this->_devtoolData->getBlockStatus()) { - foreach ($observer->getBlock()->getLayout()->getAllBlocks() as $block) { - $this->_devtoolData->addBlockInfo($block->getNameInLayout(),get_class($block),$block->getTemplateFile()); - } - $this->_devtoolData->setBlockStatus(); - } - } - - public function onEveryModelLoad(\Magento\Framework\Event\Observer $observer) - { - $event = $observer->getEvent(); - $object = $event->getObject(); - $key = get_class($object); - - if( array_key_exists($key, $this->models) ) { - $this->models[$key]['occurences']++; - } else { - $model = array(); - $model['class'] = get_class($object); - $model['resource_name'] = $object->getResourceName(); - $model['occurences'] = 1; - $this->models[$key] = $model; - - } - $this->_devtoolData->addDevToolData($this->_devtoolData->_modelKey,$this->models); - return $this; - } - /** - * Register All the Collection related details on the event core_collection_abstract_load_before - */ - public function onEveryCollectionLoad(\Magento\Framework\Event\Observer $observer) - { - $collection = $observer->getCollection(); - - $collectionArray = array(); - $collectionArray['sql'] = $collection->getSelectSql(true); - $collectionArray['type'] = 'Flat'; - $collectionArray['class'] = get_class($collection); - $this->collections[] = $collectionArray; - $this->_devtoolData->addDevToolData($this->_devtoolData->_collectionKey , $this->collections); - - } - /** - * Register All the EAV Collection related details on the event eav_collection_abstract_load_before - */ - public function onEveryEavCollectionLoad(\Magento\Framework\Event\Observer $observer) - { - $collection = $observer->getCollection(); - $collectionArrayEav = array(); - $collectionArrayEav['sql'] = $collection->getSelectSql(true); - $collectionArrayEav['type'] = 'Eav'; - $collectionArrayEav['class'] = get_class($collection); - $this->collections[] = $collectionArrayEav; - $this->_devtoolData->addDevToolData($this->_devtoolData->_collectionKey , $this->collections); - } - /** - * Register All the Controller related details on the event controller_action_postdispatch - */ - public function onControllerCall(\Magento\Framework\Event\Observer $observer) - { - $action = $observer->getControllerAction(); - $actionArray = array(); - $actionArray['Controller Name'] = $action->getRequest()->getControllerName(); - $actionArray['Action Name'] = $action->getRequest()->getActionName(); - $actionArray['Module Name'] = $action->getRequest()->getRouteName(); - $actionArray['Path Info'] = $action->getRequest()->getPathInfo(); - $this->actions[] = $actionArray; - $this->_devtoolData->addDevToolData($this->_devtoolData->_requestKey , $this->actions); - } +_devtoolData = $devtoolData; + $this->_registry = $registry; + } + + /* + * blocks , handles and template info is saved for current request + * via helpers + */ + public function setBlockname(\Magento\Framework\Event\Observer $observer) + { + if(!$this->_devtoolData->getBlockStatus()) { + foreach ($observer->getBlock()->getLayout()->getAllBlocks() as $block) { + $this->_devtoolData->addBlockInfo($block->getNameInLayout(),get_class($block),$block->getTemplateFile()); + } + $this->_devtoolData->setBlockStatus(); + } + } + + public function onEveryModelLoad(\Magento\Framework\Event\Observer $observer) + { + $event = $observer->getEvent(); + $object = $event->getObject(); + $key = get_class($object); + + if( array_key_exists($key, $this->models) ) { + $this->models[$key]['occurences']++; + } else { + $model = array(); + $model['class'] = get_class($object); + $model['resource_name'] = $object->getResourceName(); + $model['occurences'] = 1; + $this->models[$key] = $model; + + } + $this->_devtoolData->addDevToolData($this->_devtoolData->_modelKey,$this->models); + return $this; + } + /** + * Register All the Collection related details on the event core_collection_abstract_load_before + */ + public function onEveryCollectionLoad(\Magento\Framework\Event\Observer $observer) + { + $collection = $observer->getCollection(); + + $collectionArray = array(); + $collectionArray['sql'] = $collection->getSelectSql(true); + $collectionArray['type'] = 'Flat'; + $collectionArray['class'] = get_class($collection); + $this->collections[] = $collectionArray; + $this->_devtoolData->addDevToolData($this->_devtoolData->_collectionKey , $this->collections); + + } + /** + * Register All the EAV Collection related details on the event eav_collection_abstract_load_before + */ + public function onEveryEavCollectionLoad(\Magento\Framework\Event\Observer $observer) + { + $collection = $observer->getCollection(); + $collectionArrayEav = array(); + $collectionArrayEav['sql'] = $collection->getSelectSql(true); + $collectionArrayEav['type'] = 'Eav'; + $collectionArrayEav['class'] = get_class($collection); + $this->collections[] = $collectionArrayEav; + $this->_devtoolData->addDevToolData($this->_devtoolData->_collectionKey , $this->collections); + } + /** + * Register All the Controller related details on the event controller_action_postdispatch + */ + public function onControllerCall(\Magento\Framework\Event\Observer $observer) + { + $action = $observer->getControllerAction(); + $actionArray = array(); + $actionArray['Controller Name'] = $action->getRequest()->getControllerName(); + $actionArray['Action Name'] = $action->getRequest()->getActionName(); + $actionArray['Module Name'] = $action->getRequest()->getRouteName(); + $actionArray['Path Info'] = $action->getRequest()->getPathInfo(); + $this->actions[] = $actionArray; + $this->_devtoolData->addDevToolData($this->_devtoolData->_requestKey , $this->actions); + } } \ No newline at end of file diff --git a/composer.json b/composer.json index b7259d3..6d142d0 100644 --- a/composer.json +++ b/composer.json @@ -1,19 +1,18 @@ -{ - "name": "ced/module-devtool", - "description": "Magento 2 Developer-Debug Tool by CedCommerce", - "type": "magento2-module", - "version": "1.0.0", - "require": { - "php": "~5.5.0|~5.6.0", - "magento/magento-composer-installer": "*" - }, - "minimum-stability": "dev", - "extra": { - "map": [ - [ - "*", - "Ced/DevTool" - ] - ] - } -} \ No newline at end of file +{ + "name": "cedcommerce/magento2-developer-debug-tool", + "description": "Dev Tool test", + "require": { + "php": "~5.5.0|~5.6.0", + "magento/magento-composer-installer": "*" + }, + "type": "magento2-module", + "extra": { + "map": [ + [ + "*", + "Ced/DevTool" + ] + ] + } +} + diff --git a/etc/frontend/events.xml b/etc/frontend/events.xml index 9fa6fd9..b057cb0 100644 --- a/etc/frontend/events.xml +++ b/etc/frontend/events.xml @@ -1,18 +1,18 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/readme.md b/readme.md index bc2b7d2..6e9a5f7 100644 --- a/readme.md +++ b/readme.md @@ -1,75 +1,75 @@ - - -# Magento 2 Developer-Debug Tool by CedCommerce - - -**Magento 2 Developer-Debug Tool**, a Magento 2.0 development and debugging extension, which aims at easing developers concerns by fetching vital information for a current page load. The extension users are provided with complete set of data related to a current page request, collections and models called during a page load. Besides this, all observer called events data, along with parent and its extended classes of a page load are viewable by developers. Further, data information on blocks with their respective handle names, and associated template files with full file path is also communicated to the extension users. -However, in the absence of **Magento 2 Developer-Debug Tool**, developers are tasked with tracking of all important data via Magento’s backend. -The data in the module has been divided into tabs, which can be viewed at module’s bottom page, after it’s being configured from the admin section. Each tab is designed to allow developers to have better understanding on data related to the current page load. - -![](images/Block.png) - -## Tabs and their Utility Features - -- **REQUEST TAB**: shows the **Module, Controller, Action** name of the recently loaded page. Provides accurate **Path Info** of the loaded page, the feature help developers for URL rewriting. - -- **MODEL TAB: shows all the **Model Resource Name** and their respective **Class Name** in a sequenced manner to narrate loaded models mechanism during a page load. Also mentions, frequency of instantiated models. - -- **COLLECTIONS TAB**: shows all the active collections and its types (Flat/EAV) along with SQL Queries generated during a page load. - -- **OBSERVER EVENTS**: shows all events and its details called during page load. Observer details like Observer Name, Observer Function, Observer Class and Observer Frequency of being instantiated are also provided. - -- **ALL PREFERENCES/REWRITES**: shows both, all the extended classes and also the classes which extend the classes. - - -- **HANDLES, BLOCKS AND TEMPLATES**: shows all the block name of the currently loaded page with their respective handle names. Block is responsible for showing path of the template file. - -- **SYSTEM TASKS**: this is a special feature as it allows developer to enable or disable Path hints and Cache. Besides, flushing the system cache from Magento 2 frontend only. - -## Compatibility - -**Magento 2 Developer-Debug** module is tested on the **2.0.0.0-dev35** version of Magento 2.0. The tool is launched with a goal to help global developers, who are willing to leave no stone unturned in analyzing structure of Magento 2.0. - -##Installing and verifying the reference module -You can install the reference module in any of the following ways: - -- By copying the code to your /app/code// directory. -This method requires some manual tasks but it easy. -- Using composer update. - -##Installing the module by copying code -Any Magento module requires a particular directory structure under /app/code. The structure starts with: -< PackageName>/ -The reference module requires the following structure: -Ced/DevTool -To add the module to your Magento installation: - -- Log in to your Magento server as a user with privileges to write to the web server docroot (typically either the root user or the web server user). -- Enter the following commands in the order shown: -- cd /app/code -- Go to the reference module GitHub -- Click **Download Zip.** -- Copy the .zip file you downloaded to your Magento server's /app/code/. -- Enter the following commands in the order shown: -- unzip Magento2-Developer-Debug-Tool-master.zip -- mv Magento2-Developer-Debug-Tool-master/* . -- rm -rf Magento2-Developer-Debug-Tool-master -- Open /app/etc/config.php in a text editor. -- Add the following anywhere under: 'modules' => array (: -- 'Ced_DevTool' => 1, -- Save your changes and exit the text editor. - -##Installing the module using Composer - We will update this soon - -## Authors, contributors and maintainers - -![](images/Logo.png) - - - -## License - -[GPL v3](LICENSE.txt) - - + + +# Magento 2 Developer-Debug Tool by CedCommerce + + +**Magento 2 Developer-Debug Tool**, a Magento 2.0 development and debugging extension, which aims at easing developers concerns by fetching vital information for a current page load. The extension users are provided with complete set of data related to a current page request, collections and models called during a page load. Besides this, all observer called events data, along with parent and its extended classes of a page load are viewable by developers. Further, data information on blocks with their respective handle names, and associated template files with full file path is also communicated to the extension users. +However, in the absence of **Magento 2 Developer-Debug Tool**, developers are tasked with tracking of all important data via Magento’s backend. +The data in the module has been divided into tabs, which can be viewed at module’s bottom page, after it’s being configured from the admin section. Each tab is designed to allow developers to have better understanding on data related to the current page load. + +![](images/Block.png) + +## Tabs and their Utility Features + +- **REQUEST TAB**: shows the **Module, Controller, Action** name of the recently loaded page. Provides accurate **Path Info** of the loaded page, the feature help developers for URL rewriting. + +- **MODEL TAB: shows all the **Model Resource Name** and their respective **Class Name** in a sequenced manner to narrate loaded models mechanism during a page load. Also mentions, frequency of instantiated models. + +- **COLLECTIONS TAB**: shows all the active collections and its types (Flat/EAV) along with SQL Queries generated during a page load. + +- **OBSERVER EVENTS**: shows all events and its details called during page load. Observer details like Observer Name, Observer Function, Observer Class and Observer Frequency of being instantiated are also provided. + +- **ALL PREFERENCES/REWRITES**: shows both, all the extended classes and also the classes which extend the classes. + + +- **HANDLES, BLOCKS AND TEMPLATES**: shows all the block name of the currently loaded page with their respective handle names. Block is responsible for showing path of the template file. + +- **SYSTEM TASKS**: this is a special feature as it allows developer to enable or disable Path hints and Cache. Besides, flushing the system cache from Magento 2 frontend only. + +## Compatibility + +**Magento 2 Developer-Debug** module is tested on the **2.0.0.0-dev35** version of Magento 2.0. The tool is launched with a goal to help global developers, who are willing to leave no stone unturned in analyzing structure of Magento 2.0. + +##Installing and verifying the reference module +You can install the reference module in any of the following ways: + +- By copying the code to your /app/code// directory. +This method requires some manual tasks but it easy. +- Using composer update. + +##Installing the module by copying code +Any Magento module requires a particular directory structure under /app/code. The structure starts with: +< PackageName>/ +The reference module requires the following structure: +Ced/DevTool +To add the module to your Magento installation: + +- Log in to your Magento server as a user with privileges to write to the web server docroot (typically either the root user or the web server user). +- Enter the following commands in the order shown: +- cd /app/code +- Go to the reference module GitHub +- Click **Download Zip.** +- Copy the .zip file you downloaded to your Magento server's /app/code/. +- Enter the following commands in the order shown: +- unzip Magento2-Developer-Debug-Tool-master.zip +- mv Magento2-Developer-Debug-Tool-master/* . +- rm -rf Magento2-Developer-Debug-Tool-master +- Open /app/etc/config.php in a text editor. +- Add the following anywhere under: 'modules' => array (: +- 'Ced_DevTool' => 1, +- Save your changes and exit the text editor. + +##Installing the module using Composer + We will update this soon + +## Authors, contributors and maintainers + +![](images/Logo.png) + + + +## License + +[GPL v3](LICENSE.txt) + + diff --git a/view/frontend/templates/devtool/blockhandles.phtml b/view/frontend/templates/devtool/blockhandles.phtml index 5f96848..1082da3 100644 --- a/view/frontend/templates/devtool/blockhandles.phtml +++ b/view/frontend/templates/devtool/blockhandles.phtml @@ -1,38 +1,38 @@ - - -
-
-
Blocks
Handle
Associated Template
- getBlockHandleDetails() as $bloc){ - echo '
'.$bloc['class'].'
'.$bloc['handle'].'
'.$bloc['template'].'
'; - } - ?> -
-
+ + +
+
+
Blocks
Handle
Associated Template
+ getBlockHandleDetails() as $bloc){ + echo '
'.$bloc['class'].'
'.$bloc['handle'].'
'.$bloc['template'].'
'; + } + ?> +
+
diff --git a/view/frontend/templates/devtool/collections.phtml b/view/frontend/templates/devtool/collections.phtml index 0982b17..22d2ac6 100644 --- a/view/frontend/templates/devtool/collections.phtml +++ b/view/frontend/templates/devtool/collections.phtml @@ -1,25 +1,25 @@ -getCollectionDetails(); - -?> - - - - - - - - - - - - - - - - - - - +getCollectionDetails(); + +?> +
+ + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/view/frontend/templates/devtool/models.phtml b/view/frontend/templates/devtool/models.phtml index 0bf95fa..07fd0c1 100644 --- a/view/frontend/templates/devtool/models.phtml +++ b/view/frontend/templates/devtool/models.phtml @@ -1,25 +1,25 @@ -getModelDetails(); -//var_dump($items);die; -?> - - - - - - - - - - - - - - - - - - - +getModelDetails(); +//var_dump($items);die; +?> +
+ + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/view/frontend/templates/devtool/request.phtml b/view/frontend/templates/devtool/request.phtml index 5876908..ee4d863 100644 --- a/view/frontend/templates/devtool/request.phtml +++ b/view/frontend/templates/devtool/request.phtml @@ -1,47 +1,47 @@ -getRequestDetails(); -$getpostVariables = $this->getPostGetVariableDetails(); - -?> -

- - - - - - - - - - $item ): ?> - - - - - - -
- -

- - - - - - - - - - - - - $item ): ?> - - - - - - -
- +getRequestDetails(); +$getpostVariables = $this->getPostGetVariableDetails(); + +?> +

+ + + + + + + + + + $item ): ?> + + + + + + +
+ +

+ + + + + + + + + + + + + $item ): ?> + + + + + + +
+