/** * * @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; }
private function safeRead($socket, $size) { $buffer = ""; $count = 0; while ($count < $size) { if (feof($socket)) { return FALSE; } $chunk = $this->phpWrapper->fread($socket, $size - $count); $count += strlen($chunk); if ($chunk === FALSE) { return FALSE; } $buffer .= $chunk; } return $buffer; }
/** * Renders a view passing $viewState as view parameters. * * @param string|callable $view Full view name that follows class naming convention or function callback * @param array $viewState Array of view parameters. * @return string */ protected function renderView($template, $viewState) { if ($template === FALSE) { $viewOutput = ''; } elseif (is_callable($template)) { // Rendered by callback function $viewOutput = (string) call_user_func_array($template, $viewState); } elseif (is_string($template)) { $absoluteViewPath = call_user_func($this->getTemplateResolver(), $template); if (!$absoluteViewPath) { $this->getLog()->warning("Unable to load `{$template}`."); return ''; } // Rendered by PHP script ob_start(); $this->phpWrapper->phpInclude($absoluteViewPath, $viewState); $viewOutput = ob_get_contents(); ob_end_clean(); } else { throw new \UnexpectedValueException(sprintf("%s: wrong template type `%s`.", get_class($this), is_object($template) ? get_class($template) : gettype($template)), 1324479415); } return $viewOutput; }
public function phpInclude($filePath, $vars) { switch ($filePath) { case 'Nethgui\\Language\\xy\\Nethgui_Basic': $vars['L']['SYM_UNTRANSLATED'] = 'SYM_TRANSLATED1'; break; case 'Nethgui\\Language\\xy\\Nethgui_ModuleCatalog': $vars['L']['SYM_INTERPOLATE1'] = 'SYM_TRANSLATED3 ${0} ${1} ${2}'; $vars['L']['SYM_INTERPOLATE2'] = 'SYM_TRANSLATED4 ${:x} ${:y} ${:z}'; break; case 'Nethgui\\Language\\en\\Nethgui_ModuleCatalog': $vars['L']['SYM_ENGLISH_FALLBACK'] = 'SYM_TRANSLATED2'; break; case 'Nethgui\\Language\\xy\\Nethgui_ParentCatalog1': $vars['L']['FROM_PARENT_CATALOG1'] = 'SYM_TRANSLATED7a'; break; case 'Nethgui\\Language\\xy\\Nethgui_ParentCatalog2': $vars['L']['FROM_PARENT_CATALOG2'] = 'SYM_TRANSLATED7b'; break; default: return parent::phpInclude($filePath, $vars); } return TRUE; }
public function setLog(\Nethgui\Log\LogInterface $log) { $this->log = $log; $this->php->setLog($log); return $this; }