Short description of method extractTreeData

@access public
@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
@param  array $data
@param  boolean $recursive
@return array
330589
public static function extractTreeData($data, $recursive = false)
    {
        $returnValue = array();




        if(isset($data['data'])){
        	$data = array($data);
        }
        foreach($data as $node){
        	$returnValue[$node['attributes']['id']] = $node['data'];
        	if(isset($node['children'])){
        		$returnValue = array_merge($returnValue, self::extractTreeData($node['children'], true));
        	}
        }



        return (array) $returnValue;
    }
1067808
public function listWith(array $keys = [], $directory = '', $recursive = false)
    {
        $contents = $this->listContents($directory, $recursive);

        foreach ($contents as $index => $object) {
            if ($object['type'] === 'file') {
                $missingKeys = \array_diff($keys, \array_keys($object));
                $contents[$index] = \array_reduce($missingKeys, [$this, 'getMetadataByName'], $object);
            }
        }

        return $contents;
    }
302045
public function getMessages(bool $recursive = true): array {
		if (!$recursive) return [];
		
		$messages = [];
		
		foreach ($this->validationResults as $validationResult) {
			$vrMessages = $validationResult->getMessages();
			
			if (empty($vrMessages)) continue;
			
			array_push($messages, ...$validationResult->getMessages());
		}
		
		return $messages;
	}
550437
public static function to_object($array, $recursive = false) {
        if (!is_object($array) && !is_array($array)) return $array;

        if (!$recursive) return (object)$array;

        if (is_array($array)) return (object)array_map([
            __CLASS__,
            'to_object'
        ], $array);
        else return $array;
    }
468356
protected function _extractData($data)
    {
        $extractedData = array();

        foreach ($data as $key => $value) {
            $type = 'scalar';
            $options = array();

            if (is_array($value)) {
                if (isset($value['type'])) {
                    $type = $value['type'];
                    if (isset($value['default'])) {
                        $options['default'] = $value['default'];
                    }

                    if (isset($value['label'])) {
                        $options['label'] = $value['label'];
                    }

                    if (isset($value['accept'])) {
                        $options['accept'] = $value['accept'];
                    }

                    if (isset($value['maxentry'])) {
                        $options['maxentry'] = $value['maxentry'];
                    }

                    if (isset($value['minentry'])) {
                        $options['minentry'] = $value['minentry'];
                    }

                    if (isset($value['parameters'])) {
                        $options['parameters'] = $value['parameters'];
                    }

                    if (isset($value['extra'])) {
                        $options['extra'] = $value['extra'];
                    }
                } else {
                    $type = 'array';
                    $options['default'] = $value;
                }
            } else {
                $value = trim($value);

                if (strpos($value, '!!') === 0) {
                    $typedValue = explode(' ', $value, 2);
                    $type = str_replace('!!', '', $typedValue[0]);
                    if (isset($typedValue[1])) {
                        $options['default'] = $typedValue[1];
                    }
                }
            }

            $extractedData[$key] = array('type' => $type, 'options' => $options);
        }

        return $extractedData;
    }
1073148
public function getAllChildren($recursive = false)
    {
        return $this->appendIterator(
            function ($path) use ($recursive) {
                return $path->getIterator($recursive);
            }
        );
    }
9280
private static function _toArray($data, $recursion = false)
    {
        $tmp  = array();
        $data = (array) $data;
        foreach ($data as $k => $v) {
            $v = (array) $v;
            if (isset($v[0]) && is_string($v[0])) {
                $tmp[$k] = $v[0];
            } else {
                $tmp[$k] = self::_toArray($v, true);
            }
        }
        return $tmp;
    }
