Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
ActionFlag Class Reference

Public Member Functions

 __construct (\Magento\Framework\App\RequestInterface $request)
 
 set ($action, $flag, $value)
 
 get ($action, $flag='')
 

Protected Member Functions

 _getControllerKey ()
 

Protected Attributes

 $_request
 
 $_flags = []
 

Detailed Description

Request processing flag that allows to stop request dispatching in action controller from an observer Downside of this approach is temporal coupling and global communication. Will be deprecated when Action Component is decoupled.

Please use plugins to prevent action dispatching instead.

@api

Since
100.0.2

Definition at line 18 of file ActionFlag.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\App\RequestInterface  $request)
Parameters
RequestInterface$request

Definition at line 33 of file ActionFlag.php.

34  {
35  $this->_request = $request;
36  }

Member Function Documentation

◆ _getControllerKey()

_getControllerKey ( )
protected

Get controller key

Returns
string

Definition at line 82 of file ActionFlag.php.

83  {
84  return $this->_request->getRouteName() . '_' . $this->_request->getControllerName();
85  }

◆ get()

get (   $action,
  $flag = '' 
)

Retrieve flag value

Parameters
string$action
string$flag
Returns
bool

@SuppressWarnings(PHPMD.BooleanGetMethodName)

Definition at line 63 of file ActionFlag.php.

64  {
65  if ('' === $action) {
66  $action = $this->_request->getActionName();
67  }
68  if ('' === $flag) {
69  return $this->_flags[$this->_getControllerKey()] ?? [];
70  } elseif (isset($this->_flags[$this->_getControllerKey()][$action][$flag])) {
71  return $this->_flags[$this->_getControllerKey()][$action][$flag];
72  } else {
73  return false;
74  }
75  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17

◆ set()

set (   $action,
  $flag,
  $value 
)

Setting flag value

Parameters
string$action
string$flag
string$value
Returns
void

Definition at line 46 of file ActionFlag.php.

47  {
48  if ('' === $action) {
49  $action = $this->_request->getActionName();
50  }
51  $this->_flags[$this->_getControllerKey()][$action][$flag] = $value;
52  }
$value
Definition: gender.phtml:16

Field Documentation

◆ $_flags

$_flags = []
protected

Definition at line 28 of file ActionFlag.php.

◆ $_request

$_request
protected

Definition at line 23 of file ActionFlag.php.


The documentation for this class was generated from the following file: