Example #1
0
 /**
  * 2015-08-29
  * Цель метода — перевод экранных названий свойств товаров.
  * @see \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection::addItem()
  * @param Sb $sb
  * @param A $item
  * @return array(Attribute)
  */
 public function beforeAddItem(Sb $sb, A $item)
 {
     df_state()->attributeSet($item);
     try {
         $item['frontend_label'] = (string) __($item['frontend_label']);
     } finally {
         df_state()->attributeUnset();
     }
     return [$item];
 }
 /**
  * 2015-09-02
  * А вот попадаем ли мы сюда для блоков без шаблонов
  * (и надо ли нам тогда сюда попадать)?
  * @see \Magento\Framework\View\TemplateEngineInterface::render()
  * @param Sb $sb
  * @param \Closure $proceed
  * @param BlockInterface $block
  * @param string $templateFile
  * @param mixed[] $dictionary
  * @return string
  */
 public function aroundRender(Sb $sb, \Closure $proceed, BlockInterface $block, $templateFile, array $dictionary = [])
 {
     /** @var string $result */
     df_state()->blockSet($block, $templateFile);
     try {
         $result = $proceed($block, $templateFile, $dictionary);
     } finally {
         df_state()->blockSetPrev();
     }
     return $result;
 }
Example #3
0
 /**
  * 2015-09-30
  * Цель метода — перевод экранных названий свойств (товаров, разделов, покупателей и т.п.).
  * @see \Magento\Eav\Model\ResourceModel\Entity\Attribute::load()
  * @param Sb $sb
  * @param \Closure $proceed
  * @param A $object
  * @param mixed $value
  * @param string|null $field [optional]
  * @return Sb
  */
 public function aroundLoad(Sb $sb, \Closure $proceed, A $object, $value, $field = null)
 {
     $proceed($object, $value, $field);
     df_state()->attributeSet($object);
     try {
         $object['frontend_label'] = (string) __($object['frontend_label']);
     } finally {
         df_state()->attributeUnset($object);
     }
     return $sb;
 }
Example #4
0
 /**
  * 2015-09-20
  * Цель метода — перевод экранных названий свойств (товаров, разделов, покупателей и т.п.).
  * @see \Df\Framework\Plugin\Data\Form\Element\AbstractElement::afterGetEscapedValue()
  * @see \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend::getLabel()
  * @param Sb $sb
  * @param string $result
  * @return string
  */
 public function afterGetLabel(Sb $sb, $result)
 {
     df_state()->attributeSet($sb->getAttribute());
     /** @var string[] $result */
     /**
      * 2015-09-21
      * Важно сразу привести результат к строке,
      * потому что иначе @see __() вернёт объект и отложит перевод на потом,
      * когда мы уже выпадем из контекста свойства (finally ниже).
      */
     try {
         $result = (string) __($result);
     } finally {
         df_state()->attributeUnset();
     }
     return $result;
 }
Example #5
0
 /**
  * 2015-09-27
  * Цель метода — получение информации о формировании в данный момент заголовка страницы.
  * @uses \Magento\Framework\View\Page\Title::get()
  * @param Sb $sb
  * @param \Closure $proceed
  * @return string
  */
 public function aroundGet(Sb $sb, \Closure $proceed)
 {
     df_state()->renderingTitle(true);
     try {
         $result = $proceed();
         /**
          * Делаем браузерные заголовки административной части
          * более короткими и понятными: оставляем лишь первую и последнюю части заголовка.
          */
         if (df_is_backend()) {
             /** @var string[] $resultA */
             $resultA = explode(Sb::TITLE_GLUE, $result);
             $result = 3 > count($resultA) ? $result : implode(Sb::TITLE_GLUE, [df_first($resultA), df_last($resultA)]);
         }
     } finally {
         df_state()->renderingTitle(false);
     }
     return $result;
 }
 /**
 * @override
 * @see ObserverInterface::execute()
 * @used-by \Magento\Framework\Event\Invoker\InvokerDefault::_callObserverMethod()
 * @see \Magento\Framework\App\Action\Action::dispatch()
 * https://github.com/magento/magento2/blob/dd47569249206b217e0a9f9a9371e73fd7622724/lib/internal/Magento/Framework/App/Action/Action.php#L91-L92
 		$eventParameters = ['controller_action' => $this, 'request' => $request];
 		$this->_eventManager->dispatch('controller_action_predispatch', $eventParameters)
 * @param O $o
 * @return void
 */
 public function execute(O $o)
 {
     df_state()->controllerSet($o['controller_action']);
 }
Example #7
0
 /**
  * @param Sb $sb
  * @return void
  */
 public function beforeDispatch(Sb $sb)
 {
     df_state()->actionSet($sb);
 }
 /**
 * @override
 * @see ObserverInterface::execute()
 * @used-by \Magento\Framework\Event\Invoker\InvokerDefault::_callObserverMethod()
 * @see \Magento\Framework\View\Layout\Builder::generateLayoutBlocks()
 * https://github.com/magento/magento2/blob/dd47569249206b217e0a9f9a9371e73fd7622724/lib/internal/Magento/Framework/View/Layout/Builder.php#L133
 		$this->eventManager->dispatch(
 			'layout_generate_blocks_after',
 			['full_action_name' => $this->request->getFullActionName(), 'layout' => $this->layout]
 		);
 * @param O $o
 * @return void
 */
 public function execute(O $o)
 {
     df_state()->blocksHasBeenGenerated();
 }
 /**
 * @override
 * @see ObserverInterface::execute()
 * @used-by \Magento\Framework\Event\Invoker\InvokerDefault::_callObserverMethod()
 * @see \Magento\Framework\View\Layout::generateLayoutBlocks()
 * https://github.com/magento/magento2/blob/dd47569249206b217e0a9f9a9371e73fd7622724/lib/internal/Magento/Framework/View/Layout/Builder.php#L123
 		$this->eventManager->dispatch(
 			'layout_generate_blocks_before',
 			['full_action_name' => $this->request->getFullActionName(), 'layout' => $this->layout]
 		);
 * @param O $o
 * @return void
 */
 public function execute(O $o)
 {
     df_state()->blocksGenerationStarted();
 }
Example #10
0
/**
 * @return \Magento\Framework\App\Action\Action|null
 */
function df_controller()
{
    return df_state()->controller();
}
Example #11
0
 /**
  * 2015-09-19
  * Цель метода — получение информации о формируемом в данный момент компоненте
  * с целью индивидуального языкового перевода его интерфейса.
  * @see \Magento\Framework\View\Layout::renderNonCachedElement()
  * @param Sb $sb
  * @param \Closure $proceed
  * @param string $name
  * @return string
  */
 public function aroundRenderNonCachedElement(Sb $sb, \Closure $proceed, $name)
 {
     /** @var UiComponent|null $wrapper */
     $wrapper = $sb->isUiComponent($name) ? $sb->getUiComponent($name) : null;
     /** @var string $result */
     $wrapper ? df_state()->componentSet($wrapper->component) : null;
     try {
         $result = $proceed($name);
     } finally {
         $wrapper ? df_state()->componentSetPrev() : null;
     }
     return $result;
 }