Extract property that should be used for displaying the entities as text in the HTML element
@param object $object
@throws \Exception
502795
protected function extractLabel($object)
    {
        if ($this->property) {
            if ($this->property instanceof \Closure) {
                return $this->property->__invoke($object);
            } else {
                return $this->accessor->getValue($object, $this->property);
            }
        } elseif (method_exists($object, '__toString')) {
            return (string)$object;
        } else {
            throw new \Exception('"choice_label" option or "__toString" method must be defined"');
        }
    }
207618
public function extract($object)
    {
        $data = ['name' => $object->getNormalizedName()];
        if ($object->hasParent()) {
            $data['source'] = strval($object->getParent()->getNormalizedName());
        }
        return $data;
    }
803690
public function extract($object)
    {
        if (!$object instanceof TicketEntry) {
            throw new \InvalidArgumentException('$object must be an instance of TicketEntry');
        }
        /* @var $object TicketEntry */
        $data = parent::extract($object);

        return $data;
    }
204474
public function extract($object)
    {
        if (!$object instanceof TicketSubject) {
            throw new \InvalidArgumentException('$object must be an instance of TicketSubject');
        }
        /* @var $object TicketSubject */
        $data = parent::extract($object);

        return $data;
    }
646212
public function getValue($object = null)
    {
        if (!is_object($object)) {
            throw new Exception('$object is of type ' . gettype($object) . ', instance of class ' . $this->class . ' expected.', 1210859212);
        }
        if ($this->isPublic()) {
            return parent::getValue($object);
        }

        parent::setAccessible(true);
        return parent::getValue($object);
    }
71518
protected function parse($object)
    {
        if (! is_object($object)) {
            throw new ValidationException('Link has to be an object or string, "' . gettype($object) . '" given.');
        }

        if (! array_key_exists('href', $object)) {
            throw new ValidationException('Link must have a "href" attribute.');
        }

        foreach (get_object_vars($object) as $name => $value) {
            $this->setAsLink($name, $value);
        }
    }
1107428
protected function extractObjectProperties($object): array
    {
        $properties = [];

        $reflection = new \ReflectionObject($object);

        // obtain public, protected and private properties of the class itself:

        foreach ($reflection->getProperties() as $property) {
            if ($property->isStatic()) {
                continue; // omit static properties
            }

            $property->setAccessible(true);

            $properties["\${$property->name}"] = $property->getValue($object);
        }

        // obtain any inherited private properties from parent classes:

        while ($reflection = $reflection->getParentClass()) {
            foreach ($reflection->getProperties(\ReflectionProperty::IS_PRIVATE) as $property) {
                $property->setAccessible(true);

                $properties["{$reflection->name}::\${$property->name}"] = $property->getValue($object);
            }
        }

        return $properties;
    }
750565
public function extract($object)
    {
        $data = [
            'group_class_id' => $object->getClass()->getId(),
            'name' => $object->getName(),
            'parent_id' => $object->hasParent() ? $object->getParent()->getId() : null,
        ];
        if ($object->getId()) {
            $data['id'] = $object->getId();
        }
        return $data;
    }
1193073
protected function parse($object)
    {
        if (! is_object($object)) {
            throw new ValidationException('Attributes has to be an object, "' . gettype($object) . '" given.');
        }

        if (property_exists($object, 'type') or property_exists($object, 'id') or property_exists($object, 'relationships') or property_exists($object, 'links')) {
            throw new ValidationException('These properties are not allowed in attributes: `type`, `id`, `relationships`, `links`');
        }

        $object_vars = get_object_vars($object);

        if (count($object_vars) === 0) {
            return $this;
        }

        foreach ($object_vars as $name => $value) {
            $this->set($name, $value);
        }
    }
129541
protected static function readObject($object): string
    {
        if ($object instanceof Closure) {
            return 'Function';
        }

        if ($object instanceof DateTime) {
            return sprintf('DateTime(%s)', $object->format('Y-m-d\TH:i:sP'));
        }

        if (method_exists($object, 'toString')) {
            return (string) $object->toString();
        }

        if (method_exists($object, '__toString')) {
            return (string) $object;
        }

        return sprintf('Object(%s)', get_class($object));
    }
1110283
public function extract($object)
    {
        $data = parent::extract($object);

        foreach ($this->getFreeValuesKeys() as $key) {
            $data[$key] = $object->get($key);
        }

        return $data;
    }
