{@inheritdoc}

@return RecordInterface

@throws InstantionException
435288
public function make(array $fields, int $state): RecordInterface
    {
        $class = $this->class;

        //Now we can construct needed class, in this case we are following DocumentEntity declaration
        if ($state == ORMInterface::STATE_LOADED) {
            //No need to filter values, passing directly in constructor
            return new $class($fields, $state, $this->orm);
        }

        if ($state != ORMInterface::STATE_NEW) {
            throw new InstantionException(
                "Undefined state {$state}, only NEW and LOADED are supported"
            );
        }

        /*
         * Filtering entity
         */

        $entity = new $class([], $state, $this->orm);
        if (!$entity instanceof RecordInterface) {
            throw new InstantionException(
                "Unable to set filtered values for '{$class}', must be instance of RecordInterface"
            );
        }

        //Must pass value thought all needed filters
        $entity->setFields($fields);

        return $entity;
    }
245077
public function build(): NavigateToHistoryEntryRequest
	{
		$instance = new NavigateToHistoryEntryRequest();
		if ($this->entryId === null) {
			throw new BuilderException('Property [entryId] is required.');
		}
		$instance->entryId = $this->entryId;
		return $instance;
	}
817858
public function add(RecordInterface $record): self
    {
        $this->assertValid($record);
        $this->loadData(true)->instances[] = $record;

        return $this;
    }
495758
static function getInstance()
    {
        $driver = static::getLibrary();

        try {
            $instance = new $driver();
        } catch (\Exception $e) {
            throw new Exception('Unable to create an instance of ' . $driver);
        }

        if (!self::isInstanceOf($instance, CryptInterface::class)) {
            throw new Exception(Exception::MSG_INVALID_ARG, ['driver', CryptInterface::class]);
        }

        return $instance;
    }
1372902
public function create()
    {
        $record = $this->getNewModelInstance();

        $fields = array_only(
            $this->modelInformation->form->fields,
            $this->getRelevantFormFieldKeys(true)
        );

        $this->checkListParents(false);

        $values = $this->getFormFieldValuesFromModel($record, array_keys($fields));
        $errors = $this->getNormalizedFormFieldErrors();

        $renderedFields = $this->renderedFormFieldStrategies($record, $fields, $values, $errors);

        return view($this->getCreateView(), [
            'moduleKey'           => $this->moduleKey,
            'routePrefix'         => $this->routePrefix,
            'permissionPrefix'    => $this->permissionPrefix,
            'model'               => $this->modelInformation,
            'record'              => $record,
            'recordReference'     => null,
            'creating'            => true,
            'fields'              => $fields,
            'fieldStrategies'     => $renderedFields,
            'values'              => $values,
            'fieldErrors'         => $errors,
            'activeTab'           => $this->getActiveTab(),
            'errorsPerTab'        => $this->getErrorCountsPerTabPane(),
            'hasActiveListParent' => (bool) $this->listParentRelation,
            'topListParentOnly'   => $this->showsTopParentsOnly(),
            'listParents'         => $this->listParents,
        ]);
    }
1276192
public function saveInto(DataObjectInterface $record)
    {
        // Obtain Field Name:
        
        $fieldName = $this->getName();
        
        // Bail Early (if needed):
        
        if (empty($fieldName) || empty($record)) {
            return;
        }
        
        // Obtain Value:
        
        $value = $this->Value();
        
        // Value Not Empty / Does Not Exist?
        
        if (!empty($value) && !in_array($value, $this->getSourceValues())) {
            
            // Create New Object (if enabled):
            
            if ($this->getCanCreate() && $this->dataClass) {
                $object = Injector::inst()->create($this->dataClass, $this->dataDefaults);
                $object->setField($this->getTextField(), $value);
                $this->setValue($object->write());
            }
            
        }
        
        // Call Parent Method:
        
        return parent::saveInto($record);
    }
1175451
public static function getInstance()
    {
        $driver = static::getLibrary();

        try {
            $instance = self::factory($driver, AnnotationsInterface::class);
        } catch (\Exception $e) {
            throw new AnnotationsException($e->getMessage());
        }

        return $instance;
    }