51733
public function getValue($recursive = false)
    {
        $item = $this->data[$this->position][$this->key];

        if ($item instanceof Stub && Stub::TYPE_REF === $item->type && !$item->position) {
            $item = $item->value;
        }
        if (!($item = $this->getStub($item)) instanceof Stub) {
            return $item;
        }
        if (Stub::TYPE_STRING === $item->type) {
            return $item->value;
        }

        $children = $item->position ? $this->data[$item->position] : [];

        foreach ($children as $k => $v) {
            if ($recursive && !($v = $this->getStub($v)) instanceof Stub) {
                continue;
            }
            $children[$k] = clone $this;
            $children[$k]->key = $k;
            $children[$k]->position = $item->position;

            if ($recursive) {
                if (Stub::TYPE_REF === $v->type && ($v = $this->getStub($v->value)) instanceof Stub) {
                    $recursive = (array) $recursive;
                    if (isset($recursive[$v->position])) {
                        continue;
                    }
                    $recursive[$v->position] = true;
                }
                $children[$k] = $children[$k]->getValue($recursive);
            }
        }

        return $children;
    }
1105934
public static function toArray($data, bool $recursive = false)
    {
        $arr = [];

        // Ensure the input data is an array.
        if (\is_object($data)) {
            if ($data instanceof \Traversable) {
                $arr = \iterator_to_array($data);
            } elseif (\method_exists($data, 'toArray')) {
                $arr = $data->toArray();
            }
        } else {
            $arr = (array)$data;
        }

        if ($recursive) {
            foreach ($arr as $key => $value) {
                if (\is_array($value) || \is_object($value)) {
                    $arr[$key] = static::toArray($value, $recursive);
                }
            }
        }

        return $arr;
    }
695981
public function forceSave(array $data = [], $recursive = false)
    {
        return ($recursive) ? $this->recurse('save', $data) : $this->saveRecord($data);
    }
1225885
public function dump($recursive = false)
    {
        $dataset = $this->data;

        if ($recursive) {
            $dataset = static::allToArray($dataset);
        }

        return $dataset;
    }
52716
public static function camelize(array $data, $recursive = true)
    {
        $return = [];

        foreach ($data as $key => $value) {
            if (is_array($value) && $recursive) {
                $value = self::camelize($value, $recursive);
            }

            $return[Inflector::camelize($key)] = $value;
        }

        return $return;
    }
814106
public static function rmWorkingCopy($path, $recursive = true)
    {
        $returnValue = (bool) false;

        
		
		if (is_file($path)) {
			if(preg_match('/^\//', $path)){
				$returnValue = @unlink($path);
			}
		} else if ($recursive) {
			if (is_dir($path)) {
				$iterator = new DirectoryIterator($path);
				foreach ($iterator as $fileinfo) {
					if (!$fileinfo->isDot()) {
						self::rmWorkingCopy($fileinfo->getPathname(), true);
					}
					unset($fileinfo);
				}
				unset($iterator);
				$returnValue = @rmdir($path);
			}
		}
						
        

        return (bool) $returnValue;
    }
962689
public function delete($recursive = false)
	{
		if ( ! $recursive)
		{
			return parent::delete();
		}

		$finder = new Finder();
		$contents = $finder->listContents($this->path);

		foreach($contents as $item)
		{
			$item->delete(true);
		}

		return parent::delete();
	}
641820
public function getTermsTreeData($parentID = 0)
    {
        $tree = Hierarchy::getTree($this->id);

        $data = [];

        static::mapTreeDataRecursive($tree, $data, $parentID);

        return $data;
    }
1301669
public function readDirectory($directory, $recursive = true)
    {
        if (is_dir($directory) === false) {
            return false;
        }

        try {
            $resource = opendir($directory);
            $contents = array();

            while (false !== ($item = readdir($resource)))
            {
                if (in_array($item, array('.', '..'))
                    || substr($item, 0, 1) == '_') {
                    continue;
                }

                $absoluteItem = $directory . DIRECTORY_SEPARATOR . $item;
                if ($recursive === true && is_dir($absoluteItem)) {
                    $contents[$item] = $this->readDirectory($absoluteItem, $recursive);
                } else {
                    $contents[$item] = $absoluteItem;
                }
            }
        } catch(\Exception $e) {
            return false;
        }

        return $contents;
    }
1151371
public function listContents($recursive = false)
	{
		return $this->hasAdapterOrFail()->adapter->listContents($this->getPath(), $recursive);
	}