本文整理汇总了PHP中Environment::getService方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::getService方法的具体用法?PHP Environment::getService怎么用?PHP Environment::getService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Environment
的用法示例。
在下文中一共展示了Environment::getService方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ln
/**
* Sets the current sheet. Default is 'main'.
* @param string $sheet
* @return
*/
public static function ln($sheet)
{
if (self::$translator === NULL) {
self::$translator = Environment::getService('ITranslator');
}
return self::$translator->setCurrentSheet($sheet);
}
示例2: authenticate
public function authenticate(array $credentials)
{
$login = $credentials['username'];
$password = $this->phash($credentials['password']);
$super_admin = Environment::getVariable('admin');
if ($login == $super_admin['login']) {
if ($password == $super_admin['password']) {
$super_admin['roles'] = array('super admin');
$super_admin['id'] = 0;
$row = new DibiRow($super_admin);
MokujiServiceLocator::addService('UserAuthorizator', new Admin_UserModel());
} else {
throw new AuthenticationException("Invalid password.", self::INVALID_CREDENTIAL);
}
} else {
try {
$login_manager = Environment::getService('UserAuthenticator');
$row = $login_manager->authenticate($credentials);
} catch (InvalidStateException $e) {
throw new AuthenticationException("Login and password combination failed.", self::INVALID_CREDENTIAL);
}
}
$identity = new Identity($row->id, $row->roles, $row);
$identity->id = $row->id;
return $identity;
}
示例3: gatherActions
private function gatherActions()
{
$service = Environment::getService('Nette\\Loaders\\RobotLoader');
$class_list = $service->list;
$actions = array();
foreach ($class_list as $class => $file) {
//zachtime annotation exception lebo nette si generuje nejake annotation claasy do robotloodera
try {
$r = new ReflectionClass($class);
if ($r->isSubclassOf('Admin_SecurePresenter') && $r->getName() != 'BaseModulePresenter') {
$methods = $r->getMethods(ReflectionMethod::IS_PUBLIC);
foreach ($methods as $method) {
if (String::lower($method->class) == $class) {
if (strpos($method->getName(), 'action') !== false || strpos($method->getName(), 'handle') !== false) {
$actions[$class][] = $method->getName();
}
}
}
}
} catch (ReflectionException $e) {
}
}
$actions = array_merge($actions, Environment::getApplication()->getModulesPermissions());
$model = new UsersModuleModel();
$model->saveActions($actions);
return $actions;
}
示例4: startup
public function startup()
{
parent::startup();
if (!isset($this->lang)) {
$this->lang = $this->getHttpRequest()->detectLanguage($this->langs);
if ($this->lang == null) {
$this->lang = 'en';
}
$this->canonicalize();
}
$this->translator = Environment::getService('Mokuji\\Translator\\Admin');
$this->translator->lang = $this->lang;
//$this->translator = new Admin_Translator($this->lang);
$cache = Environment::getCache('langs');
$langs = $cache->offsetGet('langs');
if ($langs == NULL) {
$this->langs = $this->translator->getSupportedLangs();
//$this->model('lang')->getAll();
$cache->save('langs', $this->langs);
} else {
$this->langs = $langs;
}
$this->refreshConfig();
}
示例5: getAuthorizationHandler
/**
* Returns current authorization handler.
* @return IAuthorizator
*/
public final function getAuthorizationHandler()
{
if ($this->authorizationHandler === NULL) {
$this->authorizationHandler = Environment::getService('Nette\\Security\\IAuthorizator');
}
return $this->authorizationHandler;
}
示例6: actionPreview
/**
* Texyla preview
*/
public function actionPreview()
{
$texy = Environment::getService("Texy");
$html = $texy->process(Environment::getHttpRequest()->getPost("texy"));
$this->terminate(new RenderResponse($html));
}
示例7: getTranslator
public function getTranslator()
{
if (is_null($this->translator)) {
$this->translator = Environment::getService('Nette\\ITranslator');
}
return $this->translator;
}
示例8: getJournal
/**
* Returns the ICacheJournal
* @return ICacheJournal
*/
protected function getJournal()
{
if ($this->journal === NULL) {
$this->journal = Environment::getService('Nette\\Caching\\ICacheJournal');
}
return $this->journal;
}