Generates automatic parent_id field value

@param   array   $data  the data being saved
@return  string
552427
public function automaticParentId($data)
	{
		if (!isset($data['parent_id']))
		{
			$data['parent_id'] = 0;
		}

		if ((!isset($data['id']) || !$data['id'])
		 && ($data['parent_id'] == 0))
		{
			$data['parent_id'] = self::getRootId();
		}

		return $data['parent_id'];
	}
265117
protected function getId(array $data)
    {
        $result = null;

        if (isset($data['id'])) {
            $result = $data['id'];
        } elseif (isset($data['name'])) {
            $result = $data['name'];
        } else {
            #$result = sha1($data['action'] . $data['method']);
            $result = sha1(serialize($data));
        }

        return $result;
    }
786884
public function selected( array $data )
    {
        if ( isset( $data[self::PROPERTIES_FIELD] ) &&
             is_string( $data[self::PROPERTIES_FIELD] ) )
        {
            $data[self::PROPERTIES_FIELD] =
                $this->parseProperties( $data[self::PROPERTIES_FIELD] );
        }

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

        $data = [];

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

        return $data;
    }
207491
public function selected( array $data )
    {
        if ( isset( $data['tags'] ) && is_string( $data['tags'] ) )
        {
            $data['tags'] = explode( static::TAG_SEPARATOR, $data['tags'] );
        }

        if ( isset( $data['tagIds'] ) && is_string( $data['tagIds'] ) )
        {
            $data['tagIds'] = explode( static::TAG_SEPARATOR, $data['tagIds'] );
        }

        if ( isset( $data['localeTags'] ) && is_string( $data['localeTags'] ) )
        {
            $data['localeTags'] = explode( static::TAG_SEPARATOR, $data['localeTags'] );
        }

        if ( isset( $data['proxyData'] ) && is_string( $data['proxyData'] ) )
        {
            $data['proxyData'] = $this->parseProxyData( $data['proxyData'] );
        }

        return parent::selected( $data );
    }
1212719
protected function bindData(&$parent, $data)
  {
    if ( is_object($data) ){
      $data = get_object_vars($data);
    }
    else {
      $data = (array) $data;
    }
    
    foreach($data as $k => $v){
      if ( (is_array($v) && ArrayHelper::isAssociative($v)) || is_object($v) ){
        $parent->$k = new \stdClass;
        $this->bindData($parent->$k, $v);
      }
      else {
        $parent->$k = $v;
      }
    }
  }
721193
private function getParentId()
    {
        $posted = $this->appRequest->getPostValue();
        if (isset($posted['customer'][ABlock::TMPL_FLDGRP][ABlock::TMPL_FIELD_PARENT_MLM_ID])) {
            $mlmId = $posted['customer'][ABlock::TMPL_FLDGRP][ABlock::TMPL_FIELD_PARENT_MLM_ID];
            $found = $this->daoDwnlCust->getByMlmId($mlmId);
            if ($found) {
                $result = $found->getCustomerRef();
            }
        } else {
            $result = null;
        }
        return $result;
    }
932134
public function format(array $data)
    {
        $value = parent::format($data);
        foreach ($this->list as $uri => $values) {
            if (in_array($value, $values)) {
                return $uri;
            }
        }
        return '';
    }
1338893
public function generate(array $data): string
    {
        /** @var RecordFinder $recordFinder */
        $recordFinder = GeneralUtility::makeInstance(RecordFinder::class);
        $uidOfStyleguideRootPage = $recordFinder->findPidOfMainTableRecord('tx_styleguide');
        $uidOfElementsBasicPage = $recordFinder->findPidOfMainTableRecord('tx_styleguide_elements_basic');
        $uidOfElementsGroupPage = $recordFinder->findPidOfMainTableRecord('tx_styleguide_elements_group');
        $result = [];
        // Don't add first page if not selectable
        if (!isset($data['fieldConfig']['config']['treeConfig']['appearance']['nonSelectableLevels'])) {
            $result[] = $uidOfStyleguideRootPage;
        }
        // Don't add sub pages if maxlevels is set
        if (!isset($data['fieldConfig']['config']['treeConfig']['appearance']['maxLevels'])
            || (isset($data['fieldConfig']['config']['treeConfig']['appearance']['maxLevels'])
                && $data['fieldConfig']['config']['treeConfig']['appearance']['maxLevels'] > 1)
        ) {
            $result[] = $uidOfElementsBasicPage;
            $result[] = $uidOfElementsGroupPage;
        }
        return implode(',', $result);
    }
