src/Entity/EntityFactory.php
public function create(
        EntityFactoryConfig $config,
        ServerRequestInterface $request,
        ResponseInterface $response,
        callable $next
    ): ResponseInterface {
        $entityRequest = $config->createEntityRequest($request, $this->container);

        # make a new empty record
        $obj = $entityRequest->instantiateActiveRecord();

        # Execute beforeCreate hook, which can alter record
        $entityRequest->beforeCreate($obj, $request);

        # Then, alter object with allowed properties
        if ($config->isHydrateEntityFromRequest()) {
            $requestParams = $request->getQueryParams();
            $postParams    = $request->getParsedBody();
            if ($postParams) {
                $requestParams = array_merge($requestParams, (array)$postParams);
            }

            /** @noinspection PhpUndefinedMethodInspection */
            $obj->fromArray($entityRequest->getAllowedDataFromRequest($requestParams, $request->getMethod()));
        }

        # Execute afterCreate hook, which can alter record
        $entityRequest->afterCreate($obj, $request);

        $request = $request->withAttribute($config->getParameterToInjectInto(), $obj);
        /** @var Response $response */
        return $next($request, $response);
    }
public function create(
        EntityFactoryConfig $config,
        ServerRequestInterface $request,
        ResponseInterface $response,
        callable $next
    ): ResponseInterface {
        $entityRequest = $config->createEntityRequest($request, $this->container);

        # make a new empty record
        $obj = $entityRequest->instantiateActiveRecord();

        # Execute beforeCreate hook, which can alter record
        $entityRequest->beforeCreate($obj, $request);

        # Then, alter object with allowed properties
        if ($config->isHydrateEntityFromRequest()) {
            $requestParams = $request->getQueryParams();
            $postParams    = $request->getParsedBody();
            if ($postParams) {
                $requestParams = array_merge($requestParams, (array)$postParams);
            }

            /** @noinspection PhpUndefinedMethodInspection */
            $obj->fromArray($entityRequest->getAllowedDataFromRequest($requestParams, $request->getMethod()));
        }

        # Execute afterCreate hook, which can alter record
        $entityRequest->afterCreate($obj, $request);

        $request = $request->withAttribute($config->getParameterToInjectInto(), $obj);
        /** @var Response $response */
        return $next($request, $response);
    }
public function create ( EntityFactoryConfig $ config , ServerRequestInterface $ request , ResponseInterface $ response , callable $ next ) : ResponseInterface { $ entityRequest = $ config -> createEntityRequest ( $ request , $ this -> container ) ; # make a new empty record $ obj = $ entityRequest -> instantiateActiveRecord ( ) ; # Execute beforeCreate hook, which can alter record $ entityRequest -> beforeCreate ( $ obj , $ request ) ; # Then, alter object with allowed properties if ( $ config -> isHydrateEntityFromRequest ( ) ) { $ requestParams = $ request -> getQueryParams ( ) ; $ postParams = $ request -> getParsedBody ( ) ; if ( $ postParams ) { $ requestParams = array_merge ( $ requestParams , ( array ) $ postParams ) ; } /** @noinspection PhpUndefinedMethodInspection */ $ obj -> fromArray ( $ entityRequest -> getAllowedDataFromRequest ( $ requestParams , $ request -> getMethod ( ) ) ) ; } # Execute afterCreate hook, which can alter record $ entityRequest -> afterCreate ( $ obj , $ request ) ; $ request = $ request -> withAttribute ( $ config -> getParameterToInjectInto ( ) , $ obj ) ; /** @var Response $response */ return $ next ( $ request , $ response ) ; }
Create a new instance of activeRecord and add it to Request attributes

@param EntityFactoryConfig    $config
@param ServerRequestInterface $request
@param ResponseInterface      $response
@param callable               $next

@return ResponseInterface
Create a new instance of activeRecord and add it to Request attributes