Serializes a Subject entity.

@param Subject $subject
@param array   $options

@return array
199254
public function serialize(Subject $subject, array $options = [])
    {
        $first = $this->messageRepo->findOneBy([
          'subject' => $subject,
          'first' => true,
        ]);

        return [
          'id' => $subject->getUuid(),
          'forum' => [
            'id' => $subject->getForum()->getUuid(),
          ],
          'tags' => $this->serializeTags($subject),
          'content' => $first ? $first->getContent() : null,
          'title' => $subject->getTitle(),
          'meta' => $this->serializeMeta($subject, $options),
          'restrictions' => $this->serializeRestrictions($subject, $options),
          'poster' => $subject->getPoster() ? $this->fileSerializer->serialize($subject->getPoster()) : null,
        ];
    }
278432
public function serialize($object, array $options = [])
    {
        return $this->mapEntityToObject(
          $this->getSerializableProperties($object),
          $object,
          new \StdClass()
        );
    }
173576
public function setSubject($subject)
	{
		$this->getComposer()->subject = $subject;
		$this->getComposer()->subjectCharset = CHARSET;

		return $this;
	}
144809
public function setSubject($subject)
    {
        if (!$this->setHeaderFieldModel('Subject', $subject)) {
            $this->getHeaders()->addTextHeader('Subject', $subject);
        }

        return $this;
    }
1230741
public function createSubjectLink($subject, $title = null, $options = [])
    {
        if ($title === null) {
            if ($subject instanceof MethodDoc) {
                $title = $subject->name . '()';
            } else {
                $title = $subject->name;
            }
        }
        if (($type = $this->apiContext->getType($subject->definedBy)) === null) {
            return $subject->name;
        } else {
            $link = $this->generateApiUrl($type->name);
            if ($subject instanceof MethodDoc) {
                $link .= '#' . $subject->name . '()';
            } else {
                $link .= '#' . $subject->name;
            }
            $link .= '-detail';

            return $this->generateLink($title, $link, $options);
        }
    }
1216794
public function serialize(Options $options)
    {
        return [
            'id' => $options->getId(),
            'data' => $options->getOptions(),
            'user' => $this->userSerializer->serialize($options->getUser()),
        ];
    }
918425
protected function _fieldSetsParameter($fieldSets, Subject $subject, $options)
    {
        // could be null for e.g. using integration tests
        if ($fieldSets === null) {
             return;
        }

        // format $fieldSets to array acceptable by listener config()
        $fieldSets = array_map(function ($val) {
            return explode(',', $val);
        }, $fieldSets);

        $repository = $subject->query->getRepository();
        $associations = $repository->associations();

        $nodeName = Inflector::tableize($repository->getAlias());
        if (empty($fieldSets[$nodeName])) {
            $selectFields = [];
        } else {
            $selectFields = [$repository->aliasField($repository->getPrimaryKey())];
        }
        $columns = $repository->getSchema()->columns();
        $contains = [];
        foreach ($fieldSets as $include => $fields) {
            if ($include === $nodeName) {
                $aliasFields = array_map(function ($val) use ($repository, $columns) {
                    if (!in_array($val, $columns)) {
                        return null;
                    }

                    return $repository->aliasField($val);
                }, $fields);
                $selectFields = array_merge($selectFields, array_filter($aliasFields));
            }

            $association = $associations->get($include);
            if (!empty($association)) {
                $contains[$association->getAlias()] = [
                    'fields' => $fields,
                ];
            }
        }

        $subject->query->select($selectFields);
        if (!empty($contains)) {
            $subject->query->contain($contains);
        }

        $this->setConfig('fieldSets', $fieldSets);
    }
337320
public function setSubject($subject)
    {
        if ($subject === '') {
            throw new \InvalidArgumentException('$subject must not be empty.', 1331488802);
        }

        if ((strpos($subject, CR) !== false) || (strpos($subject, LF) !== false)) {
            throw new \InvalidArgumentException(
                '$subject must not contain any line breaks or carriage returns.',
                1331488817
            );
        }

        $this->setAsString('subject', $subject);
    }
225219
public function createMessageAction(Subject $subject)
    {
        $form = $this->container->get('form.factory')->create(new MessageType, new Message());
        $form->handleRequest($this->get('request'));


        if ($form->isValid()) {
            $message = $form->getData();
            $this->manager->createMessage($message, $subject);
        }

        return new RedirectResponse(
            $this->generateUrl('claro_forum_messages', array('subject' => $subject->getId()))
        );
    }
905379
public function subject($subject = null)
    {
        if ($subject !== null) {
            $this->_subject = $subject;

            return $this;
        }

        return $this->_subject;
    }
79922
public function barDump($subject, $title = null, array $options = null)
    {
        return $this->dump($subject)->bar($title);
    }
