2016-07-28
@override
@see ObserverInterface::execute()
@used-by \Magento\Framework\Event\Invoker\InvokerDefault::_callObserverMethod()
@param Ob $o
774772
function execute(Ob $o) {
		$provider = $o[Plugin::PROVIDER]; /** @var Provider $provider */
		/** @var ISearchResult|ApiSearchResult|UiSearchResult|OrderGC|InvoiceGC|CreditmemoGC $result */
		$result = $o[Plugin::RESULT];
		// 2017-08-02 For now, we do not handle «sales_order_invoice_grid_data_source»
		// and «sales_order_creditmemo_grid_data_source».
		if ('sales_order_grid_data_source' === $provider->getName()) {
			/**
			 * 2016-07-28
			 * https://github.com/magento/magento2/blob/2.1.0/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/SearchResult.php#L37-L40
			 * @see \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult::$document
			 * The document's structure is described here: https://mage2.pro/t/1908
			 */
			$cacheKey = __METHOD__; /** @var string $cacheKey */
			$prop = 'payment_method';  /** @var string $prop */
			df_map($result, function(Document $item) use($cacheKey, $prop) {
				/** @var string|null $methodCode */
				if (($methodCode = $item[$prop]) && df_starts_with($methodCode, 'dfe_')) {
					/**
					 * 2017-05-09
					 * Как оказалось, наличие приставки «dfe_» ешё не гарантирует,
					 * что @uses dfpm() (вызываемый ниже опосредованно через dfpm_title())
					 * действительно вернёт наследника @see \Df\Payment\Method
					 * Возможна ситуация, когда админтратор установил какой-либо из моих патёжных модулей,
					 * сделал платёж посредством него, а затем либо удалил модуль,
					 * либо из-за каких-то некорректных действий модуль стал отключенным,
					 * и вот тогда M2 вернёт не наследника @see \Df\Payment\Method,
					 * а экземпляр класса @see \Magento\Payment\Model\Method\Substitution:
					 * «How is @see \Magento\Payment\Model\Method\Substitution implemented and used?»
					 * https://mage2.pro/t/3924
					 * 1) @see \Magento\Sales\Model\Order\Payment\Info::getMethodInstance()
					 *	try {
					 *		$instance = $this->paymentData->getMethodInstance($this->getMethod());
					 *	} catch (\UnexpectedValueException $e) {
					 *		$instance = $this->paymentData->getMethodInstance(Substitution::CODE);
					 *	}
					 * https://github.com/magento/magento2/blob/2.1.6/app/code/Magento/Sales/Model/Order/Payment/Info.php#L113-L117
					 * 2) @see \Magento\Payment\Model\Info::getMethodInstance()
					 *	try {
					 *		$instance = $this->_paymentData->getMethodInstance($this->getMethod());
					 *	} catch (\UnexpectedValueException $e) {
					 *		$instance = $this->_paymentData->getMethodInstance(Method\Substitution::CODE);
					 *	}
					 * https://github.com/magento/magento2/blob/2.1.6/app/code/Magento/Payment/Model/Info.php#L106-L110
					 */
					$id = $item['entity_id']; /** @var int $id */
					// 2016-07-29
					// Эта операция очень ресурсоёмка:
					// для каждой строки таблицы заказов она делает кучу запросов к базе данных.
					// Поэтому кэшируем результаты в постоянном кэше.
					$item[$prop] = df_cache_get_simple([$cacheKey, $id], function() use($id) {
						$m = dfpm($o = df_order($id)); /** @var O $o */ /** @var M|Substitution $m */
						return !dfp_my($m) ? $m->getTitle() : df_cc_br(dfpm_title($m), dfp_choice($o)->title());
					});
				}
			});
		}
	}
948748
public function execute(Observer $observer)
    {
        if (!$this->scopeConfig->getValue(self::CONFIG_PATH_REDIRECT_TO_CHECKOUT, ScopeInterface::SCOPE_STORE)) {
            return;
        }

        /** @var Http $request */
        $request = $observer->getData('request');
        $request->setParam('return_url', $this->url->getUrl('checkout'));
    }
