-
-
Notifications
You must be signed in to change notification settings - Fork 452
Unified creating of common blocks #5010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
I dislike that the new functions still returns false on missing block. $this->getLayout()->getBlockAdminhtmlHead()?->setCanLoadTinyMce(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a unified approach for creating and accessing common layout blocks by adding type-safe helper methods to Mage_Core_Model_Layout. The changes replace direct getBlock() calls with new specialized methods like getBlockHead(), getBlockRoot(), and getBlockBreadcrumbs() that return properly typed blocks or null, leveraging PHP's nullsafe operator for cleaner code.
- Adds new typed block accessor methods (
getBlockHead(),getBlockRoot(),getBlockBreadcrumbs(), etc.) toMage_Core_Model_Layout - Refactors all block access patterns across the codebase to use these new methods with nullsafe operator
- Deprecates the legacy
getBlock()method in favor ofgetBlockByName()
Reviewed Changes
Copilot reviewed 71 out of 71 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| app/code/core/Mage/Core/Model/Layout.php | Adds new typed block accessor methods and deprecates getBlock() |
| app/code/core/Mage/Wishlist/Block/Share/Wishlist.php | Refactors head block access using getBlockHead() |
| app/code/core/Mage/Wishlist/Block/Customer/Wishlist.php | Refactors head block access using getBlockHead() |
| app/code/core/Mage/Wishlist/Block/Customer/Sharing.php | Refactors head block access using getBlockHead() |
| app/code/core/Mage/Tag/controllers/CustomerController.php | Refactors head block access using getBlockHead() |
| app/code/core/Mage/Tag/Block/Product/Result.php | Refactors head and root block access using new methods |
| app/code/core/Mage/Sales/controllers/OrderController.php | Refactors head block access using getBlockHead() |
| app/code/core/Mage/Sales/Helper/Guest.php | Refactors breadcrumbs block access using getBlockBreadcrumbs() |
| app/code/core/Mage/Sales/Block/Order/*.php | Refactors head block access across multiple order-related blocks |
| app/code/core/Mage/Rss/Block/List.php | Refactors head block access with improved null handling |
| app/code/core/Mage/Review/controllers/*.php | Refactors head and breadcrumbs block access |
| app/code/core/Mage/Paypal/Controller/Express/Abstract.php | Refactors root block access with null check |
| app/code/core/Mage/Page/Helper/Layout.php | Refactors root block access using getBlockRoot() |
| app/code/core/Mage/Newsletter/controllers/ManageController.php | Refactors head block access using getBlockHead() |
| app/code/core/Mage/Downloadable/controllers/CustomerController.php | Refactors head block access using getBlockHead() |
| app/code/core/Mage/Customer/controllers/AccountController.php | Refactors head block access using getBlockHead() |
| app/code/core/Mage/Customer/Block/*.php | Refactors head block access across customer blocks |
| app/code/core/Mage/Core/Controller/Varien/Action.php | Refactors head block access in title rendering |
| app/code/core/Mage/Cms/Block/Page.php | Refactors breadcrumbs, root, and head block access |
| app/code/core/Mage/Checkout/controllers/*.php | Refactors head and root block access across checkout |
| app/code/core/Mage/Checkout/Block/Multishipping/*.php | Refactors head block access across multishipping blocks |
| app/code/core/Mage/CatalogSearch/Block/*.php | Refactors breadcrumbs and head block access |
| app/code/core/Mage/Catalog/controllers/CategoryController.php | Refactors root block access with improved method chaining |
| app/code/core/Mage/Catalog/Block/*.php | Refactors head and breadcrumbs block access across catalog |
| app/code/core/Mage/Adminhtml/controllers/*.php | Refactors adminhtml head block access using getBlockAdminhtmlHead() |
| app/code/core/Mage/Adminhtml/Controller/Action.php | Refactors menu and breadcrumbs block access with type declarations |
| app/code/core/Mage/Adminhtml/Block/*.php | Refactors adminhtml head and breadcrumbs block access |
| app/code/core/Mage/Adminhtml/Block/Page/Menu.php | Adds method docblocks for magic methods |
| app/code/core/Mage/Adminhtml/Block/Page/Head.php | Adds method docblocks for magic methods |
| app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php | Refactors head block access and method chaining |
| .rector.php | Adds commented-out rector rule for future method renaming |
Comments suppressed due to low confidence (1)
app/code/core/Mage/Adminhtml/Block/Page/Head.php:1
- Missing docblock for
setCanLoadTinyMce()method which is used throughout the codebase (e.g., in Newsletter/Template/Edit.php, Cms/Block/Edit/Form.php). Add:@method $this setCanLoadTinyMce(bool $value)
<?php
app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php
Outdated
Show resolved
Hide resolved
|
I'm with copilot there: |
|
Okay, change it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 71 out of 71 changed files in this pull request and generated 11 comments.
app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php
Show resolved
Hide resolved
app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php
Show resolved
Hide resolved
app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php
Show resolved
Hide resolved
app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php
Show resolved
Hide resolved
app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
This reverts commit ea085be.
|
i don't know why |
|
You are right. "Reference in new issue" and move on? |
|


This prevents calling methods on non existing blocks.
get Block()in favor ofgetBlockByName()that returnsnullor existing block, allowing to use PHP´8 null safe operator