Completed
Pull Request — master (#114)
by Bart
06:18
created

Volumes::getRecords()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace NerdsAndCompany\Schematic\Services;
4
5
use Craft;
6
use craft\base\VolumeInterface;
7
use craft\base\Model;
8
use craft\volumes\Local;
9
use NerdsAndCompany\Schematic\Schematic;
10
11
/**
12
 * Schematic Asset Sources Service.
13
 *
14
 * Sync Craft Setups.
15
 *
16
 * @author    Nerds & Company
17
 * @copyright Copyright (c) 2015-2018, Nerds & Company
18
 * @license   MIT
19
 *
20
 * @see      http://www.nerds.company
21
 */
22
class Volumes extends Base
23
{
24
    /**
25
     * The record class
26
     * @TODO: export to schema file
27
     * @var string
28
     */
29
    protected $recordClass = Local::class;
30
31
    /**
32
     * Get all asset transforms
33
     *
34
     * @return VolumeInterface[]
35
     */
36
    protected function getRecords()
37
    {
38
        return Craft::$app->volumes->getAllVolumes();
39
    }
40
41
    /**
42
     * Save a record
43
     *
44
     * @param Model $record
45
     * @return boolean
46
     */
47
    protected function saveRecord(Model $record)
48
    {
49
        return Craft::$app->volumes->saveVolume($record);
50
    }
51
52
    /**
53
     * Delete a record
54
     *
55
     * @param Model $record
56
     * @return boolean
57
     */
58
    protected function deleteRecord(Model $record)
59
    {
60
        return Craft::$app->volumes->deleteVolume($record);
61
    }
62
}
63