390639
function execute(O $o) {
		if (df_is_checkout_multishipping()) {
			$p = $o['payment']; /** @var OP $p */
			/**
			 * 2017-08-28
			 * I intentionally do not use @see dfp_my() here, 
			 * because this function will instantiate a @see \Df\Payment\Method instance
			 * (or use a previously cached instance). 
			 */
			if (df_starts_with(($code = $p->getMethod()), 'dfe_')) { /** @var string $code */
				Method::sgReset();
				if ($cardId = Token::exchangedGet($code)) {  /** @var string|null $cardId */
					dfp_add_info($p, [Token::KEY => $cardId]);
				}
			}
		}
	}
1000083
final function execute(Ob $ob) {
		if (dfs($this)->enable()) {
			$ob[P::CONTAINER][P::K_TRANSPORT] = df_con($this, 'Transport');
		}
	}
736616
protected function observe($observer)
    {
        if (method_exists($observer, 'saving')) {
            $this->hook('saving', array($observer, 'saving'));
        }

        if (method_exists($observer, 'saved')) {
            $this->hook('saved', array($observer, 'saved'));
        }

        if (method_exists($observer, 'filtering')) {
            $this->hook('filtering', array($observer, 'filtering'));
        }

        if (method_exists($observer, 'filtered')) {
            $this->hook('filtered', array($observer, 'filtered'));
        }

        if (method_exists($observer, 'removing')) {
            $this->hook('removing', array($observer, 'removing'));
        }

        if (method_exists($observer, 'removed')) {
            $this->hook('removed', array($observer, 'removed'));
        }

        if (method_exists($observer, 'searching')) {
            $this->hook('searching', array($observer, 'searching'));
        }

        if (method_exists($observer, 'searched')) {
            $this->hook('searched', array($observer, 'searched'));
        }

        if (method_exists($observer, 'attaching')) {
            $this->hook('attaching', array($observer, 'attaching'));
        }

        if (method_exists($observer, 'attached')) {
            $this->hook('attached', array($observer, 'attached'));
        }

        if (method_exists($observer, 'initialized')) {
            $this->hook('initialized', array($observer, 'initialized'));
        }
    }
1049240
protected function ExecuteIPaymentCall($oOrder)
    {
        $parameters = $this->GetPayFieldParameter(array(), $oOrder);
        $requestUrl = $this->GetRequestURL();
        $url = $requestUrl.$this->getUrlUtil()->getArrayAsUrl($parameters, '?', '&');
        $this->getRedirect()->redirect($url);
    }
1167379
public function ObserverRegister($sObserverName, &$oObserver)
    {
        if (!array_key_exists($sObserverName, $this->aObservers)) {
            $this->aObservers[$sObserverName] = &$oObserver;
        }
    }
1299785
public function execute(Observer $observer)
    {
        /** @var Layout $layout */
        if (!$layout = $observer->getData('layout')) {
            return;
        }

        if (!$update = $layout->getUpdate()) {
            return;
        }

        # Set footer - Applied to all pages
        $update->addHandle($this->_getFooterHandleName());

        # Set header - Applied to all pages
        $update->addHandle($this->_getHeaderHandleName());

        # Set footer - Applied product list pages only
        if ($this->_shouldApplyProductListItemHandle()) {
            $update->addHandle($this->_getProductListItemHandleName());
        }

        # Temporary until we have a banners module
        # Adds the banner handle only when at the home page
        if ($this->_shouldApplyBannerHandle()) {
            $update->addHandle($this->_getBannerHandleName());
        }

        # In all pages, add the theme customization AFTER all of the above
        $update->addHandle(self::THEME_CUSOMIZATION_HANDLE_NAME);
    }
1288166
public static function invoke( $oInstance, $methodName, $args=null ){

		//TODO tratar los args.
		$reflectionMethod = new \ReflectionMethod( get_class( $oInstance ) , $methodName);
		$value = $reflectionMethod->invoke( $oInstance, $args );
			
		return $value;
	}
808243
private function _PluginCallbackExecution($PluginClassName, $HookMethod) {
      if (class_exists($PluginClassName)) {
         $Plugin = new $PluginClassName();
         if (method_exists($PluginClassName, $HookMethod)) {
            $Plugin->$HookMethod();
         }
      }
   }
