-
Notifications
You must be signed in to change notification settings - Fork 2
replacing cms block ID with block code [#9] #6
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
Conversation
Model/Service/DumpCmsDataService.php
Outdated
| $varDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR); | ||
| $varPath = $this->directoryList->getPath(DirectoryList::VAR_DIR); | ||
| $workingDirPath = $varPath . '/sync_cms_data'; | ||
| $this->blocksMapping = $this->getBlocksMapping(); |
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.
Don't do DB calls inside of __construct() method, __construct should only be used to initialize the variables, not populate them.
Model/Service/DumpCmsDataService.php
Outdated
| { | ||
| $blocksMapping = []; | ||
| $searchCriteria = $this->criteriaBuilder; | ||
| $blocksList = $this->blockRepository->getList($searchCriteria->create()); |
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.
You are pulling every block no matter how many are we actually exporting. Refactor this:
- Move calling this outside of __construct()
- add pagination support when pulling the data
- Call this method inside of replaceBlockIds() (pull all IDs for every call of replaceBlockId()), use the ->blocksMapping as a cache so it doesn't pull the same blockIDs over and over again
Model/Service/DumpCmsDataService.php
Outdated
| if (isset($this->blocksMapping[$blockId])) { | ||
| $identifier = $this->blocksMapping[$blockId]; | ||
| $content = str_replace("block_id=\"$blockId\"", "block_id=\"$identifier\"", $content); | ||
| if (!isset($this->blocksMapping[$blockId])) { |
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.
Better, but this approach now pulls from DB for every new block ID. I suggest pulling the data per replaceBlockIds() call. After if (isset($blockIds[1])) { you have a collection of $blockIds, use that to pull all of Ids at once. This way, we pull from DB only once per CMS block.
adding support for is_tailwindcss_jit_enabled [#6]
No description provided.