protected function getNestedBlocks() { ++$this->req->jobTotal; $this->req->appInstance->blocks->getBlocksByNames(array_unique($this->addedBlocksNames), function ($cursor) { Daemon::log('got cursor'); /** @var Cursor $cursor */ if (!$cursor->finished) { $cursor->getMore(); } else { $dbprops = array(); foreach ($cursor->items as $k => $block) { if (isset($block['name'])) { $dbprops[$block['name']] = $block; } } $cursor->destroy(); foreach ($this->addedBlocks as $block) { if (isset($block['name']) && isset($dbprops[$block['name']])) { $block = array_merge($block, $dbprops[$block['name']]); } if (!isset($block['type']) || !class_exists($class = __NAMESPACE__ . '\\Block' . $block['type'])) { $class = __NAMESPACE__ . '\\Block'; } new $class($block, $this); } unset($this->addedBlocks); ++$this->req->jobDone; $this->req->wakeup(); } }); $this->addedBlocksNames = null; $this->req->tpl->register_function('getblock', array($this->parentNode, 'getBlock')); }