1161666
@Override
   public Object invoke(Exchange exchange, Object o)
   {
      BindingOperationInfo bop = exchange.getBindingOperationInfo();
      MethodDispatcher md = (MethodDispatcher) exchange.getService().get(MethodDispatcher.class.getName());
      List<Object> params = null;
      if (o instanceof List) {
         params = CastUtils.cast((List<?>) o);
      } else if (o != null) {
         params = new MessageContentsList(o);
      }
      final Object tb = (factory == null) ? targetBean : this.getServiceObject(exchange);
      final Method method = (bop == null) ? null : md.getMethod(bop);
      if (method == null)
      {
         throw Messages.MESSAGES.missingBindingOpeartionAndDispatchedMethod();
      }
      //performance optimization, adjustMethodAndParams currently looks for @UseAsyncMethod (which is expensive) and only performs actions if it's found
      final Method fm = checkForUseAsyncMethod ? adjustMethodAndParams(md.getMethod(bop), exchange, params, tb.getClass()) : method;
      return invoke(exchange, tb, fm, params);
   }
1126459
public function execute(Observer $observer)
    {
        /** @var Customer $customer */
        $customer = $observer->getEvent()->getCustomer();

        try {
            $this->customerEventHandler->store(
                $customer->getId(),
                $customer->getWebsiteId(),
                $customer->getStoreId()
            );
        } catch (\Exception $e) {
            $this->logger->warning('Emartech\\Emarsys\\Observers\\CustomerAccountObserver: ' . $e->getMessage());
        }
    }
382855
public function execute(\Magento\Framework\Event\Observer $observer)
    {
        /** define local working data */
        /** @var \Magento\Catalog\Model\Product $product */
        $product = $observer->getData(self::DATA_PRODUCT);

        /** perform processing */
        if ($product instanceof \Magento\Catalog\Model\Product) {
            $product->setSpecialPrice(null);
        }
    }
458680
public function execute(callable $callback)
    {
        $commands = $this->commands;
        $command  = $this->client->createCommand('EXEC');

        $this->client->executeCommand($command, function ($responses, $client) use ($commands, $callback) {
            $size = count($responses);
            $processed = [];

            for ($i = 0; $i < $size; $i++) {
                $command  = $commands->dequeue();
                $response = $responses[$i];

                unset($responses[$i]);

                if (!$response instanceof ResponseInterface) {
                    $response = $command->parseResponse($response);
                }

                $processed[$i] = $response;
            }

            call_user_func($callback, $processed, $client);
        });
    }
1230180
public function execute(Observer $observer)
    {
        /** @var Order $order */
        $order = $observer->getEvent()->getOrder();

        try {
            $this->salesEventHandler->store($order);
        } catch (\Exception $e) {
            $this->logger->warning('Emartech\\Emarsys\\Observers\\SalesOrderObserver: ' . $e->getMessage());
        }
    }
59185
public function executePayment($dAmount, & $oOrder)
    {
        /** @var oxUserPayment|OxpsPaymorrowOxUserPayment $oUserPayment */
        $oUserPayment = $this->_oPaymentInfo;

        if (is_object($oUserPayment) && $oUserPayment->isUserPaymentPaymorrowMethod()) {

            // Set real order ID (OXID field) to session to be used in order confirmation during payment.
            $oOrderId = $oOrder->getId();
            $oOrder->savePaymorrowTemporaryOrderIdToSession($oOrderId);

            /** @var OxpsPaymorrowModule $oModule */
            $oModule = oxRegistry::get('OxpsPaymorrowModule');

            /** @var OxpsPaymorrowRequestControllerProxy $oPmRequestControllerProxy */
            $oPmRequestControllerProxy = oxNew('OxpsPaymorrowRequestControllerProxy');
            $oPmRequestControllerProxy->confirmOrder($oModule->getPaymentMethodName(), $oOrderId);

            /** @var OxpsPaymorrowResponseHandler $oPmResponseHandler */
            $oPmResponseHandler = oxRegistry::get('OxpsPaymorrowResponseHandler');

            /**
             * If Order has an error after validation from Paymorrow services invalidate order and delete it
             * If Payment data save failed return an error
             */
            if ($oPmResponseHandler->hasErrors() or
                !$this->_savePaymorrowUserPaymentData($oOrder, $oPmResponseHandler)
            ) {
                $this->_handleOrderResponseErrors($oPmResponseHandler);

                return false;
            }
        }

        return $this->_OxpsPaymorrowOxPaymentGateway_executePayment_parent($dAmount, $oOrder);
    }
912189
function callObservers(object, chgeset) {
    var ln = object[OBSERVER_PROPERTY];
    if (ln) {
        var elt;
        for (var i = 0, sz = ln.length; sz > i; i++) {
            elt = ln[i];
            if (elt.constructor === Function) {
                elt(chgeset);
            }
        }
    }
}