當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Environment::getService方法代碼示例

本文整理匯總了PHP中Nette\Environment::getService方法的典型用法代碼示例。如果您正苦於以下問題:PHP Environment::getService方法的具體用法?PHP Environment::getService怎麽用?PHP Environment::getService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nette\Environment的用法示例。


在下文中一共展示了Environment::getService方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getCache

 /**
  * @return Cache
  */
 protected static function getCache()
 {
     if (self::$cache === NULL) {
         self::$cache = \Nette\Environment::getService('webloader.cache');
     }
     return self::$cache;
 }
開發者ID:lohini,項目名稱:webloader,代碼行數:10,代碼來源:PreFileFilter.php

示例2: validateEntity

 private function validateEntity($entity)
 {
     $errors = Environment::getService("validator")->validate($entity);
     if (count($errors) > 0) {
         foreach ($errors as $violation) {
             throw new \Neuron\Model\ValidationException($violation->getMessage(), $violation->getPropertyPath());
         }
     }
 }
開發者ID:janmarek,項目名稱:Neuron,代碼行數:9,代碼來源:ValidationSubscriber.php

示例3: createHelperLoader

 public static function createHelperLoader()
 {
     $loader = new \Neuron\Helper\TemplateHelperLoader();
     $loader->setHelper('texy', 'Neuron\\Texy\\TemplateHelper::process');
     $loader->setHelper('safetexy', 'Neuron\\Texy\\TemplateHelper::safeProcess');
     $loader->setHelper('thumbnail', array(Environment::getService('ThumbnailHelper'), 'createThumbnail'));
     $loader->setHelper('gravatar', 'Neuron\\Helper\\Gravatar::getImageTag');
     $loader->setHelper('imagehtml', 'Neuron\\Helper\\ImageHtml::getHtml');
     $loader->setHelper('webpath', 'Neuron\\Helper\\WebPath::getSrc');
     $loader->setHelper('imagepath', function ($image) {
         return Environment::getService('PhotoService')->getImagePath($image);
     });
     return $loader;
 }
開發者ID:janmarek,項目名稱:Neuron,代碼行數:14,代碼來源:ServiceFactories.php

示例4: getPanel

 public function getPanel()
 {
     if (count($this->queries) == 0) {
         return NULL;
     }
     $platform = get_class(\Nette\Environment::getService('Doctrine\\ORM\\EntityManager')->getConnection()->getDatabasePlatform());
     $platform = substr($platform, strrpos($platform, "\\") + 1, strrpos($platform, "Platform") - (strrpos($platform, "\\") + 1));
     $queries = $this->queries;
     $totalTime = round($this->totalTime, 3);
     $i = 0;
     ob_start();
     require_once __DIR__ . "/doctrine2.panel.phtml";
     return ob_get_clean();
 }
開發者ID:janmarek,項目名稱:Neuron,代碼行數:14,代碼來源:Doctrine2Panel.php

示例5: isValid

 public function isValid($value, Constraint $constraint)
 {
     /* @var $context Symfony\Component\Validator\ValidationContext */
     $context = $this->context;
     $property = $context->getCurrentProperty();
     $em = \Nette\Environment::getService('Doctrine\\ORM\\EntityManager');
     $entity = $context->getRoot();
     $qb = $em->getRepository(get_class($entity))->createQueryBuilder('e');
     $qb->select('count(e.id)')->where("e.{$property} = ?1")->setParameter('1', $value);
     if ($entity->getId()) {
         $qb->andWhere('e.id <> ?2')->setParameter('2', $entity->getId());
     }
     $count = $qb->getQuery()->getSingleScalarResult();
     $valid = (int) $count === 0;
     if ($valid) {
         return true;
     } else {
         $this->setMessage($constraint->message, array('value' => $value));
         return false;
     }
 }
開發者ID:janmarek,項目名稱:Neuron,代碼行數:21,代碼來源:UniqueConstraintValidator.php

