2017 © Pedro Peláez
 

library hal-support

HAL format support

image

unrlab/hal-support

HAL format support

  • Monday, January 29, 2018
  • by jguido
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

hal-support

namespace UnrLab\Domain;, (*1)

use JMS\Serializer\Annotation as JMS;, (*2)

use UnrLab\Model\HalBuilder;, (*3)

use UnrLab\Model\Serializable;, (*4)

class Company implements Serializable {, (*5)

use HalBuilder;, (*6)

/**
 * @var integer
 * @JMS\Type("integer")
 */
public $id;

/**
 * @var string
 * @JMS\Type("string")
 */
public $name;

/**
 * @var string
 * @JMS\Type("string")
 */
public $siren;

/**
 * @var string
 * @JMS\Type("string")
 */
public $address;

/**
 * @var string
 * @JMS\Type("string")
 */
public $zip;

/**
 * @var string
 * @JMS\Type("string")
 */
public $city;

/**
 * @var Country
 * @JMS\Type("UnrLab\Domain\Country")
 */
public $country;

/**
 * @var array
 * @JMS\Exclude
 */
public $users;

/**
 * @var array
 * @JMS\Exclude
 */
public $customers;

/**
 * @var string
 * @JMS\Type("array")
 */
protected $links;

public function __construct() {
    $this->users = array();
    $this->customers = array();
}

public function __toString() {

    return $this->name;
}

/**
 * @JMS\PreSerialize
 */
public function preSerialize()
{
    $userIds     = array();
    $customerIds = array();
    if ($this->users->count() > 0) {
        foreach ($this->users as $user) {
            $userIds[] = $user->getId();
        }
        $this->links['users'] = $this->buildLinks($userIds, '/users/{id}', '{id}');
    }
    if ($this->customers->count() > 0) {
        foreach ($this->customers as $customer) {
            $customerIds[] = $customer->getId();
        }
        $this->links['customers'] = $this->buildLinks($customerIds, '/customers/{id}', '{id}');
    }
}

public function getLinks()
{
    return $this->links;
}

}, (*7)

The Versions

29/01 2018

dev-master

9999999-dev

HAL format support

  Sources   Download

GNU GPL-3.0-or-later

The Requires

  • php >=5.3.3

 

15/02 2016

0.1.0

0.1.0.0

HAL format support

  Sources   Download

GNU

The Requires

  • php >=5.3.3

 

15/02 2016

1.0.0

1.0.0.0

HAL format support

  Sources   Download

GNU

The Requires

  • php >=5.3.3