Serializes a ResourceType entity for the JSON api.

@param ResourceType $resourceType - the resource type to serialize

@return array - the serialized representation of the resource type
772481
public function serialize(ResourceType $resourceType)
    {
        return [
            'id' => $resourceType->getId(),
            'name' => $resourceType->getName(),
            'class' => $resourceType->getClass(),
            'tags' => $resourceType->getTags(),
            'enabled' => $resourceType->isEnabled(),
            'actions' => array_map(function (MenuAction $resourceAction) {
                return [
                    'name' => $resourceAction->getName(),
                    'group' => $resourceAction->getGroup(),
                    'scope' => $resourceAction->getScope(),
                    'permission' => $resourceAction->getDecoder(),
                    'default' => $resourceAction->isDefault(),
                ];
            }, $this->actionManager->all($resourceType)),
        ];
    }
715674
public function getResourceTypeNames()
    {
        if (!isset($GLOBALS['config']['ResourceType']) || !is_array($GLOBALS['config']['ResourceType'])) {
            return array();
        }

        $_names = array();
        foreach ($GLOBALS['config']['ResourceType'] as $key => $_resourceType) {
            if (isset($_resourceType['name'])) {
                $_names[] = (string)$_resourceType['name'];
            }
        }

        return $_names;
    }
175067
protected function parseFields(Resource $resource)
    {
        $fields = $resource->getFields();
        if (!is_array($fields)) {
            $this->sendError(static::ERROR_UNKNOWN_FIELDS, $fields);
        }
        return $fields;
    }
592735
public function request($resourceUrl, array $params = array())
    {
        $params = array('url' => $resourceUrl) + $params;

        $url = $this->setUrlParams($this->endpoint, $params);

        $data = $this->fetchUrl($url);

        if (self::TYPE_JSON === $this->type) {
            return $this->createResponseFromJson($data);
        } else if (self::TYPE_XML === $this->type) {
            return $this->createResponseFromXml($data);
        }
    }
101549
private function serializePoster(ResourceNode $resourceNode)
    {
        if (!empty($resourceNode->getPoster())) {
            /** @var PublicFile $file */
            $file = $this->om
                ->getRepository(PublicFile::class)
                ->findOneBy(['url' => $resourceNode->getPoster()]);

            if ($file) {
                return $this->fileSerializer->serialize($file);
            }
        }

        return null;
    }
1172425
public function index($contentType)
    {
        $pets = PetFactory::instance()->getAll();

        $transformer = new ResourceTransformer();
        $context = $this->getContext(Action::INDEX);

        $resources = $transformer->toResources(PetDefinition::class, $pets, $context);
        $this->outputResources($resources, $contentType);
    }
320371
public function getIncludedFields(string $resourceType): array
    {
        if ($this->includedFields === null) {
            $this->includedFields = $this->setIncludedFields();
        }

        return isset($this->includedFields[$resourceType]) ? array_keys($this->includedFields[$resourceType]) : [];
    }
266531
public function jsonSerialize($fullResource=true) {
        $data = [];

        if ($this->resourceType) {
            $data['type'] = $this->resourceType;
        }

        if ($this->id) {
            $data['id'] = $this->id;
        }

        if ($this->meta) {
            $data["meta"] = $this->meta;
        }

        if (!$fullResource) return $data;

        if (count($this->attributes) > 0) {
            foreach($this->attributes as $name => $v) $data['attributes'][$name] = $this->serializeAttribute($name);
        }
        if (count($this->relationships) > 0) {
            $data['relationships'] = [];
            foreach($this->relationships as $r) {
                $data['relationships'][$r->getName()] = $r;
            }
        }
        return $data;
    }
893755
public static function toJson($resource) {
		if (self::isJson($resource)) {
			return $resource;
		}

		if ($xml = self::isXml($resource)) {
			$resource = self::xmlToArray($xml);

		} else if ($ser = self::isSerialized($resource)) {
			$resource = $ser;
		}

		return json_encode($resource);
	}
567463
public function serialize(ResourceEvaluation $resourceEvaluation)
    {
        $serialized = [
            'id' => $resourceEvaluation->getId(),
            'date' => $resourceEvaluation->getDate() ? $resourceEvaluation->getDate()->format('Y-m-d H:i') : null,
            'status' => $resourceEvaluation->getStatus(),
            'duration' => $resourceEvaluation->getDuration(),
            'score' => $resourceEvaluation->getScore(),
            'scoreMin' => $resourceEvaluation->getScoreMin(),
            'scoreMax' => $resourceEvaluation->getScoreMax(),
            'customScore' => $resourceEvaluation->getCustomScore(),
            'progression' => $resourceEvaluation->getProgression(),
            'comment' => $resourceEvaluation->getComment(),
            'data' => $resourceEvaluation->getData(),
            'resourceUserEvaluation' => $this->resourceUserEvaluationSerializer->serialize($resourceEvaluation->getResourceUserEvaluation()),
        ];

        return $serialized;
    }
