Generates automatic created by field value

@param   array  $data  The data being saved
@return  int
@since   2.0.0
513678
public function automaticCreatedBy($data)
	{
		return (isset($data['created_by']) && $data['created_by'] ? (int)$data['created_by'] : (int)\User::get('id'));
	}
1103266
public static function createFromArray(array $data)
    {
        $self = new self();

        foreach ($data as $searchResult) {
            $self->addSearchResult(KeySearchResult::createFromArray($searchResult));
        }

        return $self;
    }
184351
public function save(array $data)
    {
        if (!$this->getModel()->isSingle()) {
            $id = $data['id'] ?? $this->id;
            $this->id = $id;
        }

        $columns = $this->data;
        foreach ($columns as $key => $column) {
            if (array_key_exists($key, $data)) {
                $column->setValue($data[$key]);
            } else {
                $column->setValue(null);
            }
        }

        $yaml = Yaml::dump($this->getData(), 5, 4, YAML::DUMP_MULTI_LINE_LITERAL_BLOCK | YAML::DUMP_OBJECT_AS_MAP);

        $fs = new Filesystem();
        $fs->dumpFile($this->getContentFilePath(), $yaml);
    }
1167685
public static function createFromArray(array $data)
    {
        $self = new self();

        if (isset($data['id'])) {
            $self->setId($data['id']);
        }
        if (isset($data['filename'])) {
            $self->setFilename($data['filename']);
        }
        if (isset($data['format'])) {
            $self->setFormat($data['format']);
        }
        if (isset($data['state'])) {
            $self->setState($data['state']);
        }
        if (isset($data['created_at'])) {
            $self->setCreatedAt($data['created_at']);
        }

        return $self;
    }
236862
public function create(array $data)
    {
        try
        {
            if ($this->validator->with($data)->passes())
            {
                $this->groups->create($data);
                return true;
            }
        }
        catch (GroupExistsException $e)
        {
            $this->validator->add('GroupExistsException', $e->getMessage());
        }
        catch (NameRequiredException $e)
        {
            $this->validator->add('NameRequiredException', $e->getMessage());
        }

        return false;
    }
257355
public function create(array &$data = null) {
		$modelClass = $this->getModelClass();

		$model = $modelClass::factory($data);
		$model->setDatagate($this);

		if ($this->hasLocator()) {
			$model->setLocator($this->getLocator());
		}

		if (empty($data)) {
			$model->forceInsert();
		}

		return $model;
	}
130656
protected function _insert(array $data)
    {
        $data = $this->_setData($data);
        $sql = Sql::createSql($this->getAdapter())->insert($this->getTableName());
        $event = new Save([
            'action' => Save::INSERT,
            'data' => $data,
            'abort' => false
        ]);
        $this->getEventManager()->trigger(Save::BEFORE_SAVE, $this, $event);
        if ($event->abort) {
            return false;
        }
        $result = $sql->set($event->data)->execute();

        if ($result > 0) {
            $pmk = $this->getPrimaryKey();
            $this->$pmk = $this->getAdapter()->getLastInsertId();
            $this->getEventManager()->trigger(Save::AFTER_SAVE, $this, $event);
        }
        return $result > 0;
    }
444279
public function createFromData(array $data): AbstractEntity
    {
        /** @var AbstractEntity $result */
        $result = $this->factory->create();
        $result->mapFromArray($data);
        return $result;
    }
479107
public static function createFromArray(array $data)
    {
        $self = new self();

        if (isset($data['id'])) {
            $self->setId($data['id']);
        }
        if (isset($data['username'])) {
            $self->setUsername($data['username']);
        }
        if (isset($data['name'])) {
            $self->setName($data['name']);
        }

        return $self;
    }
456037
public function generate(array $data): string
    {
        // Nothing by default
        $value = '';
        // Set second value selected if there is more than one item
        if (isset($data['fieldConfig']['config']['items'])
            && is_array($data['fieldConfig']['config']['items'])
            && count($data['fieldConfig']['config']['items']) > 1
        ) {
            $values = $data['fieldConfig']['config']['items'];
            array_shift($values);
            $value = array_shift($values);
            $value = $value[1];
        }
        return (string)$value;
    }
1221294
public function automaticOrdering($data)
	{
		if (!isset($data['ordering']))
		{
			$last = self::all()
				->select('ordering')
				->order('ordering', 'desc')
				->row();

			$data['ordering'] = (int)$last->get('ordering') + 1;
		}

		return $data['ordering'];
	}
1036926
public static function arrayColumns(array $data)
    {
        // Count the amount of values from the source input
        $count = count($data);

        if ($count === 0) {
            return false;
        }

        if ($count === 1) {
            return array_keys($data[0]);
        }

        if (isset($data[0])) {
            return array_keys($data[0]);
        } else {
            return false;
        }
    }
304311
protected function create(array $data)
    {
        $user = UserModel::create($data);
        return User::find($user->id);
    }
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);
    }
716120
public function create(array $data): bool
    {
        $this->invokeHook("create");

        if ($this->timestamps) {
            $data[$this->createdColumn] = ["func" => $this->timestampFunction];
        }

        $query = $this->qBuilder->table($this->table)->insert($data);
        if (($status = $this->db->execute($query, $this->qBuilder->getParams())) === false) {
            $this->error = $this->db->lastError();
        }
        $this->qBuilder->reset();

        $this->invokeHook("create", self::HOOK_AFTER);
        return $status;
    }
108174
public function row(array $data): int
    {
        array_push($this->rows, $data);
        $pdoStatement = $this->provideStatement();
        $this->execute($pdoStatement);
        return $this->getLastInsertId();
    }
1284924
public static function create(array $data)
    {
        $static = new static();

        if ($static->timestamps) {
            $data = array_merge($data, [
                'created_at' => date('Y-m-d H:i:s'),
                'updated_at' => date('Y-m-d H:i:s')
            ]);
        }

        if (!array_key_exists($static->primary_key, $data)) {
            if ($static->autoIncrement) {
                $id_value = [$static->primary_key => null];

                $data = array_merge($id_value, $data);
            } else {
                if ($static->primary_key_type == 'string') {
                    $data = array_merge([
                        $static->primary_key => ''
                    ], $data);
                }
            }
        }

        $static->setAttributes($data);

        $r = $static->save();

        if ($r == 1) {
            $static->fireEvent('oncreated');
        }

        return $static;
    }