/** * * @param string $policyName * @return JsonPolicyDecisionPoint */ public function loadPolicy($policyName) { $policyFileSpec = call_user_func($this->fileNameResolver, $policyName); if (strpos($policyFileSpec, '*') === FALSE) { $policyFiles = array($policyFileSpec); } else { $policyFiles = $this->phpWrapper->glob($policyFileSpec); if ($policyFiles === FALSE) { $this->getLog()->warning(sprintf('%s: invalid policy file specification `%s`', __CLASS__, $policyFileSpec)); $policyFiles = array(); } } foreach ($policyFiles as $policyFile) { $data = $this->phpWrapper->file_get_contents($policyFile); $this->loadJsonString(basename($policyFile), $data); } return $this; }
public function getRunningTasks() { $running = array(); $pattern = '|' . sprintf(preg_quote(self::PTRACK_PATH_TEMPLATE, '|'), "(?P<taskId>[^.]+)") . '|'; foreach ($this->phpWrapper->glob(sprintf(self::PTRACK_PATH_TEMPLATE, '*')) as $socketPath) { $matches = array(); if (preg_match($pattern, $socketPath, $matches) && isset($matches['taskId'])) { try { $task = $this->getTaskStatus($matches['taskId']); } catch (\RuntimeException $ex) { $this->log->exception($ex); $this->phpWrapper->unlink($socketPath); continue; } $running[$matches['taskId']] = $task; } } return $running; }