/** * @param string $appName * @param IRequest $request * @param IL10N $l10n * @param IConfig $config * @param ICacheFactory $cache */ public function __construct($appName, IRequest $request, IL10N $l10n, IConfig $config, ICacheFactory $cache) { parent::__construct($appName, $request); $this->l10n = $l10n; $this->config = $config; $this->cache = $cache->create($appName); }
/** * @param EnvironmentHelper $environmentHelper * @param FileAccessHelper $fileAccessHelper * @param AppLocator $appLocator * @param IConfig $config * @param ICacheFactory $cacheFactory * @param IAppManager $appManager */ public function __construct(EnvironmentHelper $environmentHelper, FileAccessHelper $fileAccessHelper, AppLocator $appLocator, IConfig $config = null, ICacheFactory $cacheFactory, IAppManager $appManager = null) { $this->environmentHelper = $environmentHelper; $this->fileAccessHelper = $fileAccessHelper; $this->appLocator = $appLocator; $this->config = $config; $this->cache = $cacheFactory->create(self::CACHE_KEY); $this->appManager = $appManager; }
/** * @param string $appName * @param IRequest $request * @param IL10N $l10n * @param IConfig $config * @param ICacheFactory $cache * @param INavigationManager $navigationManager * @param IAppManager $appManager * @param OCSClient $ocsClient */ public function __construct($appName, IRequest $request, IL10N $l10n, IConfig $config, ICacheFactory $cache, INavigationManager $navigationManager, IAppManager $appManager, OCSClient $ocsClient) { parent::__construct($appName, $request); $this->l10n = $l10n; $this->config = $config; $this->cache = $cache->create($appName); $this->navigationManager = $navigationManager; $this->appManager = $appManager; $this->ocsClient = $ocsClient; }
public function __construct($appName, IRequest $request, IConfig $settings, AppConfig $appConfig, IL10N $l10n, $uid, ICacheFactory $cache, ILogger $logger) { parent::__construct($appName, $request); $this->uid = $uid; $this->l10n = $l10n; $this->settings = $settings; $this->appConfig = $appConfig; $this->cache = $cache->create($appName); $this->logger = $logger; }
protected function setUp() { parent::setUp(); $this->userSession = $this->getMock('\\OCP\\IUserSession'); $this->groupManager = $this->getMock('\\OCP\\IGroupManager'); $this->appConfig = $this->getAppConfig(); $this->cacheFactory = $this->getMock('\\OCP\\ICacheFactory'); $this->cache = $this->getMock('\\OCP\\ICache'); $this->cacheFactory->expects($this->any())->method('create')->with('settings')->willReturn($this->cache); $this->manager = new \OC\App\AppManager($this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory); }
public function setUp() { parent::setUp(); $this->environmentHelper = $this->getMock('\\OC\\IntegrityCheck\\Helpers\\EnvironmentHelper'); $this->fileAccessHelper = $this->getMock('\\OC\\IntegrityCheck\\Helpers\\FileAccessHelper'); $this->appLocator = $this->getMock('\\OC\\IntegrityCheck\\Helpers\\AppLocator'); $this->config = $this->getMock('\\OCP\\IConfig'); $this->cacheFactory = $this->getMock('\\OCP\\ICacheFactory'); $this->appManager = $this->getMock('\\OCP\\App\\IAppManager'); $this->cacheFactory->expects($this->any())->method('create')->with('oc.integritycheck.checker')->will($this->returnValue(new NullCache())); $this->checker = new Checker($this->environmentHelper, $this->fileAccessHelper, $this->appLocator, $this->config, $this->cacheFactory, $this->appManager); }
/** * @param string $url * @return bool */ private function testRemoteUrl($url) { $cache = $this->memcacheFactory->create('files_sharing_remote_url'); if ($result = $cache->get($url)) { return (bool) $result; } $result = file_get_contents($url); $data = json_decode($result); $returnValue = (is_object($data) and !empty($data->version)); $cache->set($url, $returnValue); return $returnValue; }
/** * This function can't work properly. * You can't get the cache instance within the cron because no user is connected. * Possible solution: access the cache directly in the filesystem */ private function updateFriends() { $users = \OC::$server->getUserManager()->search(''); $cache = \OCP\ICacheFactory::create('test'); $datadir = \OCP\Config::getSystemValue('datadirectory'); \OCP\Util::writeLog('fbsync', "Cron launched: caching friends...", \OCP\Util::INFO); foreach ($users as $user) { $fbsync = new FacebookController('fbsync', $cache, $datadir . '/' . $user->getUID()); $friends = $fbsync->reload(); if (!$friends) { \OCP\Util::writeLog('fbsync', "Failed to update friends cache for user " . $user->getUID(), \OCP\Util::INFO); } else { \OCP\Util::writeLog('fbsync', count($friends) . " cached for user " . $user->getUID(), \OCP\Util::INFO); } } \OCP\Util::writeLog('fbsync', "Cron finished.", \OCP\Util::INFO); }
/** * Creates path to an image * @param string $app app * @param string $image image name * @throws \RuntimeException If the image does not exist * @return string the url * * Returns the path to the image. */ public function imagePath($app, $image) { $cache = $this->cacheFactory->create('imagePath'); $cacheKey = $app . '-' . $image; if ($key = $cache->get($cacheKey)) { return $key; } // Read the selected theme from the config file $theme = \OC_Util::getTheme(); //if a theme has a png but not an svg always use the png $basename = substr(basename($image), 0, -4); $appPath = \OC_App::getAppPath($app); // Check if the app is in the app folder $path = ''; if (file_exists(\OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/img/{$image}")) { $path = \OC::$WEBROOT . "/themes/{$theme}/apps/{$app}/img/{$image}"; } elseif (!file_exists(\OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/img/{$basename}.png")) { $path = \OC::$WEBROOT . "/themes/{$theme}/apps/{$app}/img/{$basename}.png"; } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/{$theme}/{$app}/img/{$image}")) { $path = \OC::$WEBROOT . "/themes/{$theme}/{$app}/img/{$image}"; } elseif (!empty($app) and !file_exists(\OC::$SERVERROOT . "/themes/{$theme}/{$app}/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/themes/{$theme}/{$app}/img/{$basename}.png")) { $path = \OC::$WEBROOT . "/themes/{$theme}/{$app}/img/{$basename}.png"; } elseif (file_exists(\OC::$SERVERROOT . "/themes/{$theme}/core/img/{$image}")) { $path = \OC::$WEBROOT . "/themes/{$theme}/core/img/{$image}"; } elseif (!file_exists(\OC::$SERVERROOT . "/themes/{$theme}/core/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/themes/{$theme}/core/img/{$basename}.png")) { $path = \OC::$WEBROOT . "/themes/{$theme}/core/img/{$basename}.png"; } elseif ($appPath && file_exists($appPath . "/img/{$image}")) { $path = \OC_App::getAppWebPath($app) . "/img/{$image}"; } elseif ($appPath && !file_exists($appPath . "/img/{$basename}.svg") && file_exists($appPath . "/img/{$basename}.png")) { $path = \OC_App::getAppWebPath($app) . "/img/{$basename}.png"; } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/{$app}/img/{$image}")) { $path = \OC::$WEBROOT . "/{$app}/img/{$image}"; } elseif (!empty($app) and !file_exists(\OC::$SERVERROOT . "/{$app}/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/{$app}/img/{$basename}.png")) { $path = \OC::$WEBROOT . "/{$app}/img/{$basename}.png"; } elseif (file_exists(\OC::$SERVERROOT . "/core/img/{$image}")) { $path = \OC::$WEBROOT . "/core/img/{$image}"; } elseif (!file_exists(\OC::$SERVERROOT . "/core/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/core/img/{$basename}.png")) { $path = \OC::$WEBROOT . "/themes/{$theme}/core/img/{$basename}.png"; } if ($path !== '') { $cache->set($cacheKey, $path); return $path; } else { throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT); } }
/** * @param string $url * @return bool */ private function testRemoteUrl($url) { $cache = $this->memcacheFactory->create('files_sharing_remote_url'); if ($cache->hasKey($url)) { return (bool) $cache->get($url); } $client = $this->httpClient->newClient(); try { $result = $client->get($url, ['timeout' => 10, 'connect_timeout' => 10])->getBody(); $data = json_decode($result); $returnValue = is_object($data) && !empty($data->version); } catch (ConnectException $e) { $returnValue = false; } catch (ClientException $e) { $returnValue = false; } $cache->set($url, $returnValue); return $returnValue; }
/** * @return Horde_Imap_Client_Socket */ public function getImapConnection() { if (is_null($this->client)) { $host = $this->account->getInboundHost(); $user = $this->account->getInboundUser(); $password = $this->account->getInboundPassword(); $password = $this->crypto->decrypt($password); $port = $this->account->getInboundPort(); $ssl_mode = $this->convertSslMode($this->account->getInboundSslMode()); $params = ['username' => $user, 'password' => $password, 'hostspec' => $host, 'port' => $port, 'secure' => $ssl_mode, 'timeout' => 20]; if ($this->config->getSystemValue('app.mail.imaplog.enabled', false)) { $params['debug'] = $this->config->getSystemValue('datadirectory') . '/horde.log'; } if ($this->config->getSystemValue('app.mail.server-side-cache.enabled', false)) { if ($this->memcacheFactory->isAvailable()) { $params['cache'] = ['backend' => new Cache(array('cacheob' => $this->memcacheFactory->create(md5($this->getId() . $this->getEMailAddress()))))]; } } $this->client = new \Horde_Imap_Client_Socket($params); $this->client->login(); } return $this->client; }
/** * Clear the cached list of apps when enabling/disabling an app */ public function clearAppsCache() { $settingsMemCache = $this->memCacheFactory->create('settings'); $settingsMemCache->clear('listApps'); }
/** * @param ICacheFactory $cacheFactory * @param IClientService $clientService */ public function __construct(ICacheFactory $cacheFactory, IClientService $clientService) { $this->cache = $cacheFactory->create('ocs-discovery'); $this->client = $clientService->newClient(); }
/** * @param Subscription $subscriptions * @param IL10N $l10n * @param ICacheFactory $cacheFactory */ public function __construct(Subscription $subscriptions, IL10N $l10n, ICacheFactory $cacheFactory) { $this->subscriptions = $subscriptions; $this->l10n = $l10n; $this->cache = $cacheFactory->create(self::MEMCACHEID); }