当前位置: 首页>>代码示例>>PHP>>正文


PHP CakeEvent::stopPropagation方法代码示例

本文整理汇总了PHP中CakeEvent::stopPropagation方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeEvent::stopPropagation方法的具体用法?PHP CakeEvent::stopPropagation怎么用?PHP CakeEvent::stopPropagation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CakeEvent的用法示例。


在下文中一共展示了CakeEvent::stopPropagation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testPropagation

 /**
  * Tests the event propagation stopping property
  *
  * @return void
  * @triggers fake.event
  */
 public function testPropagation()
 {
     $event = new CakeEvent('fake.event');
     $this->assertFalse($event->isStopped());
     $event->stopPropagation();
     $this->assertTrue($event->isStopped());
 }
开发者ID:keetamhoang,项目名称:lotdephong,代码行数:13,代码来源:CakeEventTest.php

示例2: beforeDispatch

 public function beforeDispatch(CakeEvent $event)
 {
     $MaintenanceMode = Configure::read('MaintenanceMode');
     /* Not in maintenance mode*/
     if (!$MaintenanceMode['enabled']) {
         return;
     }
     /* Allow access from following IPS*/
     if (!empty($MaintenanceMode['ip_filters'])) {
         if (!is_array($MaintenanceMode['ip_filters'])) {
             $ips = array($MaintenanceMode['ip_filters']);
         } else {
             $ips = $MaintenanceMode['ip_filters'];
         }
         $userIP = $this->_getUserIpAddr();
         foreach ($ips as $ip) {
             if ($this->_compareIp($userIP, $ip)) {
                 return;
             }
         }
     }
     $statusCode = 503;
     $body = 'Currently undergoing maintenance';
     if (!empty($MaintenanceMode['code'])) {
         $statusCode = $MaintenanceMode['code'];
     }
     if (!empty($MaintenanceMode['view']['template'])) {
         $View = $this->_getView();
         $body = $View->render($MaintenanceMode['view']['template'], $MaintenanceMode['view']['layout']);
     }
     $event->data['response']->statusCode($statusCode);
     $event->data['response']->body($body);
     $event->stopPropagation();
     return $event->data['response'];
 }
开发者ID:awebdeveloper,项目名称:cakephp-maintenance-mode,代码行数:35,代码来源:MaintenanceMode.php

示例3: beforeDispatch

 /**
  * Checks whether the response was cached and set the body accordingly.
  *
  * @param CakeEvent $event containing the request and response object
  * @return CakeResponse with cached content if found, null otherwise
  */
 public function beforeDispatch(CakeEvent $event)
 {
     if (Configure::read('Cache.check') !== true) {
         return;
     }
     $path = $event->data['request']->here();
     if ($path === '/') {
         $path = 'home';
     }
     $prefix = Configure::read('Cache.viewPrefix');
     if ($prefix) {
         $path = $prefix . '_' . $path;
     }
     $path = strtolower(Inflector::slug($path));
     $filename = CACHE . 'views' . DS . $path . '.php';
     if (!file_exists($filename)) {
         $filename = CACHE . 'views' . DS . $path . '_index.php';
     }
     if (file_exists($filename)) {
         $controller = null;
         $view = new View($controller);
         $result = $view->renderCache($filename, microtime(true));
         if ($result !== false) {
             $event->stopPropagation();
             $event->data['response']->body($result);
             return $event->data['response'];
         }
     }
 }
开发者ID:ophilli,项目名称:Inventory,代码行数:35,代码来源:CacheDispatcher.php

示例4: beforeDispatch

 /**
  * Checks if a requested asset exists and sends it to the browser
  *
  * @param CakeEvent $event containing the request and response object
  * @return mixed The resulting response.
  * @throws NotFoundException When asset not found
  */
 public function beforeDispatch(CakeEvent $event)
 {
     $url = urldecode($event->data['request']->url);
     if (strpos($url, '..') !== false || strpos($url, '.') === false) {
         return;
     }
     // CUSTOMIZE DELETE 2014/07/02 ryuring
     // >>>
     /*if ($result = $this->_filterAsset($event)) {
     			$event->stopPropagation();
     			return $result;
     		}*/
     // <<<
     $assetFile = $this->_getAssetFile($url);
     if ($assetFile === null || !file_exists($assetFile)) {
         return null;
     }
     $response = $event->data['response'];
     $event->stopPropagation();
     $response->modified(filemtime($assetFile));
     if ($response->checkNotModified($event->data['request'])) {
         return $response;
     }
     $pathSegments = explode('.', $url);
     $ext = array_pop($pathSegments);
     $this->_deliverAsset($response, $assetFile, $ext);
     return $response;
 }
开发者ID:kenz,项目名称:basercms,代码行数:35,代码来源:BcAssetDispatcher.php

示例5: beforeDispatch

