apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php
/**
	 * Check if sharing is enabled before the controllers is executed
	 *
	 * @param \OCP\AppFramework\Controller $controller
	 * @param string $methodName
	 * @throws NotFoundException
	 * @throws S2SException
	 */
Check if sharing is enabled before the controllers is executed
@param \OCP\AppFramework\Controller $controller
@param string $methodName
@throws NotFoundException
@throws S2SException
Check if sharing is enabled before the controllers is executed @param \ OCP \ AppFramework \ Controller $controller @param string $methodName @throws NotFoundException @throws S2SException
public function beforeController($controller, $methodName) {
		if(!$this->isSharingEnabled()) {
			throw new NotFoundException('Sharing is disabled.');
		}
		if ($controller instanceof ExternalSharesController &&
			!$this->externalSharesChecks()) {
			throw new S2SException('Federated sharing not allowed');
		} else if ($controller instanceof ShareController) {
			$token = $this->request->getParam('token');
			$share = $this->shareManager->getShareByToken($token);
			if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK
				&& !$this->isLinkSharingEnabled()) {
				throw new NotFoundException('Link sharing is disabled');
			}
		}
	}
public function beforeController ( $ controller , $ methodName ) { if ( ! $ this -> isSharingEnabled ( ) ) { throw new NotFoundException ( 'Sharing is disabled.' ) ; } if ( $ controller instanceof ExternalSharesController && ! $ this -> externalSharesChecks ( ) ) { throw new S2SException ( 'Federated sharing not allowed' ) ; } else if ( $ controller instanceof ShareController ) { $ token = $ this -> request -> getParam ( 'token' ) ; $ share = $ this -> shareManager -> getShareByToken ( $ token ) ; if ( $ share -> getShareType ( ) === \ OCP \ Share :: SHARE_TYPE_LINK && ! $ this -> isLinkSharingEnabled ( ) ) { throw new NotFoundException ( 'Link sharing is disabled' ) ; } } }
Check if sharing is enabled before the controllers is executed
 @param \OCP\AppFramework\Controller $controller
 @param string $methodName
 @throws NotFoundException
 @throws S2SException
Check if sharing is enabled before the controllers is executed @param \ OCP \ AppFramework \ Controller $controller @param string $methodName @throws NotFoundException @throws S2SException