This repository has been archived on 2026-07-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
espocrm-base/application/Espo/Services/Attachment.php
T
2014-02-14 18:22:13 +02:00

31 lines
539 B
PHP

<?php
namespace Espo\Services;
class Attachment extends Record
{
protected function init()
{
$this->dependencies[] = 'fileManager';
}
protected function getFileManager()
{
return $this->getInjection('fileManager');
}
public function createEntity($data)
{
$entity = parent::createEntity($data);
list($prefix, $contents) = explode(',', $data['file']);
if (!empty($entity->id)) {
$this->getFileManager()->putContents('data/upload/' . $entity->id, base64_decode($contents));
}
return $entity;
}
}