Beispiel #1
0
 /**
  * Builds a single string for the given scope columns values. Useful for
  * making array keys for grouping.
  *
  * @param Baum\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()));
 }
Beispiel #2
0
 /**
  * Return an array with the last node we could reach and its nesting level
  *
  * @param   Baum\Node $node
  * @param   integer   $nesting
  *
  * @return  array
  */
 protected function determineDepth($node, $nesting = 0)
 {
     // Traverse back up the ancestry chain and add to the nesting level count
     while ($parent = $node->parent()->first()) {
         $nesting = $nesting + 1;
         $node = $parent;
     }
     return array($node, $nesting);
 }
Beispiel #3
0
 /**
  * Return an array of the scoped attributes of the supplied node.
  *
  * @param   Baum\Node $node
  * @return  array
  */
 protected function scopedAttributes($node)
 {
     $keys = $this->node->getScopedColumns();
     if (count($keys) == 0) {
         return [];
     }
     $values = array_map(function ($column) use($node) {
         return $node->getAttribute($column);
     }, $keys);
     return array_combine($keys, $values);
 }
Beispiel #4
0
 public static function boot()
 {
     parent::boot();
     //        App::register($this->service_provider);
 }