main/core/API/Serializer/User/OrganizationSerializer.php
public function serialize(Organization $organization, array $options = [])
    {
        $data = [
            'id' => $organization->getUuid(),
            'name' => $organization->getName(),
            'code' => $organization->getCode(),
            'email' => $organization->getEmail(),
            'type' => $organization->getType(),
            'parent' => !empty($organization->getParent()) ? [
                'id' => $organization->getParent()->getUuid(),
                'name' => $organization->getParent()->getName(),
            ] : null,
            'meta' => [
                'default' => $organization->getDefault(),
                'position' => $organization->getPosition(),
            ],
            'managers' => array_map(function (User $administrator) {
                return [
                    'id' => $administrator->getId(),
                    'username' => $administrator->getUsername(),
                ];
            }, $organization->getAdministrators()->toArray()),
            'locations' => array_map(function (Location $location) {
                return [
                    'id' => $location->getId(),
                    'name' => $location->getName(),
                ];
            }, $organization->getLocations()->toArray()),
        ];

        if (in_array(Options::IS_RECURSIVE, $options)) {
            $data['children'] = array_map(function (Organization $child) use ($options) {
                return $this->serialize($child, $options);
            }, $organization->getChildren()->toArray());
        }

        return $data;
    }
public function serialize(Organization $organization, array $options = [])
    {
        $data = [
            'id' => $organization->getUuid(),
            'name' => $organization->getName(),
            'code' => $organization->getCode(),
            'email' => $organization->getEmail(),
            'type' => $organization->getType(),
            'parent' => !empty($organization->getParent()) ? [
                'id' => $organization->getParent()->getUuid(),
                'name' => $organization->getParent()->getName(),
            ] : null,
            'meta' => [
                'default' => $organization->getDefault(),
                'position' => $organization->getPosition(),
            ],
            'managers' => array_map(function (User $administrator) {
                return [
                    'id' => $administrator->getId(),
                    'username' => $administrator->getUsername(),
                ];
            }, $organization->getAdministrators()->toArray()),
            'locations' => array_map(function (Location $location) {
                return [
                    'id' => $location->getId(),
                    'name' => $location->getName(),
                ];
            }, $organization->getLocations()->toArray()),
        ];

        if (in_array(Options::IS_RECURSIVE, $options)) {
            $data['children'] = array_map(function (Organization $child) use ($options) {
                return $this->serialize($child, $options);
            }, $organization->getChildren()->toArray());
        }

        return $data;
    }
public function serialize ( Organization $ organization , array $ options = [ ] ) { $ data = [ 'id' => $ organization -> getUuid ( ) , 'name' => $ organization -> getName ( ) , 'code' => $ organization -> getCode ( ) , 'email' => $ organization -> getEmail ( ) , 'type' => $ organization -> getType ( ) , 'parent' => ! empty ( $ organization -> getParent ( ) ) ? [ 'id' => $ organization -> getParent ( ) -> getUuid ( ) , 'name' => $ organization -> getParent ( ) -> getName ( ) , ] : null , 'meta' => [ 'default' => $ organization -> getDefault ( ) , 'position' => $ organization -> getPosition ( ) , ] , 'managers' => array_map ( function ( User $ administrator ) { return [ 'id' => $ administrator -> getId ( ) , 'username' => $ administrator -> getUsername ( ) , ] ; } , $ organization -> getAdministrators ( ) -> toArray ( ) ) , 'locations' => array_map ( function ( Location $ location ) { return [ 'id' => $ location -> getId ( ) , 'name' => $ location -> getName ( ) , ] ; } , $ organization -> getLocations ( ) -> toArray ( ) ) , ] ; if ( in_array ( Options :: IS_RECURSIVE , $ options ) ) { $ data [ 'children' ] = array_map ( function ( Organization $ child ) use ( $ options ) { return $ this -> serialize ( $ child , $ options ) ; } , $ organization -> getChildren ( ) -> toArray ( ) ) ; } return $ data ; }
Serializes an Organization entity for the JSON api.

@param Organization $organization - the organization to serialize
@param array        $options

@return array - the serialized representation of the workspace
Serializes an Organization entity for the JSON api .