580939
public function serialize(TemplateType $templateType)
    {
        $serialized = [
            'id' => $templateType->getUuid(),
            'name' => $templateType->getName(),
            'placeholders' => $templateType->getPlaceholders(),
            'defaultTemplate' => $templateType->getDefaultTemplate(),
        ];

        return $serialized;
    }
423146
private function getPropertySerializerGroups(string $resourceClass, string $property): array
    {
        $serializerClassMetadata = $this->serializerClassMetadataFactory->getMetadataFor($resourceClass);

        foreach ($serializerClassMetadata->getAttributesMetadata() as $serializerAttributeMetadata) {
            if ($property === $serializerAttributeMetadata->getName()) {
                return $serializerAttributeMetadata->getGroups();
            }
        }

        return [];
    }
650868
private static function loadSerializationType($type)
    {
        $types = array(
            'default' => \Redis::SERIALIZER_NONE,
            'none' => \Redis::SERIALIZER_NONE,
            'php' => \Redis::SERIALIZER_PHP
        );

        if (defined('Redis::SERIALIZER_IGBINARY')) {
            $types['igbinary'] = \Redis::SERIALIZER_IGBINARY;
        }

        if (array_key_exists($type, $types)) {
            return $types[$type];
        }

        throw new InvalidConfigurationException(sprintf('%s in not a valid serializer. Valid serializers: %s', $type, implode(', ', array_keys($types))));
    }
236554
protected function serializeType($urlAliasType)
    {
        switch ($urlAliasType) {
            case Values\Content\URLAlias::LOCATION:
                return 'LOCATION';

            case Values\Content\URLAlias::RESOURCE:
                return 'RESOURCE';

            case Values\Content\URLAlias::VIRTUAL:
                return 'VIRTUAL';
        }

        throw new \RuntimeException("Unknown URL alias type: '{$urlAliasType}'.");
    }
199979
public function getResourceSet(
        QueryType $queryType,
        ResourceSet $resourceSet,
        $filterInfo = null,
        $orderBy = null,
        $top = null,
        $skip = null
    ) {
        $result = new QueryResult();

        $entityClassName = $resourceSet->getResourceType()->getInstanceType()->name;
        $entityName = $this->getEntityName($entityClassName);
        $tableName = $this->getTableName($entityName);

        $option = null;
        if ($queryType == QueryType::ENTITIES_WITH_COUNT()){
            //tell mysql we want to know the count prior to the LIMIT 
            //$option = 'SQL_CALC_FOUND_ROWS';
        }

        $where = $filterInfo ? ' WHERE ' . $filterInfo->getExpressionAsString() : '';

        $order = $orderBy ? ' ORDER BY ' . $this->getOrderByExpressionAsString($orderBy) : '';

        $sqlCount = 'SELECT COUNT(*) FROM ' . $tableName . $where;
        if ($queryType == QueryType::ENTITIES() || $queryType == QueryType::ENTITIES_WITH_COUNT()) {
            $sql = 'SELECT ' . $option . ' * FROM ' . $tableName . $where . $order
                    . ($top ? ' LIMIT ' . $top : '') . ($skip ? ' OFFSET ' . $skip : '');
            $data = $this->queryAll($sql);
            
            if ($queryType == QueryType::ENTITIES_WITH_COUNT()){
                //get those found rows
                //$result->count = $this->queryScalar('SELECT FOUND_ROWS()');
                $result->count = $this->queryScalar($sqlCount);
            }

            $result->results = array_map($entityClassName . '::fromRecord', $data);
        }
        elseif ($queryType == QueryType::COUNT()) {
            $result->count = QueryResult::adjustCountForPaging(
                $this->queryScalar($sqlCount), $top, $skip);
        }

        return $result;
    }
1196608
private function getResourceSerializerGroups(string $resourceClass): array
    {
        $serializerClassMetadata = $this->serializerClassMetadataFactory->getMetadataFor($resourceClass);

        $groups = [];
        foreach ($serializerClassMetadata->getAttributesMetadata() as $serializerAttributeMetadata) {
            $groups += array_flip($serializerAttributeMetadata->getGroups());
        }

        return array_keys($groups);
    }
787912
private static function eventName($actionName, ResourceType $resourceType = null): string
    {
        if (!empty($resourceType)) {
            // This is an action only available for the current type
            return 'resource.'.$resourceType->getName().'.'.$actionName;
        }

        // This is an action available for all resource types
        return 'resource.'.$actionName;
    }