4 use Doctrine\ORM\Mapping as ORM;
9 * Authenticated sessions.
11 * @ORM\HasLifecycleCallbacks
12 * @ORM\Table(name="profile_session")
18 * Can archive records.
20 const ARCHIVE = false;
22 * Pull Synchronization Strategy for this table.
24 const PULL_SYNCH_STRATEGY = false;
26 * Push Synchronization Strategy for this table.
28 const PUSH_SYNCH_STRATEGY = false;
32 * @ORM\Column(type="integer");
33 * @ORM\GeneratedValue(strategy="AUTO")
38 * @ORM\ManyToOne(targetEntity="Profile", inversedBy="sessions")
39 * @ORM\JoinColumn(nullable=false, name="profile_id", referencedColumnName="id")
44 * @ORM\Column(type="string", length=50, nullable=true, name="auth_token")
49 * @ORM\Column(type="string", length=50, nullable=true, name="pub_id")
54 * @ORM\Column(type="datetime");
60 * Magic getter to expose protected properties.
62 * @param string $property
65 public function __get($property)
67 return $this->$property;
71 * Magic setter to save protected properties.
73 * @param string $property
76 public function __set($property, $value)
78 $this->$property = $value;
84 public function setCreateTime()
86 $this->created = new \DateTime("now");
90 * Convert the object to an array.
91 * @param array $expand
92 * @param array $intersect
95 public function toArray(array $expand = array(), array $intersect = array())
97 $includeAll = empty($intersect);
99 ($includeAll || isset($intersect['id']))
100 && $data['id'] = $this->id;
101 ($includeAll || isset($intersect['profile']))
102 && in_array('profile', $expand)
103 && $data['profile'] = $this->profile->toArray($expand, $intersect);
104 ($includeAll || isset($intersect['authToken']))
105 && $data['authToken'] = $this->authToken;
106 ($includeAll || isset($intersect['pubId']))
107 && $data['pubId'] = $this->pubId;
108 ($includeAll || isset($intersect['created']))
109 && $data['created'] = !is_null($this->created)
110 ? $this->created->format(\Utility\Registry::getConfigParam('DateTimeFormat'))
116 * Populate from an array.
119 public function fromArray($data = array())
122 && $this->id = $data['id'];
123 isset($data['profile'])
124 && $this->profile = $data['profile'];
125 isset($data['authToken'])
126 && $this->authToken = $data['authToken'];
127 isset($data['pubId'])
128 && $this->pubId = $data['pubId'];