Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FlagManager.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Framework;
7 
9 
14 {
21  private $flagFactory;
22 
28  private $flagResource;
29 
35  public function __construct(
36  FlagFactory $flagFactory,
37  FlagResource $flagResource
38  ) {
39  $this->flagFactory = $flagFactory;
40  $this->flagResource = $flagResource;
41  }
42 
49  public function getFlagData($code)
50  {
51  return $this->getFlagObject($code)->getFlagData();
52  }
53 
61  public function saveFlag($code, $value)
62  {
63  $flag = $this->getFlagObject($code);
64  $flag->setFlagData($value);
65  $this->flagResource->save($flag);
66 
67  return true;
68  }
69 
76  public function deleteFlag($code)
77  {
78  $flag = $this->getFlagObject($code);
79 
80  if ($flag->getId()) {
81  $this->flagResource->delete($flag);
82  }
83 
84  return true;
85  }
86 
93  private function getFlagObject($code)
94  {
96  $flag = $this->flagFactory->create(['data' => ['flag_code' => $code]]);
97  $this->flagResource->load(
98  $flag,
99  $code,
100  'flag_code'
101  );
102 
103  return $flag;
104  }
105 }
__construct(FlagFactory $flagFactory, FlagResource $flagResource)
Definition: FlagManager.php:35
$value
Definition: gender.phtml:16
$code
Definition: info.phtml:12