754685
public function convert($subject)
    {
        $fqcn = starts_with('\\', $subject) ? $subject : '\\' . $subject;

        $obj = new \stdClass;

        $obj->fqcn = $fqcn;
        $obj->model = ltrim($fqcn, '\\');
        $obj->basename = class_basename($fqcn);
        $obj->object = str_singular(strtolower($obj->basename));
        $obj->transformer = ucfirst($obj->basename) . 'Transformer';
        $obj->route = 'api.v1.' . str_plural(strtolower($obj->basename)) . '.show';

        return $obj;
    }
739447
public function openSubjectAction(Subject $subject)
    {
        $forum = $subject->getCategory()->getForum();
        $this->checkAccess($forum);
        $this->manager->openSubject($subject);

        return new RedirectResponse(
            $this->generateUrl('claro_forum_subjects', array('category' => $subject->getCategory()->getId()))
        );
    }
1259659
public static function getClassAndField($subject, $optional = false)
    {
        /** @var null|SubjectIdentityInterface $subject */
        list($subject, $field) = static::getSubjectAndField($subject, $optional);

        $class = null !== $subject
            ? $subject->getType()
            : null;

        return [$class, $field];
    }
1173831
public function serialize($user, array $options = [])
    {
        if (isset($options['public']) && $options['public']) {
            // TODO : remove me (only used by BBBPlugin and it's not maintained)
            return $this->serializePublic($user);
        }

        $serializedUser = [
            'autoId' => $user->getId(), //for old compatibility purposes
            'id' => $user->getUuid(),
            'name' => $user->getFirstName().' '.$user->getLastName(),
            'firstName' => $user->getFirstName(),
            'lastName' => $user->getLastName(),
            'username' => $user->getUsername(),
            'picture' => $this->serializePicture($user),
            'email' => $user->getEmail(),
            'administrativeCode' => $user->getAdministrativeCode(),
            'phone' => $user->getPhone(),
            'meta' => $this->serializeMeta($user),
            'publicUrl' => $user->getPublicUrl(), // todo : merge with the one from meta (I do it to have it in minimal)
            'permissions' => $this->serializePermissions($user),
            'restrictions' => $this->serializeRestrictions($user),
        ];

        if (!in_array(Options::SERIALIZE_MINIMAL, $options)) {
            $userRoles = array_map(function (Role $role) { // todo use role serializer with minimal option
                return [
                    'id' => $role->getUuid(),
                    'type' => $role->getType(),
                    'name' => $role->getName(),
                    'translationKey' => $role->getTranslationKey(),
                    'workspace' => $role->getWorkspace() ? ['id' => $role->getWorkspace()->getUuid()] : null,
                    'context' => 'user',
                ];
            }, $user->getEntityRoles(false));
            $groupRoles = array_map(function (Role $role) { // todo use role serializer with minimal option
                return [
                    'id' => $role->getUuid(),
                    'type' => $role->getType(),
                    'name' => $role->getName(),
                    'translationKey' => $role->getTranslationKey(),
                    'workspace' => $role->getWorkspace() ? ['id' => $role->getWorkspace()->getUuid()] : null,
                    'context' => 'group',
                ];
            }, $user->getGroupRoles());

            $serializedUser = array_merge($serializedUser, [
                'meta' => $this->serializeMeta($user),
                'restrictions' => $this->serializeRestrictions($user),
                'roles' => array_merge($userRoles, $groupRoles),
                'groups' => array_map(function (Group $group) { // todo use group serializer with minimal option
                    return [
                        'id' => $group->getUuid(),
                        'name' => $group->getName(),
                    ];
                }, $user->getGroups()->toArray()),
            ]);

            if ($user->getMainOrganization()) {
                $serializedUser['mainOrganization'] = $this->organizationSerializer->serialize($user->getMainOrganization());
            }

            $serializedUser['administratedOrganizations'] = array_map(function ($organization) {
                return $this->organizationSerializer->serialize($organization);
            }, $user->getAdministratedOrganizations()->toArray());
        }

        if (in_array(Options::SERIALIZE_FACET, $options)) {
            $fields = $this->om
                ->getRepository('Claroline\CoreBundle\Entity\Facet\FieldFacetValue')
                ->findPlatformValuesByUser($user);
            $serializedUser['facets'] = [];

            /** @var FieldFacetValue $field */
            foreach ($fields as $field) {
                // we just flatten field facets in the base user structure
                $serializedUser['profile'][$field->getFieldFacet()->getUuid()] = $field->getValue();
            }
        }

        return $this->decorate($user, $serializedUser);
    }
860803
public function subject($subject = null)
    {
        $headers = $this->headers();
        if (!func_num_args()) {
            return $headers['Subject'];
        }
        $headers['Subject'] = Mime::encodeValue($subject, 998, "\r\n ");
        return $this;
    }
46361
public function renderTags($subjectOrTags, array $options = [])
    {
        if (null === $this->tagRenderer) {
            $this->tagRenderer = new TagRenderer();
        }

        return $this->tagRenderer->renderTags($subjectOrTags, $options);
    }