public function create($resource)
    {
        $className = $this->getResourceClassName($resource->type);
        if (!class_exists($className)) {
            throw new Exception(
                'Unknown resource type "' . $resource->type . '".',
                Exception::UNKNOWN_RESOURCE_TYPE
            );
        }

        /** @var AbstractResource $object */
        $object = $this->objectManager->get($className);

        foreach ($resource as $property => $value) {
            if (!ObjectAccess::isPropertySettable($object, $property)) {
                continue;
            }
            ObjectAccess::setProperty($object, $property, $value);
        }

        $this->postProcessResources($object);

        return $object;
    }
public function create($resource)
    {
        $className = $this->getResourceClassName($resource->type);
        if (!class_exists($className)) {
            throw new Exception(
                'Unknown resource type "' . $resource->type . '".',
                Exception::UNKNOWN_RESOURCE_TYPE
            );
        }

        /** @var AbstractResource $object */
        $object = $this->objectManager->get($className);

        foreach ($resource as $property => $value) {
            if (!ObjectAccess::isPropertySettable($object, $property)) {
                continue;
            }
            ObjectAccess::setProperty($object, $property, $value);
        }

        $this->postProcessResources($object);

        return $object;
    }
public function create ( $ resource ) { $ className = $ this -> getResourceClassName ( $ resource -> type ) ; if ( ! class_exists ( $ className ) ) { throw new Exception ( 'Unknown resource type "' . $ resource -> type . '".' , Exception :: UNKNOWN_RESOURCE_TYPE ) ; } /** @var AbstractResource $object */ $ object = $ this -> objectManager -> get ( $ className ) ; foreach ( $ resource as $ property => $ value ) { if ( ! ObjectAccess :: isPropertySettable ( $ object , $ property ) ) { continue ; } ObjectAccess :: setProperty ( $ object , $ property , $ value ) ; } $ this -> postProcessResources ( $ object ) ; return $ object ; }
Create a Resource object from the supplied resource.

@param \stdClass $resource The resource to create an Resource from.
@return AbstractResource
@throws Exception
Create a Resource object from the supplied resource .