本文整理汇总了PHP中Espo\ORM\Entity::clear方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::clear方法的具体用法?PHP Entity::clear怎么用?PHP Entity::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Espo\ORM\Entity
的用法示例。
在下文中一共展示了Entity::clear方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadUserColumnFields
public function loadUserColumnFields(Entity $entity)
{
$pdo = $this->getEntityManager()->getPDO();
$sql = "\n SELECT is_read AS 'isRead', is_important AS 'isImportant' FROM email_user\n WHERE\n deleted = 0 AND\n user_id = " . $pdo->quote($this->getUser()->id) . " AND\n email_id = " . $pdo->quote($entity->id) . "\n ";
$sth = $pdo->prepare($sql);
$sth->execute();
if ($row = $sth->fetch(\PDO::FETCH_ASSOC)) {
$isRead = !empty($row['isRead']) ? true : false;
$isImportant = !empty($row['isImportant']) ? true : false;
$entity->set('isRead', $isRead);
$entity->set('isImportant', $isImportant);
} else {
$entity->set('isRead', null);
$entity->clear('isImportant');
}
}
示例2: prepareEntityForOutput
public function prepareEntityForOutput(Entity $entity)
{
foreach ($this->internalFields as $field) {
$entity->clear($field);
}
}
示例3: prepareEntityForOutput
public function prepareEntityForOutput(Entity $entity)
{
foreach ($this->internalAttributeList as $field) {
$entity->clear($field);
}
foreach ($this->getAcl()->getScopeForbiddenAttributeList($entity->getEntityType(), 'read') as $attribute) {
$entity->clear($attribute);
}
}
示例4: save
public function save(Entity $entity, array $options = array())
{
$nowString = date('Y-m-d H:i:s', time());
$restoreData = array();
if ($entity->isNew()) {
if (!$entity->has('id')) {
$entity->set('id', Util::generateId());
}
if ($entity->hasField('createdAt')) {
$entity->set('createdAt', $nowString);
}
if ($entity->hasField('modifiedAt')) {
$entity->set('modifiedAt', $nowString);
}
if ($entity->hasField('createdById')) {
$entity->set('createdById', $this->entityManager->getUser()->id);
}
if ($entity->has('modifiedById')) {
$restoreData['modifiedById'] = $entity->get('modifiedById');
}
if ($entity->has('modifiedAt')) {
$restoreData['modifiedAt'] = $entity->get('modifiedAt');
}
$entity->clear('modifiedById');
} else {
if (empty($options['silent'])) {
if ($entity->hasField('modifiedAt')) {
$entity->set('modifiedAt', $nowString);
}
if ($entity->hasField('modifiedById')) {
$entity->set('modifiedById', $this->entityManager->getUser()->id);
}
}
if ($entity->has('createdById')) {
$restoreData['createdById'] = $entity->get('createdById');
}
if ($entity->has('createdAt')) {
$restoreData['createdAt'] = $entity->get('createdAt');
}
$entity->clear('createdById');
$entity->clear('createdAt');
}
$this->restoreData = $restoreData;
$result = parent::save($entity, $options);
return $result;
}
示例5: save
public function save(Entity $entity)
{
$nowString = date('Y-m-d H:i:s', time());
$restoreData = array();
if ($entity->isNew()) {
if (!$entity->has('id')) {
$entity->set('id', uniqid());
}
if ($entity->hasField('createdAt')) {
$entity->set('createdAt', $nowString);
}
if ($entity->hasField('createdById')) {
$entity->set('createdById', $this->entityManager->getUser()->id);
}
if ($entity->has('modifiedById')) {
$restoreData['modifiedById'] = $entity->get('modifiedById');
}
if ($entity->has('modifiedAt')) {
$restoreData['modifiedAt'] = $entity->get('modifiedAt');
}
$entity->clear('modifiedById');
$entity->clear('modifiedAt');
} else {
if ($entity->hasField('modifiedAt')) {
$entity->set('modifiedAt', $nowString);
}
if ($entity->hasField('modifiedById')) {
$entity->set('modifiedById', $this->entityManager->getUser()->id);
}
if ($entity->has('createdById')) {
$restoreData['createdById'] = $entity->get('createdById');
}
if ($entity->has('createdAt')) {
$restoreData['createdAt'] = $entity->get('createdAt');
}
$entity->clear('createdById');
$entity->clear('createdAt');
}
$result = parent::save($entity);
$entity->set($restoreData);
$this->handleEmailAddressSave($entity);
$this->handlePhoneNumberSave($entity);
$this->handleSpecifiedRelations($entity);
return $result;
}