496920
public function get($object)
    {
        // search for the correct serializer
        if (is_string($object)) {
            if ($meta = $this->om->getClassMetaData($object)) {
                $object = $meta->name;
            }
        }

        foreach ($this->serializers as $serializer) {
            $className = $this->getSerializerHandledClass($serializer);

            if ($object instanceof $className || $object === $className) {
                return $serializer;
            }
        }

        $className = is_object($object) ? get_class($object) : $object;

        throw new \Exception(
            sprintf('No serializer found for class "%s" Maybe you forgot to add the "claroline.serializer" tag to your serializer.', is_string($object) ? $object : get_class($object))
        );
    }
456306
protected function parse($object)
    {
        if (! is_object($object)) {
            throw new ValidationException('Link has to be an object, "' . gettype($object) . '" given.');
        }

        $links = get_object_vars($object);

        if (! array_key_exists('about', $links)) {
            throw new ValidationException('ErrorLink MUST contain these properties: about');
        }

        if (! is_string($links['about']) and ! is_object($links['about'])) {
            throw new ValidationException('Link has to be an object or string, "' . gettype($links['about']) . '" given.');
        }

        if (is_string($links['about'])) {
            $this->set('about', strval($links['about']));
        } else {
            $this->set('about', $this->create('Link', $links['about']));
        }

        unset($links['about']);

        // custom links
        foreach ($links as $name => $value) {
            $this->setLink($name, $value);
        }
    }
243293
private function extractProperties(
        object $object,
        MapInterface $properties
    ): MapInterface {
        $refl = $this->reflection($object);

        return $properties->reduce(
            new Map('string', 'mixed'),
            static function(MapInterface $carry, string $name, Property $property) use ($refl): MapInterface {
                return $carry->put(
                    $name,
                    $property
                        ->type()
                        ->forDatabase(
                            $refl->extract($name)->get($name)
                        )
                );
            }
        );
    }
586293
protected function parse($object)
    {
        if (! is_object($object)) {
            throw new ValidationException('RelationshipLink has to be an object, "' . gettype($object) . '" given.');
        }

        if (! property_exists($object, 'self') and ! property_exists($object, 'related')) {
            throw new ValidationException('RelationshipLink has to be at least a "self" or "related" link');
        }

        $links = get_object_vars($object);

        if (array_key_exists('self', $links)) {
            if (! is_string($links['self'])) {
                throw new ValidationException('property "self" has to be a string, "' . gettype($links['self']) . '" given.');
            }

            $this->set('self', strval($links['self']));

            unset($links['self']);
        }

        if (array_key_exists('related', $links)) {
            if (! is_string($links['related']) and ! is_object($links['related'])) {
                throw new ValidationException('property "related" has to be a string or object, "' . gettype($links['related']) . '" given.');
            }

            $this->setLink('related', $links['related']);

            unset($links['related']);
        }

        // Pagination links
        if ($this->getParent()->has('data') and (
            $this->getParent()->get('data') instanceof ResourceIdentifierCollection or
            $this->getParent()->get('data') instanceof ResourceIdentifierCollectionInterface
        )) {
            if (array_key_exists('first', $links)) {
                $this->setPaginationLink('first', $links['first']);

                unset($links['first']);
            }

            if (array_key_exists('last', $links)) {
                $this->setPaginationLink('last', $links['last']);

                unset($links['last']);
            }

            if (array_key_exists('prev', $links)) {
                $this->setPaginationLink('prev', $links['prev']);

                unset($links['prev']);
            }

            if (array_key_exists('next', $links)) {
                $this->setPaginationLink('next', $links['next']);

                unset($links['next']);
            }
        }

        // custom links
        foreach ($links as $name => $value) {
            $this->setLink($name, $value);
        }
    }
345911
public function extract($object)
    {
        $array = array();
        $methods = get_class_methods(get_class($object));

        foreach ($methods as $method) {
            preg_match('/^(get)(.*?)$/i', $method, $matches);
            if (!isset($matches[2])) {
                continue;
            }
            $key = StringUtil::snake($matches[2]);
            $array[$key] = $object->$method();
        }

        return $array;
    }
242552
public function extract($object)
    {
        if (!$object instanceof SecretQuestion) {
            throw new \Exception('$object must be an instance of SecretQuestion');
        }
        /* @var $object SecretQuestion */
        $data = parent::extract($object);

        return $data;
    }