本文整理汇总了PHP中fajr\libfajr\base\Preconditions类的典型用法代码示例。如果您正苦于以下问题:PHP Preconditions类的具体用法?PHP Preconditions怎么用?PHP Preconditions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Preconditions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:36,代码来源:StudiumController.php
示例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;
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:12,代码来源:ArrayTrace.php
示例3: __construct
public function __construct(array $options, $cookieFile)
{
Preconditions::checkIsString($cookieFile, '$cookieFile should be string');
$this->options = $options;
$this->cookieFile = $cookieFile;
$this->_curlInit();
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:7,代码来源:CurlConnection.php
示例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;
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:10,代码来源:CosignProxyLogin.php
示例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;
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:10,代码来源:CosignProxyLogin.php
示例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);
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:44,代码来源:StudiumController.php
示例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;
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:36,代码来源:SecureRandom.php
示例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);
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:37,代码来源:BaseController.php
示例9: closeDialog
public function closeDialog($dialogUid)
{
Preconditions::checkContainsInteger($dialogUid);
if ($this->openedDialog != $dialogUid) {
throw new IllegalStateException("Zatváram zlý dialóg!");
}
$this->openedDialog = null;
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:8,代码来源:FakeAbstractScreen.php
示例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");
}
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:8,代码来源:PHPFile.php
示例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;
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:13,代码来源:DisplayManager.php
示例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];
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:14,代码来源:SkinSettings.php
示例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']);
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:17,代码来源:AIS2VersionParser.php
示例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'];
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:16,代码来源:Serializer.php
示例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'];
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:17,代码来源:AIS2UserNameParser.php
示例16: get
/**
* Get a value of a given key
* @param string $key
* @returns mixed value of a given key
* @throws InvalidArgumentException if the key does not exist
*/
public function get($key)
{
Preconditions::checkIsString($key);
// Note: isset() returns false if the item value is null
if (!array_key_exists($key, $this->config)) {
throw new InvalidArgumentException('Unknown configuration parameter: ' . $key);
}
return $this->config[$key];
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:15,代码来源:FajrConfig.php
示例17: getZoznamTerminovDialog
public function getZoznamTerminovDialog(Trace $trace, $predmetIndex)
{
Preconditions::checkContainsInteger($predmetIndex);
$data = $this->executor->readTable(array(), 'zapisanePredmety');
if (!array_key_exists($predmetIndex, $data)) {
throw new Exception("Zadaný predmet neexistuje!");
}
return new FakeTerminyDialogImpl($trace, $this, array('predmet' => $predmetIndex));
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:9,代码来源:FakeTerminyHodnoteniaScreenImpl.php
示例18: 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();
Preconditions::checkNotNull($request);
Preconditions::checkNotNull($response);
Preconditions::checkNotNull($session);
// check access to application
$apps = $session->read('ais/aisApps');
if (!is_array($apps)) {
throw new Exception("Interná chyba - zoznam AIS aplikácii je nekorektný.");
}
if (!in_array(AIS2ApplicationEnum::ADMINISTRACIA_STUDIA, $apps)) {
$response->setTemplate('studium/notAvailable');
return;
}
$screenFactory = $this->factory;
$adminStudia = $screenFactory->newAdministraciaStudiaScreen($trace);
$this->administraciaStudiaScreen = $adminStudia;
$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($trace, $response, 'zoznam studii', regression\ZoznamStudiiRegression::get(), $this->zoznamStudii->getTableDefinition());
FajrUtils::warnWrongTableStructure($trace, $response, 'zoznam zapisnych listov', regression\ZoznamZapisnychListovRegression::get(), $this->zapisneListy->getTableDefinition());
$zapisneListyData = $this->zapisneListy->getData();
if (count($zapisneListyData) == 0) {
$this->zapisnyList = null;
$this->terminyHodnoteniaScreen = null;
$this->hodnoteniaScreen = null;
} else {
$this->zapisnyList = $request->getParameter('list');
if ($this->zapisnyList === '') {
$lastList = end($zapisneListyData);
$this->zapisnyList = $lastList['index'];
}
$this->terminyHodnoteniaScreen = $screenFactory->newTerminyHodnoteniaScreen($trace, $adminStudia->getZapisnyListIdFromZapisnyListIndex($trace, $this->zapisnyList, VSES017\AdministraciaStudiaScreen::ACTION_TERMINY_HODNOTENIA), $adminStudia->getStudiumIdFromZapisnyListIndex($trace, $this->zapisnyList, VSES017\AdministraciaStudiaScreen::ACTION_TERMINY_HODNOTENIA));
// 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, VSES017\AdministraciaStudiaScreen::ACTION_HODNOTENIA_PRIEMERY));
}
$response->set('zoznamStudii', $this->zoznamStudii);
$response->set('studium', $this->studium);
$response->set('zapisneListy', $this->zapisneListy);
$response->set('zapisnyList', $this->zapisnyList);
if (array_key_exists($action, $this->actionInfo)) {
$info = $this->actionInfo[$action];
if ($info['requiresZapisnyList'] && $this->zapisnyList == null) {
$response->set('activeTab', $info['tabName']);
$response->setTemplate('studium/chybaZapisnyList');
return;
}
}
parent::invokeAction($trace, $action, $context);
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:66,代码来源:StudiumController.php
示例19: remove
/**
* Removes data from this storage.
*
* @param string $key key to the data
*
* @returns mixed data associated with the key
*/
public function remove($key)
{
Preconditions::checkIsString($key);
$retval = null;
if (array_key_exists($key, $this->data)) {
$retval = $this->data[$key];
unset($this->data[$key]);
}
return $retval;
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:17,代码来源:MemoryStorage.php
示例20: runInformacnyList
public function runInformacnyList(Trace $trace, Context $context)
{
$request = $context->getRequest();
$response = $context->getResponse();
$code = $request->getParameter('code');
Preconditions::check(!empty($code), "Nezadaný kód predmetu!");
$content = $this->registerPredmetovScreen->getInformacnyList($trace, $code);
$content = iconv("Windows-1250", "UTF-8", $content);
$response->setTemplate('predmety/informacnyList');
$response->set('content', $content);
}
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:11,代码来源:PredmetyController.php
注:本文中的fajr\libfajr\base\Preconditions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论