/**
  * Get resource attributes.
  *
  * @param \Cake\ORM\Entity $resource Entity resource
  * @return array
  */
 public function getAttributes($resource)
 {
     if ($resource->has($this->idField)) {
         $hidden = array_merge($resource->hiddenProperties(), [$this->idField]);
         $resource->hiddenProperties($hidden);
     }
     return $resource->toArray();
 }
Beispiel #2
0
 /**
  * Test that toArray respects hidden properties.
  *
  * @return void
  */
 public function testToArrayHiddenProperties()
 {
     $data = ['secret' => 'sauce', 'name' => 'mark', 'id' => 1];
     $entity = new Entity($data);
     $entity->hiddenProperties(['secret']);
     $this->assertEquals(['name' => 'mark', 'id' => 1], $entity->toArray());
 }