Skip to content

Conversation

@rocketweb
Copy link
Collaborator

No description provided.

$varDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
$varPath = $this->directoryList->getPath(DirectoryList::VAR_DIR);
$workingDirPath = $varPath . '/sync_cms_data';
$this->blocksMapping = $this->getBlocksMapping();
Copy link
Collaborator Author

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.

{
$blocksMapping = [];
$searchCriteria = $this->criteriaBuilder;
$blocksList = $this->blockRepository->getList($searchCriteria->create());
Copy link
Collaborator Author

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

if (isset($this->blocksMapping[$blockId])) {
$identifier = $this->blocksMapping[$blockId];
$content = str_replace("block_id=\"$blockId\"", "block_id=\"$identifier\"", $content);
if (!isset($this->blocksMapping[$blockId])) {
Copy link
Collaborator Author

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.

rocketweb pushed a commit that referenced this pull request Jan 8, 2024
adding support for is_tailwindcss_jit_enabled [#6]
@rocketweb rocketweb merged commit 70759f2 into main Jan 8, 2024
@rocketweb rocketweb deleted the ICP-9_translate_block_id branch January 8, 2024 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants