lib/Weasel/JsonMarshaller/Config/ClassAnnotationDriver.php
public function getConfig()
    {
        $this->config = new ClassMarshaller();
        $this->config->serialization = new Serialization\ClassSerialization();
        $this->config->deserialization = new Deserialization\ClassDeserialization();

        $reader = $this->_getAnnotationReader();

        /**
         * @var \Weasel\JsonMarshaller\Config\Annotations\JsonInclude $includer
         */
        $includer = $reader->getSingleClassAnnotation($this->annNS . 'JsonInclude');
        $this->config->serialization->include = $this->_getIncluderValue($includer);

        /**
         * Work out what the class' "name" is, just in case inheritance is needed.
         * @var \Weasel\JsonMarshaller\Config\Annotations\JsonTypeName $typeNamer
         */
        $typeNamer = $reader->getSingleClassAnnotation($this->annNS . 'JsonTypeName');
        $name = null;
        if (isset($typeNamer)) {
            $name = $typeNamer->getName();
        }
        if (empty($name)) {
            // Default to the unqualified class name
            $name = $this->rClass->getName();
        }
        $this->config->deserialization->name = $name;

        /**
         * @var Annotations\JsonTypeInfo $typeInfo
         * @var Annotations\JsonSubTypes $subTypes
         */
        $typeInfo = $reader->getSingleClassAnnotation($this->annNS . 'JsonTypeInfo');
        $subTypes = $reader->getSingleClassAnnotation($this->annNS . 'JsonSubTypes');
        $this->config->deserialization->typeInfo = $this->_getDeserializationTypeInfo($typeInfo, $subTypes);
        $this->config->serialization->typeInfo = $this->_getSerializationTypeInfo($typeInfo, $subTypes);

        $methods = $this->rClass->getMethods(\ReflectionMethod::IS_PUBLIC);

        foreach ($methods as $method) {
            $this->_configureMethod($method);
        }

        $properties = $this->rClass->getProperties(\ReflectionProperty::IS_PUBLIC & ~\ReflectionProperty::IS_STATIC);
        foreach ($properties as $property) {
            $this->_configureProperty($property);
        }

        /**
         * @var \Weasel\JsonMarshaller\Config\Annotations\JsonIgnoreProperties $ignorer
         */
        $ignorer = $reader->getSingleClassAnnotation($this->annNS . 'JsonIgnoreProperties');
        if (!empty($ignorer)) {
            // The ignorer config affects which properties we will consider.
            $this->config->deserialization->ignoreUnknown = $ignorer->getIgnoreUnknown();
            $this->config->deserialization->ignoreProperties = $ignorer->getNames();
        }


        return $this->config;

    }
public function getConfig()
    {
        $this->config = new ClassMarshaller();
        $this->config->serialization = new Serialization\ClassSerialization();
        $this->config->deserialization = new Deserialization\ClassDeserialization();

        $reader = $this->_getAnnotationReader();

        /**
         * @var \Weasel\JsonMarshaller\Config\Annotations\JsonInclude $includer
         */
        $includer = $reader->getSingleClassAnnotation($this->annNS . 'JsonInclude');
        $this->config->serialization->include = $this->_getIncluderValue($includer);

        /**
         * Work out what the class' "name" is, just in case inheritance is needed.
         * @var \Weasel\JsonMarshaller\Config\Annotations\JsonTypeName $typeNamer
         */
        $typeNamer = $reader->getSingleClassAnnotation($this->annNS . 'JsonTypeName');
        $name = null;
        if (isset($typeNamer)) {
            $name = $typeNamer->getName();
        }
        if (empty($name)) {
            // Default to the unqualified class name
            $name = $this->rClass->getName();
        }
        $this->config->deserialization->name = $name;

        /**
         * @var Annotations\JsonTypeInfo $typeInfo
         * @var Annotations\JsonSubTypes $subTypes
         */
        $typeInfo = $reader->getSingleClassAnnotation($this->annNS . 'JsonTypeInfo');
        $subTypes = $reader->getSingleClassAnnotation($this->annNS . 'JsonSubTypes');
        $this->config->deserialization->typeInfo = $this->_getDeserializationTypeInfo($typeInfo, $subTypes);
        $this->config->serialization->typeInfo = $this->_getSerializationTypeInfo($typeInfo, $subTypes);

        $methods = $this->rClass->getMethods(\ReflectionMethod::IS_PUBLIC);

        foreach ($methods as $method) {
            $this->_configureMethod($method);
        }

        $properties = $this->rClass->getProperties(\ReflectionProperty::IS_PUBLIC & ~\ReflectionProperty::IS_STATIC);
        foreach ($properties as $property) {
            $this->_configureProperty($property);
        }

        /**
         * @var \Weasel\JsonMarshaller\Config\Annotations\JsonIgnoreProperties $ignorer
         */
        $ignorer = $reader->getSingleClassAnnotation($this->annNS . 'JsonIgnoreProperties');
        if (!empty($ignorer)) {
            // The ignorer config affects which properties we will consider.
            $this->config->deserialization->ignoreUnknown = $ignorer->getIgnoreUnknown();
            $this->config->deserialization->ignoreProperties = $ignorer->getNames();
        }


        return $this->config;

    }
public function getConfig ( ) { $ this -> config = new ClassMarshaller ( ) ; $ this -> config -> serialization = new Serialization \ ClassSerialization ( ) ; $ this -> config -> deserialization = new Deserialization \ ClassDeserialization ( ) ; $ reader = $ this -> _getAnnotationReader ( ) ; /**
         * @var \Weasel\JsonMarshaller\Config\Annotations\JsonInclude $includer
         */ $ includer = $ reader -> getSingleClassAnnotation ( $ this -> annNS . 'JsonInclude' ) ; $ this -> config -> serialization -> include = $ this -> _getIncluderValue ( $ includer ) ; /**
         * Work out what the class' "name" is, just in case inheritance is needed.
         * @var \Weasel\JsonMarshaller\Config\Annotations\JsonTypeName $typeNamer
         */ $ typeNamer = $ reader -> getSingleClassAnnotation ( $ this -> annNS . 'JsonTypeName' ) ; $ name = null ; if ( isset ( $ typeNamer ) ) { $ name = $ typeNamer -> getName ( ) ; } if ( empty ( $ name ) ) { // Default to the unqualified class name $ name = $ this -> rClass -> getName ( ) ; } $ this -> config -> deserialization -> name = $ name ; /**
         * @var Annotations\JsonTypeInfo $typeInfo
         * @var Annotations\JsonSubTypes $subTypes
         */ $ typeInfo = $ reader -> getSingleClassAnnotation ( $ this -> annNS . 'JsonTypeInfo' ) ; $ subTypes = $ reader -> getSingleClassAnnotation ( $ this -> annNS . 'JsonSubTypes' ) ; $ this -> config -> deserialization -> typeInfo = $ this -> _getDeserializationTypeInfo ( $ typeInfo , $ subTypes ) ; $ this -> config -> serialization -> typeInfo = $ this -> _getSerializationTypeInfo ( $ typeInfo , $ subTypes ) ; $ methods = $ this -> rClass -> getMethods ( \ ReflectionMethod :: IS_PUBLIC ) ; foreach ( $ methods as $ method ) { $ this -> _configureMethod ( $ method ) ; } $ properties = $ this -> rClass -> getProperties ( \ ReflectionProperty :: IS_PUBLIC & ~ \ ReflectionProperty :: IS_STATIC ) ; foreach ( $ properties as $ property ) { $ this -> _configureProperty ( $ property ) ; } /**
         * @var \Weasel\JsonMarshaller\Config\Annotations\JsonIgnoreProperties $ignorer
         */ $ ignorer = $ reader -> getSingleClassAnnotation ( $ this -> annNS . 'JsonIgnoreProperties' ) ; if ( ! empty ( $ ignorer ) ) { // The ignorer config affects which properties we will consider. $ this -> config -> deserialization -> ignoreUnknown = $ ignorer -> getIgnoreUnknown ( ) ; $ this -> config -> deserialization -> ignoreProperties = $ ignorer -> getNames ( ) ; } return $ this -> config ; }
Get the config for the current class.
@return ClassMarshaller A populated ClassMarshaller config object.
Get the config for the current class .