1034325
public function create(array $data, array $options = [])
    {
        if (isset($data['id']) && $this->hasNode($data['id'])) {
            return $this->getNode($data['id']);
        }

        $options = array_replace_recursive(
            [
                'addParentsAndChildren'     => true
            ],
            $options
        );

        $bkp = $data;

        if (isset($data['children'])) {
            if (!is_array($data['children'])) {
                throw ValidationException::create('Field "children" must be an array.');
            }

            $data['childrenIds'] = [];

            foreach ($data['children'] as $i => $nodeData) {
                if (!is_array($nodeData)) {
                    throw ValidationException::create(
                        'Field "children" must be an array of arrays.'
                    );
                }

                $node = $this->create($nodeData, array_merge($options, ['addParentsAndChildren' => false]));

                $data['childrenIds'][] = $node->getId();
            }

            unset($data['children']);
        }

        if (isset($data['parents'])) {
            if (!is_array($data['parents'])) {
                throw ValidationException::create('Field "parents" must be an array.');
            }

            $data['parentsIds'] = [];

            foreach ($data['parents'] as $i => $nodeData) {
                if (!is_array($nodeData)) {
                    throw ValidationException::create(
                        'Field "parents" must be an array of arrays.'
                    );
                }

                $node = $this->create($nodeData, array_merge($options, ['addParentsAndChildren' => false]));

                $data['parentsIds'][] = $node->getId();
            }

            unset($data['parents']);
        }

        $node = $this->createNodeInstance($data, $options);

        if ($options['addParentsAndChildren']) {
            $func = function(array $data) use (&$func) {
                if (isset($data['children'])) {
                    foreach ($data['children'] as $nodeData) {
                        $this->getNode($data['id'])->addChild($this->getNode($nodeData['id']));

                        $func($nodeData);
                    }
                }

                if (isset($data['parents'])) {
                    foreach ($data['parents'] as $nodeData) {
                        $this->getNode($data['id'])->addParent($this->getNode($nodeData['id']));

                        $func($nodeData);
                    }
                }

                if (isset($data['childrenIds'])) {
                    if (!is_array($data['childrenIds'])) {
                        throw ValidationException::create('Field "childrenIds" must be an array.');
                    }

                    foreach ($data['childrenIds'] as $id) {
                        $this->getNode($data['id'])->addChild($this->getNode($id));
                    }
                }

                if (isset($data['parentIds'])) {
                    if (!is_array($data['parentIds'])) {
                        throw ValidationException::create('Field "parentIds" must be an array.');
                    }

                    foreach ($data['parentIds'] as $id) {
                        $this->getNode($data['id'])->addParent($this->getNode($id));
                    }
                }
            };

            $func($bkp);
        }

        return $node;
    }
292493
public function create($parentId, array $data)
    {
        $resource = $this->createPartialResourceUrlForList($parentId);
        $data = $this->client->post($resource, [$this->getResourceName() => $data]);

        return $this->fromArray(reset($data));
    }
1018806
protected function normalizeData(array $data, $parentId = null) {
        $result = [];
        foreach ($data as $element) {
            if (ArrayHelper::getValue($element, $this->parentColumnName) === $parentId) {
                $result[] = $element;
                $children = $this->normalizeData($data, ArrayHelper::getValue($element, $this->keyColumnName));
                if ($children) {
                    $result = array_merge($result, $children);
                }
            }
        }
        return $result;
    }
513678
public function automaticCreatedBy($data)
	{
		return (isset($data['created_by']) && $data['created_by'] ? (int)$data['created_by'] : (int)\User::get('id'));
	}
1232709
public function createUser($data)
    {
        $data['type'] = 'user';
        $data['has-children'] = false;
        $principal = $this->principalUpdate($data);

        return (int) $principal->attributes()->{'principal-id'};
    }
196824
public function format($name, array $data) {
        $name = $this->_getTemplateName($name, $data);
        return parent::format($name, $data);
    }
1125190
public static function getTreeChild($data, $parent_id, $key = 'parent_id', $id_key = 'id') {
		$result = [];
		$args   = [$parent_id];
		do {
			$kids = [];
			$flag = false;
			foreach ($args as $fid) {
				for ($i = count($data) - 1; $i >=0 ; $i --) {
					$node = $data[$i];
					if ($node[$key] == $fid) {
						array_splice($data, $i , 1);
						$result[] = $node[$id_key];
						$kids[]   = $node[$id_key];
						$flag     = true;
					}
				}
			}
			$args = $kids;
		} while($flag === true);
		return $result;
	}
397002
public function generate(array $data): string
    {
        /** @var RecordFinder $recordFinder */
        $recordFinder = GeneralUtility::makeInstance(RecordFinder::class);
        return implode(',', $recordFinder->findUidsOfDemoBeUsers());
    }