本文整理汇总了PHP中Enlight_Event_EventArgs类的典型用法代码示例。如果您正苦于以下问题:PHP Enlight_Event_EventArgs类的具体用法?PHP Enlight_Event_EventArgs怎么用?PHP Enlight_Event_EventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Enlight_Event_EventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extendExtJS
public function extendExtJS(\Enlight_Event_EventArgs $arguments)
{
/** @var \Enlight_View_Default $view */
$view = $arguments->getSubject()->View();
$view->addTemplateDir($this->getPath() . '/Views/');
$view->extendsTemplate('backend/swag_attribute/Shopware.attribute.Form.js');
}
示例2: init
/**
* Initialize important variables
* @param Enlight_Event_EventArgs $arguments
*/
protected function init(Enlight_Event_EventArgs $arguments)
{
$this->controller = $arguments->getSubject();
$this->request = $this->controller->Request();
$this->view = $this->controller->View();
$this->helper->setRequest($this->request);
}
示例3: onPostDispatch
/**
* Event listener method
*
* Read the last article in defined controllers
* Saves the last article in detail controller
*
* @param Enlight_Event_EventArgs $args
*/
public function onPostDispatch(Enlight_Event_EventArgs $args)
{
$request = $args->getSubject()->Request();
$response = $args->getSubject()->Response();
$view = $args->getSubject()->View();
if (!$request->isDispatched() || $response->isException() || $request->getModuleName() != 'frontend' || !$view->hasTemplate()) {
return;
}
$config = $this->Config();
if ($request->getControllerName() == 'detail' && !Shopware()->Session()->Bot && Shopware()->Shop()->getTemplate()->getVersion() == 1) {
$this->setLastArticleById($view->sArticle["articleID"]);
}
if (rand(0, 100) === 0) {
$time = $config->time > 0 ? (int) $config->time : 15;
$sql = '
DELETE FROM s_emarketing_lastarticles
WHERE time < DATE_SUB(CONCAT(CURDATE(), ?), INTERVAL ? DAY)
';
Shopware()->Db()->query($sql, array(' 00:00:00', $time));
Shopware()->Events()->notify('Shopware_Plugins_LastArticles_ResetLastArticles', array('subject' => $this));
}
if (empty($config->show)) {
return;
}
if (!empty($config->controller) && strpos($config->controller, $request->getControllerName()) === false) {
return;
}
$view->assign('sLastArticlesShow', true);
}
示例4: onPostDispatchFrontend
public function onPostDispatchFrontend(Enlight_Event_EventArgs $arguments)
{
/**@var $controller Shopware_Controllers_Frontend_Index*/
$controller = $arguments->getSubject();
/**
* @var $request Zend_Controller_Request_Http
*/
$request = $controller->Request();
/**
* @var $response Zend_Controller_Response_Http
*/
$response = $controller->Response();
/**
* @var $view Enlight_View_Default
*/
$view = $controller->View();
//Check if there is a template and if an exception has occured
if (!$request->isDispatched() || $response->isException() || $request->getModuleName() != 'frontend' || !$arguments->getSubject()->View()->hasTemplate()) {
return;
}
//Add our plugin template directory to load our slogan extension.
$view->addTemplateDir($this->Path() . 'Views/');
$view->extendsTemplate('frontend/index/footer-navigation.tpl');
for ($i = 1; $i < 5; $i++) {
$contentShow = "pprContentShow{$i}";
$contentColumn = "pprContentColumn{$i}";
$view->assign("show{$i}", $this->Config()->{$contentShow});
$view->assign("column{$i}", $this->Config()->{$contentColumn});
}
}
示例5: onFilterRender
/**
* Plugin event method
*
* @param Enlight_Event_EventArgs $args
* @return mixed
*/
public function onFilterRender(Enlight_Event_EventArgs $args)
{
$request = $args->getSubject()->Action()->Request();
/** @var $response Enlight_Controller_Response_ResponseHttp */
$response = $args->getSubject()->Action()->Response();
$headers = $response->getHeaders();
foreach($headers as $header) {
if($header['name'] == 'Content-Type' && strpos($header['value'], 'application/javascript') === 0) {
$source = $args->getReturn();
$source = str_replace(array("\r\n", "\r"), "\n", $source);
$expressions = array(
// Remove comments
'#/\*.*?\*/#ms' => '',
'#^\s*//.*$#m' => '',
//'#\n\s+#ms' => '',
'#^\s+#ms' => '',
//'#\s+$#ms' => '',
);
$source = preg_replace(array_keys($expressions), array_values($expressions), $source);
return $source;
}
}
if ($request->getModuleName() !== 'frontend' && $request->getModuleName() !== 'widgets') {
return $args->getReturn();
}
return $this->filterSource($args->getReturn());
}
示例6: onAddEncoder
/**
* Add our own encoder to the internal encoder collection
*
* @param Enlight_Event_EventArgs $args
* @return array|mixed
*/
public function onAddEncoder(Enlight_Event_EventArgs $args)
{
$this->registerMyComponents();
$hashes = $args->getReturn();
$hashes[] = new \Shopware\SwagMd5Reversed\Md5ReversedEncoder();
return $hashes;
}
示例7: onPostDispatch
/**
* Called from the Event Manager after the dispatch process
*
* @param Enlight_Event_EventArgs $args
* @return bool
*/
public function onPostDispatch(Enlight_Event_EventArgs $args)
{
/** @var $subject Enlight_Controller_Action */
$subject = $args->get('subject');
$response = $subject->Response();
$request = $subject->Request();
if (!$request->isDispatched()) {
return;
}
// If the attribute padding is a boolean true
if ($this->padding === true) {
$this->padding = $request->getParam('callback');
$this->padding = preg_replace('#[^0-9a-z_]+#i', '', (string) $this->padding);
}
// decide if we should render the data or the whole page
if ($this->renderer === true) {
$content = $subject->View()->getAssign();
} elseif (!empty($this->padding)) {
$content = $response->getBody();
} else {
return;
}
// Convert content to json
$content = $this->convertToJson($content);
if (!empty($this->padding)) {
$response->setHeader('Content-type', 'text/javascript', true);
$response->setBody($this->addPadding($content, $this->padding));
} elseif ($this->renderer === true) {
$response->setHeader('Content-type', 'application/json', true);
$response->setBody($content);
}
$this->padding = null;
$this->encoding = 'UTF-8';
$this->renderer = null;
}
示例8: onSecureCheckoutConfirmPostDispatch
public function onSecureCheckoutConfirmPostDispatch(Enlight_Event_EventArgs $arguments)
{
$controller = $arguments->get('subject');
$view = $controller->View();
$view->addTemplateDir($this->Path() . '/Views');
$view->assign('number', $this->Config()->get('number'));
}
示例9: onAfterRegisterShop
/**
* @param \Enlight_Event_EventArgs $args
*/
public function onAfterRegisterShop(\Enlight_Event_EventArgs $args)
{
/** @var $container Container */
$container = $args->getSubject();
/** @var $router \Shopware\Components\Routing\RouterInterface */
$router = $container->get('router');
/** @var $shop \Shopware\Models\Shop\Shop */
$shop = $container->get('shop');
/** @var $config \Shopware_Components_Config */
$config = $container->get('config');
// Register the shop (we're to soon)
$config->setShop($shop);
$context = $router->getContext();
$newContext = Context::createFromShop($shop, $config);
// Reuse the host
if ($newContext->getHost() === null) {
$newContext->setHost($context->getHost());
$newContext->setBaseUrl($context->getBaseUrl());
// Reuse https
if (!$newContext->isSecure()) {
$newContext->setSecure($context->isSecure());
$newContext->setSecureBaseUrl($context->getSecureBaseUrl());
}
}
// Reuse the global params like controller and action
$globalParams = $context->getGlobalParams();
$newContext->setGlobalParams($globalParams);
$router->setContext($newContext);
}
示例10: onPostDispatchIndexController
public function onPostDispatchIndexController(Enlight_Event_EventArgs $arguments)
{
$controller = $arguments->getSubject();
$view = $controller->View();
$view->addTemplateDir($this->Path() . 'Views/');
$shopLang = Shopware()->Front()->Request()->getCookie('shopLang');
// $ip = $_SERVER['REMOTE_ADDR'];
$ip = '195.149.248.130';
//BG
// $ip = '194.50.69.124'; //DE
// $ip = '211.156.198.82'; //CN
$gi = geoip_open(__DIR__ . '/GeoIp/db/GeoIP.dat', GEOIP_STANDARD);
$countryCode = geoip_country_code_by_addr($gi, $ip);
geoip_close($gi);
if ($shopLang != strtolower($countryCode)) {
$shopLang = strtolower($countryCode);
Shopware()->Front()->Response()->setCookie('shopLang', $shopLang, 0);
$builder = Shopware()->Container()->get('dbal_connection')->createQueryBuilder();
$shopId = $builder->select('scs.id')->from('s_core_locales', 'scl')->innerJoin('scl', 's_core_shops', 'scs', 'scl.id = scs.locale_id')->where('scl.locale LIKE ?')->setParameter(0, $shopLang . '%')->execute()->fetch();
if ($shopId) {
$view->extendsTemplate('frontend/index/change_shop.tpl');
$view->assign(array('shopId' => $shopId['id']));
}
}
}
示例11: createS3Adapter
/**
* Creates adapter instance
*
* @param Enlight_Event_EventArgs $args
* @return AdapterInterface
*/
public function createS3Adapter(Enlight_Event_EventArgs $args)
{
$defaultConfig = ['key' => '', 'secret' => '', 'region' => '', 'version' => 'latest', 'bucket' => '', 'prefix' => ''];
$config = array_merge($defaultConfig, $args->get('config'));
$client = S3Client::factory(['credentials' => ['key' => $config['key'], 'secret' => $config['secret']], 'region' => $config['region'], 'version' => $config['version']]);
return new AwsS3Adapter($client, $config['bucket'], $config['prefix']);
}
示例12: testOnFilterCollectors
public function testOnFilterCollectors()
{
$container = Shopware()->Container();
$debug = $this->getDebugClass();
$eventManager = $container->get('events');
$utils = new Utils();
$arguments = new \Enlight_Event_EventArgs(['utils' => $utils, 'eventManager' => $eventManager]);
$arguments->setReturn([]);
$collectors = $debug->onFilterCollectors($arguments);
$this->assertCount(count($arguments->getReturn()), $collectors);
$arguments->setReturn([new EventCollector($eventManager, $utils)]);
$collectors = $debug->onFilterCollectors($arguments);
$this->assertCount(count($arguments->getReturn()), $collectors);
$this->assertInstanceOf('\\Shopware\\Plugins\\ShopwareClockwork\\Clockwork\\Components\\Collector\\EventCollector', $collectors[0]);
$arguments->setReturn([new TemplateCollector($container->get('template'), $utils, $container->get('kernel')->getRootDir())]);
$collectors = $debug->onFilterCollectors($arguments);
$this->assertCount(count($arguments->getReturn()), $collectors);
$this->assertInstanceOf('\\Shopware\\Plugins\\ShopwareClockwork\\Clockwork\\Components\\Collector\\TemplateCollector', $collectors[0]);
$arguments->setReturn([new EventCollector($eventManager, $utils), new TemplateCollector($container->get('template'), $utils, $container->get('kernel')->getRootDir())]);
$collectors = $debug->onFilterCollectors($arguments);
$this->assertCount(count($arguments->getReturn()), $collectors);
$this->assertInstanceOf('\\Shopware\\Plugins\\ShopwareClockwork\\Clockwork\\Components\\Collector\\EventCollector', $collectors[0]);
$this->assertInstanceOf('\\Shopware\\Plugins\\ShopwareClockwork\\Clockwork\\Components\\Collector\\TemplateCollector', $collectors[1]);
$info = [1, 2, 3];
$arguments->setReturn($info);
$collectors = $debug->onFilterCollectors($arguments);
$this->assertCount(count($arguments->getReturn()), $collectors);
$this->assertSame($info, $collectors);
}
示例13: onPostDispatch
/**
* Event listener method
*
* Read base controller data
*
* @param Enlight_Event_EventArgs $args
*/
public function onPostDispatch(Enlight_Event_EventArgs $args)
{
$request = $args->getSubject()->Request();
$response = $args->getSubject()->Response();
$view = $args->getSubject()->View();
if (!$request->isDispatched() || $response->isException() || $request->getModuleName() != 'frontend' || !$view->hasTemplate()) {
return;
}
$view->baseUrl = $request->getBaseUrl() . $request->getPathInfo();
$shop = Shopware()->Shop();
$view->Controller = $args->getSubject()->Request()->getControllerName();
$view->Shopware = Shopware();
$view->sBasketQuantity = $view->sBasketQuantity ?: 0;
$view->sBasketAmount = $view->sBasketAmount ?: 0;
$view->sNotesQuantity = $view->sNotesQuantity ?: 0;
$view->sUserLoggedIn = $view->sUserLoggedIn ?: false;
$view->Shop = $shop;
$view->Locale = $shop->getLocale()->getLocale();
$view->sCategoryStart = $shop->getCategory()->getId();
$view->sCategoryCurrent = $this->getCategoryCurrent($view->sCategoryStart);
$view->sCategories = $this->getCategories($view->sCategoryCurrent);
$view->sMainCategories = $view->sCategories;
$view->sOutputNet = Shopware()->Session()->sOutputNet;
$activePage = isset($view->sCustomPage['id']) ? $view->sCustomPage['id'] : null;
$view->sMenu = $this->getMenu($shop->getId(), $activePage);
$view->sShopname = Shopware()->Config()->shopName;
}
示例14: onPreDispatch
/**
* Called from the event manager before the dispatch process.
* Parse the json input data, when it was activated.
*
* @param Enlight_Event_EventArgs $args
* @return bool
*/
public function onPreDispatch(Enlight_Event_EventArgs $args)
{
/** @var $subject Enlight_Controller_Action */
$subject = $args->get('subject');
$request = $subject->Request();
// Parses the json input data, if the content type is correct
if ($this->parseInput === true && ($contentType = $request->getHeader('Content-Type')) !== false && strpos($contentType, 'application/json') === 0 && ($input = file_get_contents('php://input')) !== false) {
$input = Zend_Json::decode($input);
foreach ((array) $input as $key => $value) {
if ($value !== null) {
$request->setPost($key, $value);
}
}
}
// Parse the json Params
if (count($this->parseParams)) {
foreach ($this->parseParams as $Param) {
if (($value = $request->getParam($Param)) !== null) {
$value = Zend_Json::decode($value);
$request->setParam($Param, $value);
}
}
}
// Rests the configuration for the next dispatch
$this->parseInput = false;
$this->parseParams = array();
}
示例15: onDispatchEvent
/**
* Listener method for the Enlight_Controller_Front_PostDispatch event.
*
* @param Enlight_Event_EventArgs $args
* @return void
*/
public function onDispatchEvent(Enlight_Event_EventArgs $args)
{
if (!$args->getResponse()->isException()) {
return;
}
$exception = $args->getResponse()->getException();
$this->handleException($exception[0]);
}