/** * @param stdClass $row */ private function handleRow(stdClass $row) { $this->Tree->walk(function (stdClass $node, array $path) use($row) { # Check is this part already handled. Perform road. $road = []; $cache = $this->cache; foreach ($path as $it) { // !Enjoin::debug() ?: sd($row); $id = $it->prefix ? $row->{$it->prefix . Extras::GLUE_CHAR . 'id'} : $row->id; if (is_null($id)) { # Skip handle on `id = NULL` in sql result. // TODO: break walk return null; } // !Enjoin::debug() ?: sd($path); $prop = isset($it->asProp) ? $it->asProp : null; $mile = ['id' => $id, 'prop' => $prop]; list($cache, $mile['index']) = $this->getIndex($cache, $id, $prop); $road[] = $mile; } # Check last mile cache index: // if (is_null($mile['index'])) { if (!isset($mile['index'])) { $Record = $this->getRecord($node, $row); $this->applyRecord($this->records, $this->cache, $Record, $road); } }); }
/** * Group constructor. * @param Model $Model * @param Tree $Tree * @param string|array $params */ public function __construct(Model $Model, Tree $Tree, $params) { $this->Model = $Model; $this->tree = $Tree->get(); $this->params = $params; }