Hal\Resource::setData PHP Method

setData() public method

public setData ( $rel, null $data = null ) : Resource
$rel
$data null
return Resource
    public function setData($rel, $data = null)
    {
        if (is_array($rel) && null === $data) {
            foreach ($rel as $k => $v) {
                $this->_data[$k] = $v;
            }
        } else {
            $this->_data[$rel] = $data;
        }
        return $this;
    }

Usage Example

Example #1
0
 /**
  * Populates the given resource with the values in the form; overwriting any existing items.
  *
  * @param \Hal\Resource $resource
  * @param FormInterface $form
  *
  * @return void
  */
 public function populateResourceWithForm(Resource $resource, FormInterface $form)
 {
     $formData = $form->getData();
     $resource->setData(array('username' => $formData['username'], 'email' => $formData['email']));
 }
All Usage Examples Of Hal\Resource::setData