1125149
public function saveInto(DataObjectInterface $record)
    {
        if (!$this->actionToExecuteOnSaveInto) {
            return;
        }

        if ($this->actionToExecuteOnSaveInto instanceof FormAction) {
            $this->actionToExecuteOnSaveInto = $this->actionToExecuteOnSaveInto->actionName();
        }

        $funcName = $this->actionToExecuteOnSaveInto;

        if (!$funcName && $defaultAction = $this->inlineForm->defaultAction()) {
            $funcName = $defaultAction->actionName();
        }

        if ($funcName) {
            $this->inlineForm->setButtonClicked($funcName);
        } else {
            if($this->inlineForm->Record) {
                $record = $this->inlineForm->Record;
            }

            $this->unprependName($this->inlineForm->Fields());
            $this->inlineForm->loadDataFrom($this->value);
            $this->inlineForm->saveInto($record);

            return;
        }

        if (
            // Ensure that the action is actually a button or method on the form,
            // and not just a method on the controller.
            (
                $this->form
                && $this->form->Controller
                && $this->form->Controller->hasMethod($funcName)
                && !$this->form->Controller->checkAccessAction($funcName)
                // If a button exists, allow it on the controller
                && !$this->form->dataFieldByName('action_' . $funcName)
            ) &&
            (
                $this->inlineForm
                && $this->inlineForm->Controller
                && $this->inlineForm->Controller->hasMethod($funcName)
                && !$this->inlineForm->Controller->checkAccessAction($funcName)
                // If a button exists, allow it on the controller
                && !$this->inlineForm->dataFieldByName('action_' . $funcName)
            ) &&
            ($this->form->hasMethod($funcName) && !$this->form->checkAccessAction($funcName)) &&
            ($this->inlineForm->hasMethod($funcName) && !$this->inlineForm->checkAccessAction($funcName))
            // No checks for button existence or $allowed_actions is performed -
            // all form methods are callable (e.g. the legacy "callfieldmethod()")
        ) {
            return;
        }

        $this->unprependName($this->inlineForm->Fields());
        $this->inlineForm->loadDataFrom($this->value);
        $request = \Controller::curr()->Request;

        if ($this->inlineForm->Controller->hasMethod($funcName)) {
            $this->inlineForm->Controller->$funcName($this->inlineForm->Data, $this->inlineForm, $request);
            // Otherwise, try a handler method on the form object.
        } elseif ($this->inlineForm->hasMethod($funcName)) {
            $this->inlineForm->$funcName($this->inlineForm->Data, $this->inlineForm, $request);
        } elseif ($this->form && $this->form->Controller->hasMethod($funcName)) {
            $this->form->Controller->$funcName($this->inlineForm->Data, $this->inlineForm, $request);
        } elseif ($this->form && $this->inlineForm->hasMethod($funcName)) {
            $this->form->$funcName($this->inlineForm->Data, $this->inlineForm, $request);
        } elseif ($field = $this->inlineForm->checkFieldsForAction($this->inlineForm->Fields(), $funcName)) {
            $field->$funcName($this->inlineForm->Data, $this->inlineForm, $request);
        }
    }
672064
public function newInstance()
    {
        $class = $this->entityMap->getClass();

        if ($this->entityMap->useDependencyInjection()) {
            return $this->newInstanceUsingDependencyInjection($class);
        }

        return $this->newInstanceUsingInstantiator($class);
    }
99116
static function instance()
    {
        $accountHandler = null;
        if ( eZExtension::findExtensionType( array( 'ini-name' => 'shopaccount.ini',
                                                    'repository-group' => 'HandlerSettings',
                                                    'repository-variable' => 'Repositories',
                                                    'extension-group' => 'HandlerSettings',
                                                    'extension-variable' => 'ExtensionRepositories',
                                                    'type-group' => 'AccountSettings',
                                                    'type-variable' => 'Handler',
                                                    'alias-group' => 'AccountSettings',
                                                    'alias-variable' => 'Alias',
                                                    'subdir' => 'shopaccounthandlers',
                                                    'type-directory' => false,
                                                    'extension-subdir' => 'shopaccounthandlers',
                                                    'suffix-name' => 'shopaccounthandler.php' ),
                                             $out ) )
        {
            $filePath = $out['found-file-path'];
            include_once( $filePath );
            $class = $out['type'] . 'ShopAccountHandler';
            $accountHandler = new $class( );
        }
        else
        {
            $accountHandler = new eZDefaultShopAccountHandler();
        }
        return $accountHandler;
    }
