PHP Class Neomerx\JsonApi\Encoder\Encoder

Inheritance: implements Neomerx\JsonApi\Contracts\Encoder\EncoderInterface
显示文件 Open project: neomerx/json-api Class Usage Examples

Protected Properties

Property Type Description
$container Neomerx\JsonApi\Contracts\Schema\ContainerInterface
$encoderOptions Neomerx\JsonApi\Encoder\EncoderOptions | null
$factory Neomerx\JsonApi\Contracts\Factories\FactoryInterface
$isAddJsonApiVersion boolean
$jsonApiVersionMeta mixed | null
$links array | null Links in array format.
$meta array | object | null

Public Methods

Method Description
__construct ( Neomerx\JsonApi\Contracts\Factories\FactoryInterface $factory, Neomerx\JsonApi\Contracts\Schema\ContainerInterface $container, Neomerx\JsonApi\Encoder\EncoderOptions $encoderOptions = null )
encodeData ( $data, Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface $parameters = null )
encodeError ( Neomerx\JsonApi\Contracts\Document\ErrorInterface $error )
encodeErrors ( $errors )
encodeIdentifiers ( $data, Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface $parameters = null )
encodeMeta ( $meta )
instance ( array $schemas = [], Neomerx\JsonApi\Encoder\EncoderOptions $encodeOptions = null ) : Neomerx\JsonApi\Contracts\Encoder\EncoderInterface Create encoder instance.
withJsonApiVersion ( $meta = null )
withLinks ( array $links )
withMeta ( $meta )
withRelationshipRelatedLink ( $resource, $relationshipName, $meta = null, $treatAsHref = false )
withRelationshipSelfLink ( $resource, $relationshipName, $meta = null, $treatAsHref = false )

Protected Methods

Method Description
checkInputData ( mixed $data )
encodeDataInternal ( Neomerx\JsonApi\Contracts\Schema\ContainerInterface $container, object | array | Iterato\Iterator | null $data, Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface $parameters = null ) : string
encodeToJson ( array $document ) : string Encode array to JSON.
getFactory ( ) : Neomerx\JsonApi\Contracts\Factories\FactoryInterface

Private Methods

Method Description
configureUrlPrefix ( Neomerx\JsonApi\Contracts\Document\DocumentInterface $docWriter )
createParametersAnalyzer ( Neomerx\JsonApi\Contracts\Schema\ContainerInterface $container, Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface $parameters = null ) : Neomerx\JsonApi\Contracts\Encoder\Parameters\ParametersAnalyzerInterface
resetEncodeParameters ( ) Reset encode parameters.

Method Details

__construct() public method

public __construct ( Neomerx\JsonApi\Contracts\Factories\FactoryInterface $factory, Neomerx\JsonApi\Contracts\Schema\ContainerInterface $container, Neomerx\JsonApi\Encoder\EncoderOptions $encoderOptions = null )
$factory Neomerx\JsonApi\Contracts\Factories\FactoryInterface
$container Neomerx\JsonApi\Contracts\Schema\ContainerInterface
$encoderOptions Neomerx\JsonApi\Encoder\EncoderOptions

checkInputData() protected method

protected checkInputData ( mixed $data )
$data mixed

encodeData() public method

public encodeData ( $data, Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface $parameters = null )
$parameters Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface

encodeDataInternal() protected method

protected encodeDataInternal ( Neomerx\JsonApi\Contracts\Schema\ContainerInterface $container, object | array | Iterato\Iterator | null $data, Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface $parameters = null ) : string
$container Neomerx\JsonApi\Contracts\Schema\ContainerInterface
$data object | array | Iterato\Iterator | null
$parameters Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface
return string

encodeError() public method

public encodeError ( Neomerx\JsonApi\Contracts\Document\ErrorInterface $error )
$error Neomerx\JsonApi\Contracts\Document\ErrorInterface

encodeErrors() public method

public encodeErrors ( $errors )

encodeIdentifiers() public method

public encodeIdentifiers ( $data, Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface $parameters = null )
$parameters Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface

encodeMeta() public method

public encodeMeta ( $meta )

encodeToJson() protected method

Encode array to JSON.
protected encodeToJson ( array $document ) : string
$document array
return string

getFactory() protected static method

protected static getFactory ( ) : Neomerx\JsonApi\Contracts\Factories\FactoryInterface
return Neomerx\JsonApi\Contracts\Factories\FactoryInterface

instance() public static method

Create encoder instance.
public static instance ( array $schemas = [], Neomerx\JsonApi\Encoder\EncoderOptions $encodeOptions = null ) : Neomerx\JsonApi\Contracts\Encoder\EncoderInterface
$schemas array Schema providers.
$encodeOptions Neomerx\JsonApi\Encoder\EncoderOptions
return Neomerx\JsonApi\Contracts\Encoder\EncoderInterface

withJsonApiVersion() public method

public withJsonApiVersion ( $meta = null )

withMeta() public method

public withMeta ( $meta )

Property Details

$container protected_oe property

protected ContainerInterface,Neomerx\JsonApi\Contracts\Schema $container
return Neomerx\JsonApi\Contracts\Schema\ContainerInterface

$encoderOptions protected_oe property

protected EncoderOptions,Neomerx\JsonApi\Encoder|null $encoderOptions
return Neomerx\JsonApi\Encoder\EncoderOptions | null

$factory protected_oe property

protected FactoryInterface,Neomerx\JsonApi\Contracts\Factories $factory
return Neomerx\JsonApi\Contracts\Factories\FactoryInterface

$isAddJsonApiVersion protected_oe property

protected bool $isAddJsonApiVersion
return boolean

$jsonApiVersionMeta protected_oe property

protected mixed|null $jsonApiVersionMeta
return mixed | null

$meta protected_oe property

protected array|object|null $meta
return array | object | null