/**
 * Checks if request is for a compiled asset, otherwise skip any operation
 *
 * @param CakeEvent $event containing the request and response object
 * @throws NotFoundException
 * @return CakeResponse if the client is requesting a recognized asset, null otherwise
 */
	public function beforeDispatch(CakeEvent $event) {
		$url = $event->data['request']->url;
		$Config = $this->_getConfig();
		$production = !Configure::read('debug');
		if ($production && !$Config->general('alwaysEnableController')) {
			return;
		}

		$build = $this->_getBuild($url);
		if ($build === false) {
			return;
		}

		if (isset($event->data['request']->query['theme'])) {
			$Config->theme($event->data['request']->query['theme']);
		}

		// Dynamically defined build file. Disabled in production for
		// hopefully obvious reasons.
		if ($Config->files($build) === array()) {
			$files = array();
			if (isset($event->data['request']->query['file'])) {
				$files = $event->data['request']->query['file'];
			}
			$Config->files($build, $files);
		}

		try {
			$Compiler = new AssetCompiler($Config);
			$mtime = $Compiler->getLastModified($build);
			$event->data['response']->modified($mtime);
			if ($event->data['response']->checkNotModified($event->data['request'])) {
				$event->stopPropagation();
				return $event->data['response'];
			}
			$contents = $Compiler->generate($build);
		} catch (Exception $e) {
			throw new NotFoundException($e->getMessage());
		}

		$event->data['response']->type($Config->getExt($build));
		$event->data['response']->body($contents);
		$event->stopPropagation();
		return $event->data['response'];
	}
开发者ID:renan,项目名称:asset_compress,代码行数:52,代码来源:AssetCompressor.php