1292030
public function get(Instantiator $instantiator)
    {
        // Already initialized?
        if (!is_null($this->object)) {
            return $this->object;
        }

        // Already in initialization?
        if ($this->initialization) {
            throw new ContainerException(sprintf('Recursive initialization of service "%s"', $this->class));
        }

        // Create instance of object
        if (is_null($this->factory)) {
            $this->object = $instantiator->newInstanceOf($this->class, $this->getArguments());
        } else {
            $factory = explode('::', $this->factory, 2);
            $object = $instantiator->invokeMethod($factory[0],
                                                  $factory[1],
                                                  array_merge(['service' => $this], $this->getArguments()));

            if (!$object instanceof $this->class) {
                throw new ContainerException(sprintf('Factory "%s" must returns a "%s" class, "%s" returned', $this->factory, $this->class, get_class($object)));
            }

            $this->object = $object;
        }

        // Calls
        foreach ($this->calls ?? [] as $method => $args) {
            $instantiator->invokeMethod($this->object, $method, $args ?? []);
        }

        return $this->object;
    }
155349
public function recordEditForm()
    {
        //clone current request : used to figure out what record we are asking
        $request = clone $this->request;
        $recordInfo = $request->shift();

        //shift request till we find the requested field
        while ($recordInfo) {
            if ($unescapedRecordInfo = $this->unEscapeFieldName($recordInfo)) {
                $id = $unescapedRecordInfo['id'];
                $fieldName = $unescapedRecordInfo['name'];

                $action = $request->shift();
                break;
            } else {
                $recordInfo = $request->shift();
            }
        }

        //generate a form with only that requested record's fields
        if ($id) {
            $modelClass = $this->gridField->getModelClass();
            $record = DataObject::get_by_id($modelClass, $id);

            $cmsFields = $record->getCMSFields();
            $recordEditingFields = $this->getRecordEditingFields($record);

            return Form::create(
                $this->gridField,
                'recordEditForm',
                FieldList::create($recordEditingFields),
                FieldList::create()
            );
        }
    }
614666
private function detectRecord($record)
    {
        foreach ($this->recordTypes as $recordType) {
            $method = new ReflectionMethod($recordType, 'match');
            $arguments = [$record];

            if ($method->invokeArgs(null, $arguments) === false) {
                continue;
            }

            $class = $method->getDeclaringClass();

            return ($class->hasMethod('__construct'))
                ? $class->newInstanceArgs($arguments) : $class->newInstance();
        }

        throw new UnexpectedValueException();
    }
703792
public function instantiate()
    {
        $router = new Wildcard($this->entryPoint);
        $router->setLogger($this->app->getLogger());
        return $router;
    }
989294
static function instance()
    {
        $confirmOrderHandler = null;
        if ( eZExtension::findExtensionType( array( 'ini-name' => 'shopaccount.ini',
                                                    'repository-group' => 'HandlerSettings',
                                                    'repository-variable' => 'Repositories',
                                                    'extension-group' => 'HandlerSettings',
                                                    'extension-variable' => 'ExtensionRepositories',
                                                    'type-group' => 'ConfirmOrderSettings',
                                                    'type-variable' => 'Handler',
                                                    'alias-group' => 'ConfirmOrderSettings',
                                                    'alias-variable' => 'Alias',
                                                    'subdir' => 'confirmorderhandlers',
                                                    'type-directory' => false,
                                                    'extension-subdir' => 'confirmorderhandlers',
                                                    'suffix-name' => 'confirmorderhandler.php' ),
                                             $out ) )
        {
            $filePath = $out['found-file-path'];
            include_once( $filePath );
            $class = $out['type'] . 'ConfirmOrderHandler';
            return new $class();
        }

        return new eZDefaultConfirmOrderHandler();
    }
1143623
protected function createObjectFactory()
    {
        try {
            if (isset($this->parameters[SessionParameter::OBJECT_FACTORY_CLASS])) {
                $objectFactoryClass = new $this->parameters[SessionParameter::OBJECT_FACTORY_CLASS];
            } else {
                $objectFactoryClass = $this->createDefaultObjectFactoryInstance();
            }

            if (!($objectFactoryClass instanceof ObjectFactoryInterface)) {
                throw new \RuntimeException('Class does not implement ObjectFactoryInterface!', 1408354119);
            }

            $objectFactoryClass->initialize($this, $this->parameters);

            return $objectFactoryClass;
        } catch (\Exception $exception) {
            throw new \RuntimeException(
                'Unable to create object factory: ' . $exception,
                1408354120
            );
        }
    }
699786
public function toRecord(string $recordClass): Record
    {
        $record = Record::instanceRecord($recordClass, $this->data);
        $record->setLoaded();
        return $record;
    }