Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CallableMethod.php
Go to the documentation of this file.
1 <?php
7 
9 
14 {
22  public function execute($directive, DataObject $processedObject)
23  {
24  $object = $processedObject;
25  $result = '';
26  foreach (explode('.', $directive[1]) as $method) {
27  $methodName = substr($method, 0, strpos($method, '('));
28  if (is_callable([$object, $methodName])) {
29  $result = $object->$methodName();
30  if (is_scalar($result)) {
31  break;
32  }
33  $object = $result;
34  continue;
35  }
36  break;
37  }
38 
39  return $result;
40  }
41 
47  public function getPattern()
48  {
49  return '#\{\{((?:[\w_0-9]+\(\)){1}(?:(?:\.[\w_0-9]+\(\))+)?)\}\}#';
50  }
51 }
$method
Definition: info.phtml:13