function nodeRename(PropertyMapping $propertyMapping, $fileName, $params)
 {
     $obj = $propertyMapping->getObj();
     $id = isset($params['id']) && $params['id'] ? strtolower($params['id']) : 'id';
     $id = $obj->{'get' . ucfirst($id)}();
     $nodeId = ceil($id / 100);
     $dirName = $nodeId . '/' . $id;
     return $dirName;
 }
示例#2
0
 protected function getFieldValueByParam(PropertyMapping $propertyMapping, $params)
 {
     $obj = $propertyMapping->getObj();
     $fieldValue = '';
     if (isset($params['use_field_name']) && $params['use_field_name']) {
         $fieldValue = $propertyMapping->getFileDataPropertyName();
     } else {
         $field = isset($params['field']) && $params['field'] ? $params['field'] : 'id';
         $fieldValue = $obj->{'get' . ucfirst($field)}();
     }
     if (!$fieldValue) {
         $fieldValue = $obj->getId();
     }
     return $fieldValue;
 }
示例#3
0
 function dateRename(PropertyMapping $propertyMapping, $fileName, $params)
 {
     $obj = $propertyMapping->getObj();
     $field = isset($params['field']) && $params['field'] ? $params['field'] : 'id';
     $depth = isset($params['depth']) && $params['depth'] ? strtolower($params['depth']) : 'day';
     $date = $obj->{'get' . ucfirst($field)}();
     $date = $date ? $date->getTimestamp() : time();
     $tpl = "Y/m/d";
     if ($depth == 'month') {
         $tpl = "Y/m";
     }
     if ($depth == 'year') {
         $tpl = "Y";
     }
     $dirName = date($tpl, $date);
     return $dirName;
 }