示例6: match

	/**
	 * Maps HTTP request to a PresenterRequest object.
	 *
	 * @author   Jan Tvrdík
	 * @param    IHttpRequest
	 * @return   PresenterRequest|NULL
	 */
	public function match(IHttpRequest $httpRequest)
	{
		$path = rtrim($httpRequest->getUri()->getRelativeUri(), '/');
		$page = ($path === '' ? $this->homepage : $path);
		$templateLocator = Env::getService('TemplateLocator');
		if (!$templateLocator->existsPage($page)) {
			$page .= '/' . $this->defaultPage;
			if (!$templateLocator->existsPage($page)) {
				return NULL;
			}
		}

		return new PresenterRequest(
			$this->presenter,
			$httpRequest->getMethod(),
			array('page' => $page),
			$httpRequest->getPost(),
			$httpRequest->getFiles(),
			array('secured' => $httpRequest->isSecured())
		);
	}
開發者ID:JanTvrdik,項目名稱:NetteExtrasWeb,代碼行數:28,代碼來源:StaticRouter.php

示例7: authenticate

 /**
  * Performs an authentication
  * @param  array
  * @return void
  * @throws AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     $row = $this->fetch(array('username' => $credentials[0], 'active' => 1));
     if (!$row) {
         throw new AuthenticationException('Incorrect member name or password!', self::IDENTITY_NOT_FOUND);
     }
     if ($row['active'] == 0) {
         throw new AuthenticationException('Access denied', self::INVALID_CREDENTIAL);
     }
     if ($row['password'] !== sha1($credentials[1])) {
         throw new AuthenticationException('Incorrect member name or password!', self::INVALID_CREDENTIAL);
     }
     $acl = Nette\Environment::getService('authorizator');
     if ($row['role'] !== NULL) {
         $roles = $acl->getRoleParents($row['role']);
         $roles[] = $row['role'];
     } else {
         $roles = $row['role'];
         // or $roles = NULL
     }
     $this->setOnline($row['id']);
     unset($row['password']);
     unset($row['role']);
     return new Nette\Security\Identity($row['id'], $roles, $row);
 }
開發者ID:soundake,項目名稱:pd,代碼行數:31,代碼來源:Accounts.php

示例8: createRobotLoader

 /**
  * @return Nette\Loaders\RobotLoader
  */
 public static function createRobotLoader($options)
 {
     $loader = new Nette\Loaders\RobotLoader();
     $loader->autoRebuild = isset($options['autoRebuild']) ? $options['autoRebuild'] : !Environment::isProduction();
     $loader->setCacheStorage(Environment::getService('Nette\\Caching\\ICacheStorage'));
     if (isset($options['directory'])) {
         $loader->addDirectory($options['directory']);
     } else {
         foreach (array('appDir', 'libsDir') as $var) {
             if ($dir = Environment::getVariable($var, NULL)) {
                 $loader->addDirectory($dir);
             }
         }
     }
     $loader->register();
     return $loader;
 }
開發者ID:JPalounek,項目名稱:IconStore,代碼行數:20,代碼來源:Configurator.php

示例9: getJournal

 /**
  * Returns the ICacheJournal
  * @return ICacheJournal
  */
 protected function getJournal()
 {
     if ($this->journal === NULL) {
         $this->journal = Nette\Environment::getService('Nette\\Caching\\ICacheJournal');
     }
     return $this->journal;
 }
開發者ID:vrana,項目名稱:ORM-benchmark,代碼行數:11,代碼來源:FileStorage.php

示例10: register

 /**
  * Register CaptchaControl to FormContainer, start session and set $defaultFontFile (if not set)
  * @return void
  * @throws \Nette\InvalidStateException
  */
 public static function register()
 {
     if (self::$registered) {
         throw new \Nette\InvalidStateException(__CLASS__ . " is already registered");
     }
     $session = Environment::getService('session');
     if (!$session->isStarted()) {
         $session->start();
     }
     self::$session = $session->getSection('PavelMaca.Captcha');
     if (!self::$defaultFontFile) {
         self::$defaultFontFile = __DIR__ . "/fonts/Vera.ttf";
     }
     FormContainer::extensionMethod('addCaptcha', callback(__CLASS__, 'addCaptcha'));
     self::$registered = TRUE;
 }
