forked from thelia/thelia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Carousel.php
113 lines (97 loc) · 2.44 KB
/
Carousel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
namespace Carousel\Model;
use Carousel\Form\CarouselImageForm;
use Carousel\Model\Base\Carousel as BaseCarousel;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\Connection\ConnectionInterface;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Files\FileModelInterface;
use Thelia\Files\FileModelParentInterface;
use Thelia\Form\BaseForm;
class Carousel extends BaseCarousel implements FileModelInterface
{
public function preDelete(ConnectionInterface $con = null)
{
$carousel = new \Carousel\Carousel();
$fs = new Filesystem();
try {
$fs->remove($carousel->getUploadDir() . DS . $this->getFile());
return true;
} catch (IOException $e) {
return false;
}
}
/**
* Set file parent id
*
* @param int $parentId parent id
*
* @return $this
*/
public function setParentId($parentId)
{
return $this;
}
/**
* Get file parent id
*
* @return int parent id
*/
public function getParentId()
{
return $this->getId();
}
/**
* @return FileModelParentInterface the parent file model
*/
public function getParentFileModel()
{
return new static;
}
/**
* Get the ID of the form used to change this object information
*
* @return BaseForm the form
*/
public function getUpdateFormId()
{
return 'carousel.image';
}
/**
* @return string the path to the upload directory where files are stored, without final slash
*/
public function getUploadDir()
{
$carousel = new \Carousel\Carousel();
return $carousel->getUploadDir();
}
/**
* @param int $objectId the object ID
*
* @return string the URL to redirect to after update from the back-office
*/
public function getRedirectionUrl()
{
return '/admin/module/Carousel';
}
/**
* Get the Query instance for this object
*
* @return ModelCriteria
*/
public function getQueryInstance()
{
return CarouselQuery::create();
}
/**
* @param bool $visible true if the file is visible, false otherwise
* @return FileModelInterface
*/
public function setVisible($visible)
{
// Not implemented
return $this;
}
}