当前位置: 首页>>代码示例>>PHP>>正文


PHP Container::exists方法代码示例

本文整理汇总了PHP中Joomla\DI\Container::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::exists方法的具体用法?PHP Container::exists怎么用?PHP Container::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Joomla\DI\Container的用法示例。


在下文中一共展示了Container::exists方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testExists

 /**
  * Test exists
  *
  * @return  void
  *
  * @since   1.0
  */
 public function testExists()
 {
     $reflection = new \ReflectionProperty($this->fixture, 'dataStore');
     $reflection->setAccessible(true);
     $reflection->setValue($this->fixture, array('foo' => 'bar'));
     $this->assertTrue($this->fixture->exists('foo'), 'When calling exists on an item that has been set in the container, it should return true.');
     $this->assertFalse($this->fixture->exists('baz'), 'When calling exists on an item that has not been set in the container, it should return false.');
 }
开发者ID:ZerGabriel,项目名称:joomla-framework,代码行数:15,代码来源:ContainerTest.php

示例2: getProofProfile

 /**
  * Return profile object from Proof of Identity.
  *
  * <code>
  * $userId = 1;
  *
  * $this->prepareProfile($container, $userId);
  * $profile = $this->getProfile($container, $userId);
  * </code>
  *
  * @param Container $container
  * @param int $userId
  *
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @throws \UnexpectedValueException
  * @throws \OutOfBoundsException
  *
  * @return User
  */
 protected function getProofProfile($container, $userId)
 {
     $userId = (int) abs($userId);
     $hash = StringHelper::generateMd5Hash(Constants::CONTAINER_PROOF_PROFILE, $userId);
     if (!$container->exists($hash) and $userId > 0) {
         $this->prepareProofProfile($container, $userId);
     }
     return $container->get($hash);
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:29,代码来源:ProofHelper.php

示例3: getReward

 /**
  * Return reward object.
  *
  * <code>
  * $rewardId = 1;
  * $projectId = 2;
  *
  * $this->prepareReward($container, $rewardId, $projectId);
  * $reward = $this->getReward($container, $rewardId, $projectId);
  * </code>
  *
  * @param Container $container
  * @param int $rewardId
  * @param int $projectId
  *
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @throws \UnexpectedValueException
  * @throws \OutOfBoundsException
  *
  * @return Reward
  */
 protected function getReward($container, $rewardId, $projectId)
 {
     $rewardId = (int) abs($rewardId);
     $hash = StringHelper::generateMd5Hash(Constants::CONTAINER_REWARD, array($rewardId, $projectId));
     if (!$container->exists($hash) and $rewardId > 0) {
         $this->prepareReward($container, $rewardId, $projectId);
     }
     return $container->get($hash);
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:31,代码来源:RewardHelper.php

示例4: getProject

 /**
  * Return project.
  *
  * <code>
  * $projectId = 1;
  *
  * $this->prepareProject($container, $projectId);
  * $project = $this->getProject($container, $projectId);
  * </code>
  *
  * @param Container $container
  * @param int $projectId
  *
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @throws \UnexpectedValueException
  * @throws \OutOfBoundsException
  *
  * @return Project
  */
 protected function getProject($container, $projectId)
 {
     $projectId = (int) abs($projectId);
     $hash = StringHelper::generateMd5Hash(Constants::CONTAINER_PROJECT, $projectId);
     if (!$container->exists($hash) and $projectId > 0) {
         $this->prepareProject($container, $projectId);
     }
     return $container->get($hash);
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:29,代码来源:ProjectHelper.php

示例5: getProfile

 /**
  * Return user profile.
  *
  * <code>
  * $userId = 1;
  *
  * $this->prepareProfile($container, $params, $userId);
  * $profile = $this->getProfile($container, $params, $userId);
  * </code>
  *
  * @param Container $container
  * @param Registry $params
  * @param int $userId
  *
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @throws \UnexpectedValueException
  * @throws \OutOfBoundsException
  *
  * @return Project
  */
 protected function getProfile($container, $params, $userId)
 {
     $userId = (int) abs($userId);
     $options = array('platform' => $params->get('integration_social_platform'), 'user_id' => $userId);
     $hash = StringHelper::generateMd5Hash(Constants::CONTAINER_PROFILE, $options);
     if (!$container->exists($hash) and $userId > 0) {
         $this->prepareProfile($container, $params, $userId);
     }
     return $container->get($hash);
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:31,代码来源:ProfileHelper.php

示例6: getNumberFormatter

 /**
  * Return number formatter.
  *
  * <code>
  * $fractionDigits = 2;
  *
  * $this->prepareNumberFormatter($container, $fractionDigits);
  * $numberFormatter = $this->getNumberFormatter($container, $fractionDigits);
  * </code>
  *
  * @param Container $container
  * @param int $fractionDigits
  *
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @throws \OutOfBoundsException
  *
  * @return \NumberFormatter
  */
 protected function getNumberFormatter($container, $fractionDigits = 2)
 {
     $fractionDigits = (int) abs($fractionDigits);
     $numberHash = StringHelper::generateMd5Hash(Constants::CONTAINER_FORMATTER_NUMBER, $fractionDigits);
     if (!$container->exists($numberHash)) {
         $this->prepareNumberFormatter($container, $fractionDigits);
         $numberFormatter = $container->get($numberHash);
     } else {
         $numberFormatter = $container->get($numberHash);
     }
     return $numberFormatter;
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:31,代码来源:NumberHelper.php

示例7: __construct

 /**
  * Constructor.
  *
  * @param string           $name        The Component name.
  * @param \JInput          $input       The Input object.
  * @param \JApplicationCms $application The Application object.
  * @param Container        $container   The DI container.
  *
  * @throws \Exception
  */
 public function __construct($name = null, $input = null, $application = null, $container = null)
 {
     $this->name = $name;
     // Guess component name.
     if (!$this->name) {
         $reflection = $this->getReflection();
         $this->name = $reflection->getShortName();
         $this->name = strtolower(str_replace('Component', '', $this->name));
         if (!$this->name) {
             throw new \Exception('Component need name.');
         }
     }
     $this->option = 'com_' . strtolower($this->name);
     $this->container = $container ?: Container::getInstance($this->option);
     $this->application = $application ?: $this->container->get('app');
     $this->input = $input ?: $this->application->input;
     // Add a config but make it B/C
     if ($this->container->exists($this->option . '.config')) {
         $this->config = $this->container->get($this->option . '.config');
     }
     $this->config = $this->config ?: new Registry();
     $this->config->merge(\JComponentHelper::getParams($this->option));
     $this->init();
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:34,代码来源:Component.php

示例8: testTheDatabaseServiceProviderIsRegisteredToTheContainer

 /**
  * @testdox The database service provider is registered to the DI container
  *
  * @covers  Stats\Providers\DatabaseServiceProvider::register
  */
 public function testTheDatabaseServiceProviderIsRegisteredToTheContainer()
 {
     $container = new Container();
     $container->registerServiceProvider(new DatabaseServiceProvider());
     $this->assertTrue($container->exists('Joomla\\Database\\DatabaseDriver'));
 }
开发者ID:phproberto,项目名称:jstats-server,代码行数:11,代码来源:DatabaseServiceProviderTest.php

示例9: getMoneyFormatter

 /**
  * Return money formatter.
  *
  * <code>
  * $this->prepareMoneyFormatter($container, $params);
  * $money = $this->getMoneyFormatter($container, $params);
  * </code>
  *
  * @param Container $container
  * @param Registry $params
  *
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @throws \OutOfBoundsException
  *
  * @return Money
  */
 protected function getMoneyFormatter($container, $params)
 {
     $currencyId = $params->get('project_currency');
     $moneyHash = StringHelper::generateMd5Hash(Constants::CONTAINER_FORMATTER_MONEY, $currencyId);
     if (!$container->exists($moneyHash)) {
         $this->prepareMoneyFormatter($container, $params);
         $money = $container->get($moneyHash);
     } else {
         $money = $container->get($moneyHash);
     }
     return $money;
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:29,代码来源:MoneyHelper.php

示例10: testTheApplicationServiceProviderIsRegisteredToTheContainer

 /**
  * @testdox The application service provider is registered to the DI container
  *
  * @covers  Stats\Providers\ApplicationServiceProvider::register
  */
 public function testTheApplicationServiceProviderIsRegisteredToTheContainer()
 {
     $container = new Container();
     $container->registerServiceProvider(new ApplicationServiceProvider());
     $this->assertTrue($container->exists('Stats\\Application'));
 }
开发者ID:phproberto,项目名称:jstats-server,代码行数:11,代码来源:ApplicationServiceProviderTest.php

示例11: testTheConfigServiceProviderIsRegisteredToTheContainer

 /**
  * @testdox The config service provider is registered to the DI container
  *
  * @covers  Stats\Providers\ConfigServiceProvider::__construct
  * @covers  Stats\Providers\ConfigServiceProvider::register
  */
 public function testTheConfigServiceProviderIsRegisteredToTheContainer()
 {
     $container = new Container();
     $container->registerServiceProvider(new ConfigServiceProvider(APPROOT . '/etc/config.dist.json'));
     $this->assertTrue($container->exists('config'));
 }
开发者ID:phproberto,项目名称:jstats-server,代码行数:12,代码来源:ConfigServiceProviderTest.php

示例12: getInstance

 /**
  * Returns a reference to the global JApplicationCms object, only creating it if it doesn't already exist.
  *
  * This method must be invoked as: $web = JApplicationCms::getInstance();
  *
  * @param   string     $name       The name (optional) of the JApplicationCms class to instantiate.
  * @param   string     $prefix     The class name prefix of the object.
  * @param   Container  $container  An optional dependency injection container to inject into the application.
  *
  * @return  JApplicationCms
  *
  * @since   3.2
  * @throws  RuntimeException
  */
 public static function getInstance($name = null, $prefix = 'JApplication', Container $container = null)
 {
     if (empty(static::$instances[$name])) {
         // Create a JApplicationCms object.
         $classname = $prefix . ucfirst($name);
         if (!class_exists($classname)) {
             throw new RuntimeException(JText::sprintf('JLIB_APPLICATION_ERROR_APPLICATION_LOAD', $name), 500);
         }
         if ($container && $container->exists($classname)) {
             static::$instances[$name] = $container->get($classname);
         } else {
             // TODO - This creates an implicit hard requirement on the JApplicationCms constructor
             static::$instances[$name] = new $classname(null, null, null, $container);
         }
     }
     return static::$instances[$name];
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:31,代码来源:cms.php


注:本文中的Joomla\DI\Container::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。