Continued work on getter/setters: post names
This commit is contained in:
parent
878079030d
commit
c4bcc4b85b
2 changed files with 14 additions and 4 deletions
|
@ -6,7 +6,7 @@ class PostEntity extends AbstractEntity implements IValidatable
|
||||||
{
|
{
|
||||||
protected $type;
|
protected $type;
|
||||||
protected $name;
|
protected $name;
|
||||||
public $origName;
|
protected $origName;
|
||||||
public $fileHash;
|
public $fileHash;
|
||||||
public $fileSize;
|
public $fileSize;
|
||||||
public $mimeType;
|
public $mimeType;
|
||||||
|
@ -229,6 +229,16 @@ class PostEntity extends AbstractEntity implements IValidatable
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getOriginalName()
|
||||||
|
{
|
||||||
|
return $this->origName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setOriginalName($origName)
|
||||||
|
{
|
||||||
|
$this->origName = $origName;
|
||||||
|
}
|
||||||
|
|
||||||
public function getType()
|
public function getType()
|
||||||
{
|
{
|
||||||
return $this->type;
|
return $this->type;
|
||||||
|
@ -327,7 +337,7 @@ class PostEntity extends AbstractEntity implements IValidatable
|
||||||
{
|
{
|
||||||
$this->fileSize = filesize($srcPath);
|
$this->fileSize = filesize($srcPath);
|
||||||
$this->fileHash = md5_file($srcPath);
|
$this->fileHash = md5_file($srcPath);
|
||||||
$this->origName = $origName;
|
$this->setOriginalName($origName);
|
||||||
|
|
||||||
if ($this->fileSize == 0)
|
if ($this->fileSize == 0)
|
||||||
throw new SimpleException('Specified file is empty');
|
throw new SimpleException('Specified file is empty');
|
||||||
|
@ -386,7 +396,7 @@ class PostEntity extends AbstractEntity implements IValidatable
|
||||||
if (!preg_match('/^https?:\/\//', $srcUrl))
|
if (!preg_match('/^https?:\/\//', $srcUrl))
|
||||||
throw new SimpleException('Invalid URL "%s"', $srcUrl);
|
throw new SimpleException('Invalid URL "%s"', $srcUrl);
|
||||||
|
|
||||||
$this->origName = $srcUrl;
|
$this->setOriginalName($srcUrl);
|
||||||
|
|
||||||
if (preg_match('/youtube.com\/watch.*?=([a-zA-Z0-9_-]+)/', $srcUrl, $matches))
|
if (preg_match('/youtube.com\/watch.*?=([a-zA-Z0-9_-]+)/', $srcUrl, $matches))
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,7 +47,7 @@ class PostModel extends AbstractCrudModel
|
||||||
$bindings = [
|
$bindings = [
|
||||||
'type' => $post->getType()->toInteger(),
|
'type' => $post->getType()->toInteger(),
|
||||||
'name' => $post->getName(),
|
'name' => $post->getName(),
|
||||||
'orig_name' => $post->origName,
|
'orig_name' => $post->getOriginalName(),
|
||||||
'file_hash' => $post->fileHash,
|
'file_hash' => $post->fileHash,
|
||||||
'file_size' => $post->fileSize,
|
'file_size' => $post->fileSize,
|
||||||
'mime_type' => $post->mimeType,
|
'mime_type' => $post->mimeType,
|
||||||
|
|
Loading…
Reference in a new issue