本文整理汇总了PHP中Entity::getProperties方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::getProperties方法的具体用法?PHP Entity::getProperties怎么用?PHP Entity::getProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::getProperties方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getKeyValuePropertiesByEntity
/**
* This functions builds an array (key\value) with entity data, to later insert on the db
*
* @param Entity $entity
*
* @return array
*/
private function getKeyValuePropertiesByEntity(Entity $entity)
{
$properties = array_keys($entity->getProperties());
$keyValueProperties = array();
foreach ($properties as $property) {
$method = $this->getterMethodToGetPropertyValue($property);
$propertyValue = $entity->{$method}();
if (is_null($propertyValue)) {
continue;
}
$annotations = $this->annotation->getAnnotationsByProperty($property, $entity);
$propertyKey = $this->getValueOfAnnotation($annotations, self::PROPERTY_ANNOTATION);
$keyValueProperties[$propertyKey] = $propertyValue;
}
return $keyValueProperties;
}
示例2: generateSql
private function generateSql(Entity $entity)
{
$table = $entity->getTable();
$primKey = $entity->getPrimaryKey();
$sql = "CREATE TABLE `{$table}` (\n";
$sql .= "\t`{$primKey->getName()}` {$primKey->getDbType()} NOT NULL AUTO_INCREMENT,\n";
foreach ($entity->getProperties() as $property) {
$sql .= "\t`{$property->getName()}` {$property->getDbType()} NOT NULL,\n";
}
foreach (Singleton::create("ServiceBuilder")->getOneToManyMappedProperties($entity) as $property) {
$sql .= "\t`{$property->getMappingKey()}` {$property->getEntity()->getPrimaryKey()->getDbType()} NOT NULL,\n";
}
$sql .= implode(",\n", $this->generateIndexes($entity));
$sql .= "\n);";
return $sql;
}
示例3: ValidateEntityPropertiesCheck
/**
* Валидирует значение свойств у объекта
*
* @param Entity $oTarget
*
* @return bool|string
*/
public function ValidateEntityPropertiesCheck($oTarget)
{
/**
* Пробуем получить свойства из реквеста
*/
$oTarget->setProperties($oTarget->getProperties() ? $oTarget->getProperties() : getRequest('property'));
$aPropertiesValue = $oTarget->getProperties();
$aPropertiesResult = array();
/**
* Получаем весь список свойств у объекта
*/
$aPropertiesObject = $this->Property_GetPropertyItemsByFilter(array('target_type' => $oTarget->property->getPropertyTargetType()));
$this->Property_AttachValueForProperties($aPropertiesObject, $oTarget->property->getPropertyTargetType(), $oTarget->getId());
foreach ($aPropertiesObject as $oProperty) {
$oValue = $oProperty->getValue();
$sValue = isset($aPropertiesValue[$oProperty->getId()]) ? $aPropertiesValue[$oProperty->getId()] : null;
/**
* Валидируем значение
*/
$oValueType = $oValue->getValueTypeObject();
$oValueType->setValueForValidate($sValue);
if (true === ($sRes = $oValueType->validate())) {
$oValueType->setValue($oValueType->getValueForValidate());
$aPropertiesResult[$oProperty->getId()] = $oProperty;
} else {
return 'Поле "' . $oProperty->getTitle() . '": ' . ($sRes ? $sRes : 'неверное значение');
}
}
$oTarget->setPropertiesObject($aPropertiesResult);
return true;
}