/** * Return an array of the scoped attributes of the supplied node. * * @param \AwatBayazidi\Foundation\Tree\Node $node * @return array */ protected function scopedAttributes($node) { $keys = $this->node->getScopedColumns(); if (count($keys) == 0) { return array(); } $values = array_map(function ($column) use($node) { return $node->getAttribute($column); }, $keys); return array_combine($keys, $values); }
/** * Builds a single string for the given scope columns values. Useful for * making array keys for grouping. * * @param \AwatBayazidi\Foundation\Tree\Node $node * @return string */ protected function keyForScope($node) { return implode('-', array_map(function ($column) use($node) { $value = $node->getAttribute($column); if (is_null($value)) { return 'NULL'; } return $value; }, $node->getScopedColumns())); }