当前位置: 首页>>代码示例>>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;未经允许,请勿转载。