当前位置: 首页>>代码示例>>PHP>>正文


PHP FWValidator::is_serialized方法代码示例

本文整理汇总了PHP中FWValidator::is_serialized方法的典型用法代码示例。如果您正苦于以下问题:PHP FWValidator::is_serialized方法的具体用法?PHP FWValidator::is_serialized怎么用?PHP FWValidator::is_serialized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FWValidator的用法示例。


在下文中一共展示了FWValidator::is_serialized方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: export

 /**
  * This function is used to convert the array into entity objects.
  * 
  * @param  array $data
  * 
  * @return array return as entity object array
  */
 public function export($data)
 {
     if (empty($data)) {
         return;
     }
     $em = \Env::get('em');
     $entityClassMetaData = $em->getClassMetadata($this->entityClass);
     $repository = $em->getRepository($this->entityClass);
     $entities = array();
     foreach ($data as $entityArray) {
         $entityObj = null;
         $primaryKeyName = $entityClassMetaData->getSingleIdentifierFieldName();
         if (!empty($entityArray[$primaryKeyName])) {
             $entityObj = $repository->findOneBy(array($primaryKeyName => $entityArray[$primaryKeyName]));
         }
         if (!$entityObj) {
             $entityObj = new $this->entityClass();
         }
         //get the association mappings
         $associationMappings = $entityClassMetaData->getAssociationMappings();
         //class methods
         $classMethods = get_class_methods($entityObj);
         foreach ($entityArray as $entityField => $entityValue) {
             $associationObj = null;
             if (!in_array('set' . ucfirst($entityField), $classMethods)) {
                 continue;
             }
             if ($entityClassMetaData->isSingleValuedAssociation($entityField)) {
                 $targetEntity = $associationMappings[$entityField]['targetEntity'];
                 $mappingEntityField = $em->getClassMetadata($targetEntity)->getSingleIdentifierFieldName();
                 //check the association entity
                 $mappingEntityValue = is_array($entityValue) ? isset($entityValue[$mappingEntityField]) ? $entityValue[$mappingEntityField] : 0 : $entityValue;
                 if (!\FWValidator::isEmpty($mappingEntityValue)) {
                     $associationObj = $em->getRepository($targetEntity)->findOneBy(array($mappingEntityField => $mappingEntityValue));
                 }
                 if (!$associationObj) {
                     $associationObj = new $targetEntity();
                 }
                 if (is_array($entityValue)) {
                     foreach ($entityValue as $method => $value) {
                         $associationObj->{'set' . ucfirst($method)}($value);
                     }
                 } else {
                     $entityObj->{'set' . ucfirst($entityField)}($associationObj);
                 }
                 $entityValue = $associationObj;
             }
             //checks if the string a serialized array
             if (\FWValidator::is_serialized($entityValue)) {
                 $entityValue = unserialize($entityValue);
             }
             $entityObj->{'set' . ucfirst($entityField)}($entityValue);
         }
         $entities[] = $entityObj;
     }
     return $entities;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:64,代码来源:EntityInterface.class.php


注:本文中的FWValidator::is_serialized方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。