forked from symfony-cmf/media-bundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MediaManagerInterface.php
84 lines (77 loc) · 2.21 KB
/
MediaManagerInterface.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
<?php
/*
* This file is part of the Symfony CMF package.
*
* (c) 2011-2014 Symfony CMF
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Cmf\Bundle\MediaBundle;
/**
* Interface containing media helper methods, these are probably persistence
* layer specific.
*/
interface MediaManagerInterface
{
/**
* Get path, like:
* - /path/to/file/filename.ext
* - /fileId
*
* It is similar to a filesystem path only always uses "/" to separate
* parents, and therefore allows to get the parent from the path.
*
* @param MediaInterface $media
*
* @return string
*/
public function getPath(MediaInterface $media);
/**
* Get an url safe path
*
* @param MediaInterface $media
*
* @return string
*/
public function getUrlSafePath(MediaInterface $media);
/**
* Set defaults for a media object;
* this is used fe. by Doctrine Phpcr to ensure a unique id and add the
* parent object.
*
* @param MediaInterface $media
* @param string $parentPath optionally add the parent path
*
* @return void
*
* @throws \RuntimeException if the defaults could not be set
*/
public function setDefaults(MediaInterface $media, $parentPath = null);
/**
* Map the path to an id that can be used to lookup the file in the
* Doctrine store.
*
* @param string $path
* @param string $rootPath
*
* @return string
*
* @throws \OutOfBoundsException if the path is out of the root path where
* the filesystem is located
*/
public function mapPathToId($path, $rootPath = null);
/**
* Map the requested path (ie. subpath in the URL) to an id that can
* be used to lookup the file in the Doctrine store.
*
* @param string $path
* @param string $rootPath
*
* @return string
*
* @throws \OutOfBoundsException if the path is out of the root path where
* the filesystem is located
*/
public function mapUrlSafePathToId($path, $rootPath = null);
}