開發者ID:vbuilder,項目名稱:framework,代碼行數:21,代碼來源:Captcha.php

示例11: setUp

 protected function setUp()
 {
     $em = Environment::getService("Doctrine\\ORM\\EntityManager");
     $this->object = new Service($em);
 }
開發者ID:janmarek,項目名稱:Neuron,代碼行數:5,代碼來源:MenuServiceTest.php

示例12: ConnectionHelper

<?php

use Nette\Environment;
use Symfony\Component\Console;
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Doctrine\ORM\Tools\Console\Command as DoctrineCommand;
use Doctrine\DBAL\Tools\Console\Command as DoctrineDBALCommand;
use Neuron\Console\Command as NeuronCommand;
require __DIR__ . '/../../../index.php';
$em = Environment::getService('Doctrine\\ORM\\EntityManager');
$helperSet = new Console\Helper\HelperSet();
$helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
$helperSet->set(new EntityManagerHelper($em), 'em');
$cli = new Console\Application('Doctrine & Neuron Command Line Interface', Doctrine\ORM\Version::VERSION);
$cli->setCatchExceptions(true);
$cli->setHelperSet($helperSet);
$cli->addCommands(array(new DoctrineDBALCommand\RunSqlCommand(), new DoctrineDBALCommand\ImportCommand(), new DoctrineCommand\ClearCache\MetadataCommand(), new DoctrineCommand\ClearCache\ResultCommand(), new DoctrineCommand\ClearCache\QueryCommand(), new DoctrineCommand\SchemaTool\CreateCommand(), new DoctrineCommand\SchemaTool\UpdateCommand(), new DoctrineCommand\SchemaTool\DropCommand(), new DoctrineCommand\EnsureProductionSettingsCommand(), new DoctrineCommand\ConvertDoctrine1SchemaCommand(), new DoctrineCommand\GenerateRepositoriesCommand(), new DoctrineCommand\GenerateEntitiesCommand(), new DoctrineCommand\GenerateProxiesCommand(), new DoctrineCommand\ConvertMappingCommand(), new DoctrineCommand\RunDqlCommand(), new DoctrineCommand\ValidateSchemaCommand(), new NeuronCommand\GenerateForm(), new NeuronCommand\GenerateModel(), new NeuronCommand\GenerateCrud(), new NeuronCommand\GenerateFrontPresenter()));
$cli->run();
開發者ID:janmarek,項目名稱:Neuron,代碼行數:19,代碼來源:cli.php

示例13: _nx

/**
 * Translates the given string with plural and vsprintf.
 *
 * @deprecated
 * @param string
 * @param string
 * @param int plural form (positive number)
 * @param array for vsprintf
 * @return string
 */
function _nx($single, $plural, $number, array $args)
{
    // trigger_error(__FUNCTION__ . '() is deprecated; use __(array(\$single, \$plural), array(\$number, $args[0], $args[1], ...) instead.', E_USER_DEPRECATED);
    return Nette\Environment::getService('translator')->translate(array($single, $plural), array_merge(array($number), $args));
}
開發者ID:vbuilder,項目名稱:framework,代碼行數:15,代碼來源:shortcuts.php

示例14: actionPreview

 /**
  * Texyla preview
  */
 public function actionPreview()
 {
     $texy = Environment::getService("Texy");
     $html = $texy->process(Environment::getHttpRequest()->getPost("texy"));
     $this->sendResponse(new RenderResponse($html));
 }
開發者ID:janmarek,項目名稱:Neuron,代碼行數:9,代碼來源:TexylaPresenter.php

示例15: process

	/**
	 * @param string texy source
	 * @return string html code
	 */
	public static function process($text)
	{
		return Environment::getService("Texy")->process($text);
	}
開發者ID:JanTvrdik,項目名稱:Neuron,代碼行數:8,代碼來源:TemplateHelper.php


注:本文中的Nette\Environment::getService方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。