本文整理汇总了PHP中fajr\libfajr\base\Preconditions类的典型用法代码示例。如果您正苦于以下问题:PHP Preconditions类的具体用法?PHP Preconditions怎么用?PHP Preconditions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Preconditions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: invokeAction
/**
* Invoke an action given its name
*
* This function requests information necessary to operate on
* VSES017 AIS application
*
* @param Trace $trace trace object
* @param string $action action name
* @param Context $context fajr context
*/
public function invokeAction(Trace $trace, $action, Context $context)
{
$request = $context->getRequest();
$response = $context->getResponse();
Preconditions::checkIsString($action);
$this->screenFactory = new VSES017\VSES017_factory($context->getAisConnection());
$this->adminStudia = $this->screenFactory->newAdministraciaStudiaScreen($trace);
$this->studium = $request->getParameter('studium', '0');
$this->zoznamStudii = $this->adminStudia->getZoznamStudii($trace->addChild("Get Zoznam Studii:"));
$this->zapisneListy = $this->adminStudia->getZapisneListy($trace->addChild('getZapisneListy'), $this->studium);
$this->zapisnyList = $request->getParameter('list');
if (empty($this->zapisnyList)) {
$tmp = $this->zapisneListy->getData();
$lastList = end($tmp);
$this->zapisnyList = $lastList['index'];
}
$this->terminyHodnoteniaScreen = $this->screenFactory->newTerminyHodnoteniaScreen($trace, $this->adminStudia->getZapisnyListIdFromZapisnyListIndex($trace, $this->zapisnyList), $this->adminStudia->getStudiumIdFromZapisnyListIndex($trace, $this->zapisnyList));
// FIXME: chceme to nejak refaktorovat, aby sme nevytvarali zbytocne
// objekty, ktore v konstruktore robia requesty
$this->hodnoteniaScreen = $this->screenFactory->newHodnoteniaPriemeryScreen($trace, $this->adminStudia->getZapisnyListIdFromZapisnyListIndex($trace, $this->zapisnyList));
$response->set('zoznamStudii', $this->zoznamStudii);
$response->set('studium', $this->studium);
$response->set('zapisneListy', $this->zapisneListy);
$response->set('zapisnyList', $this->zapisnyList);
parent::invokeAction($trace, $action, $context);
}
示例2: addChild
/**
* Create a new ArrayTrace at the insertion point
* @param string $header text to use as header
* @return ArrayTrace child trace object
*/
public function addChild($header = "")
{
Preconditions::checkIsString($header, 'header');
$child = new ArrayTrace($this->timer, $header);
$this->children[] = array('info' => $this->getInfoArray(), 'type' => 'trace', 'trace' => $child);
return $child;
}
示例3: __construct
public function __construct(array $options, $cookieFile)
{
Preconditions::checkIsString($cookieFile, '$cookieFile should be string');
$this->options = $options;
$this->cookieFile = $cookieFile;
$this->_curlInit();
}
示例4: __construct
/**
* @param string $proxyDir path to directory containing cosign proxy files
*/
public function __construct($proxyDir, $proxyCookieName)
{
Preconditions::checkIsString($proxyDir, 'proxyDir');
Preconditions::checkIsString($proxyDir, 'proxyCookieName');
$this->proxyDir = $proxyDir;
$this->proxyCookieName = $proxyCookieName;
}
示例5: __construct
/**
* @param string $proxyDir path to directory containing cosign proxy files
*/
public function __construct($proxyDir, $proxyCookieName)
{
Preconditions::checkIsString($proxyDir, '$proxyDir should be string.');
Preconditions::checkIsString($proxyCookieName, '$proxyCookieName should be string');
$this->proxyDir = $proxyDir;
$this->proxyCookieName = $proxyCookieName;
}
示例6: invokeAction
/**
* Invoke an action given its name
*
* This function requests information necessary to operate on
* VSES017 AIS application
*
* @param Trace $trace trace object
* @param string $action action name
* @param Context $context fajr context
*/
public function invokeAction(Trace $trace, $action, Context $context)
{
Preconditions::checkIsString($action);
$request = $context->getRequest();
$response = $context->getResponse();
$session = $context->getSessionStorage();
// check access to application
if (!in_array(AIS2ApplicationEnum::ADMINISTRACIA_STUDIA, $session->read('ais/aisApps'))) {
$response->setTemplate('studium/notAvailable');
return;
}
$screenFactory = $this->factory;
$adminStudia = $screenFactory->newAdministraciaStudiaScreen($trace);
$this->studium = $request->getParameter('studium', '0');
$this->zoznamStudii = $adminStudia->getZoznamStudii($trace->addChild("Get Zoznam Studii:"));
$this->zapisneListy = $adminStudia->getZapisneListy($trace->addChild('getZapisneListy'), $this->studium);
FajrUtils::warnWrongTableStructure($response, 'zoznam studii', regression\ZoznamStudiiRegression::get(), $this->zoznamStudii->getTableDefinition());
FajrUtils::warnWrongTableStructure($response, 'zoznam zapisnych listov', regression\ZoznamZapisnychListovRegression::get(), $this->zapisneListy->getTableDefinition());
$this->zapisnyList = $request->getParameter('list');
if ($this->zapisnyList === '') {
$tmp = $this->zapisneListy->getData();
$lastList = end($tmp);
$this->zapisnyList = $lastList['index'];
}
$this->terminyHodnoteniaScreen = $screenFactory->newTerminyHodnoteniaScreen($trace, $adminStudia->getZapisnyListIdFromZapisnyListIndex($trace, $this->zapisnyList), $adminStudia->getStudiumIdFromZapisnyListIndex($trace, $this->zapisnyList));
// FIXME: chceme to nejak refaktorovat, aby sme nevytvarali zbytocne
// objekty, ktore v konstruktore robia requesty
$this->hodnoteniaScreen = $screenFactory->newHodnoteniaPriemeryScreen($trace, $adminStudia->getZapisnyListIdFromZapisnyListIndex($trace, $this->zapisnyList));
$response->set('zoznamStudii', $this->zoznamStudii);
$response->set('studium', $this->studium);
$response->set('zapisneListy', $this->zapisneListy);
$response->set('zapisnyList', $this->zapisnyList);
parent::invokeAction($trace, $action, $context);
}
示例7: randomBytes
/**
* Returns a securely generated random *bytes* using the supplied providers.
* Providers will be queried in the same order as the were given to constructor
* and first which will return random bytes will be used.
*
* @param int $count number of random bytes to be generated
*
* @returns bytes generated bytes
* @throws RuntimeException if any error occurs (or no provider returns random bytes)
* Warning: Never catch and ignore exceptions from this function!
*/
public function randomBytes($count)
{
Preconditions::check(is_int($count));
Preconditions::check($count > 0);
// TODO(ppershing): verify following claim
// Try the OpenSSL method first. This is the strongest.
$output = false;
foreach ($this->providers as $provider) {
$output = $provider->randomBytes($count);
if ($output !== false) {
break;
}
}
// No method was able to generate random bytes.
// Do not ignore this and throw security error as
// caller may forgot to check return value.
if ($output == false) {
throw new RuntimeException("Unable to generate random bytes.");
}
// internal check on sanity
if (strlen($output) != $count) {
throw new Exception("Wrong number random bytes were generated. " . "This may be a severe internal error in secure random.");
}
return $output;
}
示例8: invokeAction
/**
* Invoke an action given its name
*
* This function checks if public non-abstract non-static runAction method
* exists in this object and calls it in such a case with request and response
* parameters
*
* @param Trace $trace trace object
* @param string $action action name
* @param Context $context fajr context
*/
public function invokeAction(Trace $trace, $action, Context $context)
{
Preconditions::checkIsString($action);
Preconditions::checkMatchesPattern('@^[A-Z][a-zA-Z]*$@', $action, '$action must start with capital letter and ' . 'contain only letters.');
$methodName = 'run' . $action;
if (!method_exists($this, $methodName)) {
throw new Exception('Action method ' . $methodName . ' does not exist');
}
$method = new ReflectionMethod($this, $methodName);
if (!$method->isPublic()) {
throw new Exception('Action method ' . $methodName . ' is not public');
}
if ($method->isAbstract()) {
throw new Exception('Action method ' . $methodName . ' is abstract');
}
if ($method->isStatic()) {
throw new Exception('Action method ' . $methodName . ' is static');
}
if ($method->isConstructor()) {
throw new Exception('Action method ' . $methodName . ' is constructor');
}
if ($method->isDestructor()) {
throw new Exception('Action method ' . $methodName . ' is destructor');
}
$method->invoke($this, $trace, $context);
}
示例9: closeDialog
public function closeDialog($dialogUid)
{
Preconditions::checkContainsInteger($dialogUid);
if ($this->openedDialog != $dialogUid) {
throw new IllegalStateException("Zatváram zlý dialóg!");
}
$this->openedDialog = null;
}
示例10: write
public function write($string)
{
Preconditions::checkIsString($string, '$string must be string');
$this->checkNotClosed();
if (@fwrite($this->handle, $string) === false) {
throw new Exception("Cannot write file");
}
}
示例11: display
/**
* Generate a page content
* @param Response $response response data to use to generate output
* @return string Generated output to be sent to the browser
*/
public function display(Response $response)
{
Preconditions::checkNotNull($response->getTemplate(), "Template not set");
$templateName = 'pages/' . $response->getTemplate() . '.xhtml';
$template = $this->twig->loadTemplate($templateName);
$output = $template->render($response->getData());
return $output;
}
示例12: getSkinByName
/**
* @param string $name name of the skin to retrieve
*
* @returns SkinConfig
* @throws IllegalArgumentException
*/
public function getSkinByName($name)
{
Preconditions::checkIsString($name);
if (!in_array($name, array_keys($this->skins))) {
throw new IllegalArgumentException("You must specify a valid skin!");
}
return $this->skins[$name];
}
示例13: parseVersionStringFromMainPage
/**
* Parses the AIS2 version from html page.
*
* @param string $html AIS2 html reply to be parsed
*
* @returns AIS2Version AIS2 version
* @throws ParseException on error
*/
public function parseVersionStringFromMainPage($html)
{
Preconditions::checkIsString($html);
$data = StrUtil::matchAll(self::VERSION_PATTERN, $html);
if ($data === false) {
throw new ParseException("Cannot parse AIS version from response.");
}
return new AIS2Version(2, $data['major'], $data['minor'], $data['patch']);
}
示例14: deserialize
/**
* Deserialize previously serialized value.
*
* @param string $data
*
* @returns mixed deserialized value
*/
public static function deserialize($data)
{
Preconditions::checkIsString($data);
$result = @unserialize($data);
if ($result == false || !array_key_exists('value', $result)) {
throw new InvalidArgumentException("Invalid data to deserialize.");
}
return $result['value'];
}
示例15: parseUserNameFromMainPage
/**
* Parses user name from AIS2 start page
*
* @param string $html AIS2 html reply to be parsed
*
* @returns AIS2Version AIS2 version
* @throws ParseException on error
*/
public function parseUserNameFromMainPage($html)
{
Preconditions::checkIsString($html);
$data = StrUtil::matchAll(self::USERNAME_PATTERN, $html);
if ($data === false) {
throw new ParseException("Cannot parse username from response.");
}
return $data['username'];
}