Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PreprocessorStrategy.php
Go to the documentation of this file.
1 <?php
7 
15 
23 {
27  private $frontendCompilation;
28 
32  private $alternativeSource;
33 
37  private $scopeConfig;
38 
42  private $state;
43 
51  public function __construct(
52  AlternativeSourceInterface $alternativeSource,
53  FrontendCompilation $frontendCompilation,
54  ScopeConfigInterface $scopeConfig
55  ) {
56  $this->frontendCompilation = $frontendCompilation;
57  $this->alternativeSource = $alternativeSource;
58  $this->scopeConfig = $scopeConfig;
59  }
60 
67  public function process(PreProcessor\Chain $chain)
68  {
69  $isClientSideCompilation =
70  $this->getState()->getMode() !== State::MODE_PRODUCTION
71  && WorkflowType::CLIENT_SIDE_COMPILATION === $this->scopeConfig->getValue(WorkflowType::CONFIG_NAME_PATH);
72 
73  if ($isClientSideCompilation) {
74  $this->frontendCompilation->process($chain);
75  } else {
76  $this->alternativeSource->process($chain);
77  }
78  }
79 
84  private function getState()
85  {
86  if (null === $this->state) {
87  $this->state = ObjectManager::getInstance()->get(State::class);
88  }
89  return $this->state;
90  }
91 }
__construct(AlternativeSourceInterface $alternativeSource, FrontendCompilation $frontendCompilation, ScopeConfigInterface $scopeConfig)