-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathFree.php
More file actions
67 lines (58 loc) · 1.74 KB
/
Free.php
File metadata and controls
67 lines (58 loc) · 1.74 KB
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
<?php
namespace Cloudinary\Cloudinary\Block\Adminhtml\Form\Field;
use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Cloudinary\Cloudinary\Core\ConfigurationInterface;
use Cloudinary\Cloudinary\Model\Config\Backend\Free as FreeBackendModel;
class Free extends Field
{
const XML_PATH_GLOBAL_TRANSFORMATION = 'cloudinary/transformations/cloudinary_free_transform_global';
/**
* @var ConfigurationInterface
*/
private $configuration;
/**
* @var FreeBackendModel
*/
private $model;
/**
* @param Context $context
* @param ConfigurationInterface $configuration
* @param FreeBackendModel $model
* @param array $data
*/
public function __construct(
Context $context,
ConfigurationInterface $configuration,
FreeBackendModel $model,
array $data = []
) {
$this->configuration = $configuration;
$this->model = $model;
parent::__construct($context, $data);
}
/**
* @return $this
*/
protected function _beforeToHtml()
{
$this->setTemplate('Cloudinary_Cloudinary::config/free.phtml');
return $this;
}
public function isCanPreviewTransformations() {
return $this->_scopeConfig->getValue(self::XML_PATH_GLOBAL_TRANSFORMATION);
}
/**
* @param AbstractElement $element
* @return string
*/
protected function _getElementHtml(AbstractElement $element)
{
return sprintf(
'%s%s',
$element->getElementHtml(),
$this->model->hasAccountConfigured() ? $this->toHtml() : ''
);
}
}