示例6: beforeDispatch

 public function beforeDispatch(CakeEvent $event)
 {
     if (!preg_match("/media\\/router\\/index\\//i", $event->data['request']->url)) {
         return;
     }
     $event->stopPropagation();
     $requestData = $event->data['request']->params;
     list($type, $id, $size, $filename) = $requestData['pass'];
     App::uses('MediaPath', 'Media.Vendor');
     $this->PHMedia = new MediaPath();
     $fname = $this->PHMedia->getFileName($type, $id, $size, $filename);
     $aFName = $this->PHMedia->getFileInfo($filename);
     $response = $event->data['response'];
     if (!file_exists($fname)) {
         $this->_processMedia($requestData['pass'], $fname, $aFName);
     }
     $this->_deliverMedia($response, $fname, $aFName);
     return $response;
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:19,代码来源:MediaDispatcher.php

示例7: beforeDispatch

 /**
  * Handle OPTIONS requests
  *
  * If it's an options request, loop on the configured http verbs and add
  * an Access-Control-Allow-Methods header with the verbs the application
  * is configured to respond to.
  *
  * @param CakeEvent $event
  * @return CakeResponse|null
  */
 public function beforeDispatch(CakeEvent $event)
 {
     $request = $event->data['request'];
     if (!$request->is('options')) {
         return;
     }
     $event->stopPropagation();
     $url = $request->url;
     $verbs = Configure::read('Crud.HttpMethodFilter.verbs') ?: $this->defaultVerbs;
     $allowedMethods = array();
     foreach ($verbs as $verb) {
         $_SERVER['REQUEST_METHOD'] = $verb;
         if (Router::parse('/' . $url)) {
             $allowedMethods[] = $verb;
         }
     }
     $_SERVER['REQUEST_METHOD'] = 'OPTIONS';
     $response = $event->data['response'];
     $response->header('Access-Control-Allow-Methods', implode(', ', $allowedMethods));
     return $response;
 }
开发者ID:linking-arts,项目名称:furry-goggles,代码行数:31,代码来源:HttpMethodFilter.php

示例8: beforeDispatch

 /**
  * Before Dispatch - Set CORS access control headers
  * 
  * @author	Anthony Putignano <anthony@wizehive.com>
  * @since	1.0
  * @param	CakeEvent		$event
  * @return	CakeResponse
  */
 public function beforeDispatch(CakeEvent $event)
 {
     $request = $event->data['request'];
     $response = $event->data['response'];
     $origin = !empty($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '*';
     $response->header('Access-Control-Allow-Origin: ' . $origin);
     $response->header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
     if (!empty($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
         $response->header('Access-Control-Allow-Headers: ' . $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
     }
     // Currently exit on all OPTIONS requests
     // Fix for swagger-ui CORS preflight requests
     if ($request->is('OPTIONS')) {
         if (defined('ENVIRONMENT') && ENVIRONMENT === 'development') {
             $response->header('Cache-Control: no-cache');
         } else {
             $response->header('Cache-Control: max-age=3600');
         }
         $event->stopPropagation();
         return $response;
     }
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:30,代码来源:ApiCorsPreflightDispatcher.php

示例9: beforeDispatch

 /**
  * Inspects the requests and if the url is the one set for processing the Sendgrid
  * webhook, it will convert the payload to one or several SendgridEvent objects and
  * trigger the configured callback for each one of them.
  *
  * @param CakeEvent $event
  * @return CakeResponse
  */
 public function beforeDispatch(CakeEvent $event)
 {
     $config = Configure::read('Dispatcher.filters.GridHook');
     $endpoint = '/webhook/sendgrid';
     if (!empty($config['endpoint'])) {
         $endpoint = $config['endpoint'];
     }
     $request = $event->data['request'];
     $response = $event->data['response'];
     if ('/' . $request->url !== $endpoint || !$request->is('post')) {
         return;
     }
     $callable = $config['handler'];
     if (!is_callable($callable)) {
         throw new InvalidArgumentException('Not a valid handler for sendgrid webhooks');
     }
     $data = ['events' => json_decode($request->input(), true), 'meta' => ['relay' => $request->query('relay')]];
     $this->_trigger($callable, $data);
     $response->statusCode(200);
     $event->stopPropagation();
     return $response;
 }
开发者ID:lorenzo,项目名称:cakephp-gridhook,代码行数:30,代码来源:SendgridWebhookDispatcher.php

示例10: beforeDispatch

 /**
  * Checks whether the response was cached and set the body accordingly.
  *
  * @param CakeEvent $event containing the request and response object
  * @return CakeResponse with cached content if found, null otherwise
  */
 public function beforeDispatch(CakeEvent $event)
 {
     if (Configure::read('Cache.check') !== true) {
         return null;
     }
     // CUSTOMIZE 2014/08/11 ryuring
     // $this->request->here で、URLを取得する際、URL末尾の 「index」の有無に関わらず
     // 同一ファイルを参照すべきだが、別々のURLを出力してしまう為、
     // 正規化された URLを取得するメソッドに変更
     // >>>
     //$path = $event->data['request']->here();
     // ---
     $path = $event->data['request']->normalizedHere();
     // <<<
     if ($path === '/') {
         $path = 'index';
     }
     $prefix = Configure::read('Cache.viewPrefix');
     if ($prefix) {
         $path = $prefix . '_' . $path;
     }
     $path = strtolower(Inflector::slug($path));
     $filename = CACHE . 'views' . DS . $path . '.php';
     if (!file_exists($filename)) {
         $filename = CACHE . 'views' . DS . $path . '_index.php';
     }
     if (file_exists($filename)) {
         $controller = null;
         $view = new View($controller);
         $view->response = $event->data['response'];
         $result = $view->renderCache($filename, microtime(true));
         if ($result !== false) {
             $event->stopPropagation();
             $event->data['response']->body($result);
             return $event->data['response'];
         }
     }
 }
开发者ID:baserproject,项目名称:basercms,代码行数:44,代码来源:BcCacheDispatcher.php

示例11: stopListener

 /**
  * Auxiliary function to help in stopPropagation testing
  *
  * @param CakeEvent $event        	
  * @return void
  */
 public function stopListener($event)
 {
     $event->stopPropagation();
 }
开发者ID:julkar9,项目名称:gss,代码行数:10,代码来源:CakeEventManagerTest.php

示例12: beforeDispatch

 public function beforeDispatch(CakeEvent $event)
 {
     $event->data['response']->statusCode(500);
     $event->stopPropagation();
     return $event->data['response'];
 }
开发者ID:SebFav,项目名称:ApplicationInternet2,代码行数:6,代码来源:Test2DispatcherFilter.php

示例13: testStopPropagation

 public function testStopPropagation()
 {
     $this->event->stopPropagation(false);
     $this->assertFalse($this->event->isStopped());
 }
开发者ID:gianarb,项目名称:penny,代码行数:5,代码来源:CakeHttpFlowEventTest.php

示例14: imagePath

 /**
  * Generates the path the image depending on the storage adapter
  *
  * @param CakeEvent $Event
  * @return void
  */
 public function imagePath($Event)
 {
     if ($Event->data['image']['adapter'] == 'Local') {
         $Helper = $Event->subject();
         extract($Event->data);
         $path = $this->_buildPath($image, true, $hash);
         $Event->data['path'] = $path;
         $Event->stopPropagation();
     }
 }
开发者ID:arourke,项目名称:cakephp-file-storage,代码行数:16,代码来源:LocalImageProcessingListener.php

示例15: setFlash

 /**
  * setFlash
  *
  * An API request doesn't need flash messages - so stop them being processed
  *
  * @param CakeEvent $event
  */
 public function setFlash(CakeEvent $event)
 {
     $event->stopPropagation();
 }
开发者ID:linking-arts,项目名称:furry-goggles,代码行数:11,代码来源:ApiListener.php


注:本文中的CakeEvent::stopPropagation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。