Skip to content

Instantly share code, notes, and snippets.

@mooror
Created June 5, 2016 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mooror/33b3dee86a01524d9fd530f8945818d0 to your computer and use it in GitHub Desktop.
Save mooror/33b3dee86a01524d9fd530f8945818d0 to your computer and use it in GitHub Desktop.
<?php
class CustomUploadField extends UploadField {
/**
* FieldList $fields or string $name (of a method on File to provide a fields) for the EditForm
* @example 'getCMSFields'
*
* @var FieldList|string
*/
private static $fileOwnerId =0;
/**
* FieldList $fields or string $name (of a method on File to provide a fields) for the EditForm
* @example 'getCMSFields'
*
* @var FieldList|string
*/
private static $itemTitle = 'Defualt';
/**
* FieldList $fields or string $name (of a method on File to provide a fields) for the EditForm
* @example 'getCMSFields'
*
* @var FieldList|string
*/
private static $itemVersion = '0.0.1';
// public function setFileOwnerId($fileOwnerId){
// $this->$fileOwnerId = $fileOwnerId;
// Debug::show($this->$fileOwnerId);
// Debug::show($fileOwnerId);
// }
// public function setItemTitle($itemTitle){
// $this->$itemTitle = $itemTitle;
// }
// public function setItemVersion($itemVersion){
// $this->$itemVersion = $itemVersion;
// }
// public function setNameGeneratorInfo($fileOwnerId,$itemTitle,$itemVersion){
// $this->$fileOwnerId = $fileOwnerId;
// $this->$itemTitle = $itemTitle;
// $this->$itemVersion = $itemVersion;
// return $this;
// }
public function getGeneratedFileName(){
$userId = $this->$fileOwnerId;
$itemTitle = $this->$itemTitle;
$itemVersion = $this->$itemVersion;
return hash("md5", $userId.$itemTitle.$itemVersion);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment