• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CM_Service_Manager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中CM_Service_Manager的典型用法代码示例。如果您正苦于以下问题:PHP CM_Service_Manager类的具体用法?PHP CM_Service_Manager怎么用?PHP CM_Service_Manager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: _getServiceManager

 /**
  * @param string $codeGoogleAnalytics
  * @param string $codeKissMetrics
  * @return CM_Service_Manager
  */
 protected function _getServiceManager($codeGoogleAnalytics, $codeKissMetrics)
 {
     $serviceManager = new CM_Service_Manager();
     $serviceManager->registerInstance('googleanalytics', new CMService_GoogleAnalytics_Client($codeGoogleAnalytics));
     $serviceManager->registerInstance('kissmetrics', new CMService_KissMetrics_Client($codeKissMetrics));
     $serviceManager->registerInstance('trackings', new CM_Service_Trackings(['googleanalytics', 'kissmetrics']));
     return $serviceManager;
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:13,代码来源:AbstractTest.php


示例2: testServiceInstantiation

 public function testServiceInstantiation()
 {
     $serviceManager = new CM_Service_Manager();
     $serviceManager->registerWithArray('stream-message', ['class' => 'CM_MessageStream_Factory', 'method' => ['name' => 'createService', 'arguments' => ['adapterClass' => 'CM_MessageStream_Adapter_SocketRedis', 'adapterArguments' => ['servers' => [['httpHost' => 'localhost', 'httpPort' => 8085, 'sockjsUrls' => ['http://localhost:8090']]]]]]]);
     $stream = $serviceManager->get('stream-message');
     $this->assertSame(true, $stream instanceof CM_MessageStream_Service);
     $adapter = $stream->getAdapter();
     $this->assertSame(true, $adapter instanceof CM_MessageStream_Adapter_SocketRedis);
     /** @var CM_MessageStream_Adapter_SocketRedis $adapter */
     $this->assertSame($serviceManager, $adapter->getServiceManager());
 }
开发者ID:cargomedia,项目名称:cm,代码行数:11,代码来源:ServiceTest.php


示例3: setUp

 protected function setUp()
 {
     $serviceManager = new CM_Service_Manager();
     $this->_filesystemDefault = new CM_File_Filesystem(new CM_File_Filesystem_Adapter_Local());
     $this->_filesystemFoo = new CM_File_Filesystem(new CM_File_Filesystem_Adapter_Local());
     $serviceManager->registerInstance('filesystem-usercontent-default', $this->_filesystemDefault);
     $serviceManager->registerInstance('filesystem-usercontent-foo', $this->_filesystemFoo);
     $config = array('default' => array('url' => 'http://example.com/default', 'filesystem' => 'filesystem-usercontent-default'), 'foo' => array('url' => 'http://example.com/foo', 'filesystem' => 'filesystem-usercontent-foo'));
     $this->_service = new CM_Service_UserContent($config);
     $this->_service->setServiceManager($serviceManager);
 }
开发者ID:cargomedia,项目名称:cm,代码行数:11,代码来源:UserContentTest.php


示例4: testGetUrl

 public function testGetUrl()
 {
     $serviceManager = new CM_Service_Manager();
     $filesystemDefault = new CM_File_Filesystem(new CM_File_Filesystem_Adapter_Local());
     $filesystemFoo = new CM_File_Filesystem(new CM_File_Filesystem_Adapter_Local());
     $serviceManager->registerInstance('filesystem-usercontent-default', $filesystemDefault);
     $serviceManager->registerInstance('filesystem-usercontent-foo', $filesystemFoo);
     $serviceConfig = array('default' => array('url' => 'http://example.com/default', 'filesystem' => 'filesystem-usercontent-default'), 'foo' => array('url' => 'http://example.com/foo', 'filesystem' => 'filesystem-usercontent-foo'));
     $serviceManager->registerInstance('usercontent', new CM_Service_UserContent($serviceConfig));
     $userFile = new CM_File_UserContent('foo', 'my.jpg', null, $serviceManager);
     $this->assertSame('http://example.com/foo/foo/my.jpg', $userFile->getUrl());
     $userFile = new CM_File_UserContent('bar', 'my.jpg', null, $serviceManager);
     $this->assertSame('http://example.com/default/bar/my.jpg', $userFile->getUrl());
 }
开发者ID:cargomedia,项目名称:cm,代码行数:14,代码来源:UserContentTest.php


示例5: execute

 /**
  * @param array|null $parameters
  * @param bool|null  $disableQueryBuffering
  * @throws CM_Db_Exception
  * @return CM_Db_Result
  */
 public function execute(array $parameters = null, $disableQueryBuffering = null)
 {
     $disableQueryBuffering = (bool) $disableQueryBuffering;
     $retryCount = 1;
     for ($try = 0; true; $try++) {
         try {
             if ($disableQueryBuffering) {
                 $this->_client->setBuffered(false);
             }
             @$this->_pdoStatement->execute($parameters);
             if ($disableQueryBuffering) {
                 $this->_client->setBuffered(true);
             }
             CM_Service_Manager::getInstance()->getDebug()->incStats('mysql', $this->getQueryString());
             return new CM_Db_Result($this->_pdoStatement);
         } catch (PDOException $e) {
             if ($try < $retryCount && $this->_client->isConnectionLossError($e)) {
                 $this->_client->disconnect();
                 $this->_client->connect();
                 $this->_reCreatePdoStatement();
                 continue;
             }
             throw new CM_Db_Exception('Cannot execute SQL statement', null, ['tries' => $try, 'originalExceptionMessage' => $e->getMessage(), 'query' => $this->_pdoStatement->queryString]);
         }
     }
     throw new CM_Db_Exception('Line should never be reached');
 }
开发者ID:cargomedia,项目名称:cm,代码行数:33,代码来源:Statement.php


示例6: testWithoutWhere

 public function testWithoutWhere()
 {
     $client = CM_Service_Manager::getInstance()->getDatabases()->getMaster();
     $query = new CM_Db_Query_UpdateSequence($client, 't`est', 's`ort', -1, null, 4, 9);
     $this->assertSame('UPDATE `t``est` SET `s``ort` = `s``ort` + ? WHERE `s``ort` BETWEEN ? AND ?', $query->getSqlTemplate());
     $this->assertEquals(array(-1, 4, 9), $query->getParameters());
 }
开发者ID:cargomedia,项目名称:cm,代码行数:7,代码来源:UpdateSequenceTest.php


示例7: testGetSetRuntime

 public function testGetSetRuntime()
 {
     $defaultTimeZoneBackup = date_default_timezone_get();
     $interval = '1 day';
     $timezone = new DateTimeZone('Europe/Berlin');
     $event1 = new CM_Clockwork_Event('foo', $interval);
     $event2 = new CM_Clockwork_Event('bar', $interval);
     $date1 = new DateTime('2014-10-31 08:00:00', $timezone);
     $date2 = new DateTime('2014-10-31 08:02:03', $timezone);
     $context = 'persistence-test';
     $storage = new CM_Clockwork_Storage_FileSystem($context);
     $serviceManager = CM_Service_Manager::getInstance();
     $storage->setServiceManager($serviceManager);
     $filepath = 'clockwork/' . md5($context) . '.json';
     $file = new CM_File($filepath, $serviceManager->getFilesystems()->getData());
     $this->assertFalse($file->exists());
     $this->assertFalse($file->getParentDirectory()->exists());
     $storage->setRuntime($event1, $date1);
     $this->assertTrue($file->getParentDirectory()->exists());
     $this->assertTrue($file->exists());
     $storage->setRuntime($event2, $date2);
     date_default_timezone_set('Antarctica/Vostok');
     $storage = new CM_Clockwork_Storage_FileSystem($context);
     $storage->setServiceManager($serviceManager);
     $this->assertEquals($date1, $storage->getLastRuntime($event1));
     $this->assertEquals($date2, $storage->getLastRuntime($event2));
     date_default_timezone_set($defaultTimeZoneBackup);
 }
开发者ID:cargomedia,项目名称:cm,代码行数:28,代码来源:FileSystemTest.php


示例8: testImportVideoThumbnail

 public function testImportVideoThumbnail()
 {
     $testFile1 = CM_File::create('test1.png', 'foo1', CM_Service_Manager::getInstance()->getFilesystems()->getTmp());
     $testFile2 = CM_File::create('test2.png', 'foo2', CM_Service_Manager::getInstance()->getFilesystems()->getTmp());
     $cli = new CM_MediaStreams_Cli();
     // streamchannel exists
     /** @var CM_Model_StreamChannel_Media $streamChannel */
     $streamChannel = CMTest_TH::createStreamChannel(null, null, 'foobar');
     $this->assertCount(0, $streamChannel->getThumbnails());
     $cli->importVideoThumbnail('foobar', $testFile1, 1234);
     $this->assertCount(1, $streamChannel->getThumbnails());
     /** @var CM_StreamChannel_Thumbnail $thumbnail */
     $thumbnail = $streamChannel->getThumbnails()->getItem(0);
     $this->assertSame(1234, $thumbnail->getCreateStamp());
     $this->assertSame('foo1', $thumbnail->getFile()->read());
     // archive exists
     $archive = CM_Model_StreamChannelArchive_Media::createStatic(['streamChannel' => $streamChannel]);
     $streamChannel->delete();
     $cli->importVideoThumbnail('foobar', $testFile2, 1235);
     $this->assertCount(2, $streamChannel->getThumbnails());
     /** @var CM_StreamChannel_Thumbnail $thumbnail */
     $thumbnail = $archive->getThumbnails()->getItem(1);
     $this->assertSame(1235, $thumbnail->getCreateStamp());
     $this->assertSame('foo2', $thumbnail->getFile()->read());
 }
开发者ID:cargomedia,项目名称:cm,代码行数:25,代码来源:CliTest.php


示例9: _getEmailVerification

 /**
  * @return CM_Service_EmailVerification_ClientInterface
  */
 protected function _getEmailVerification()
 {
     if ($this->getParams()->getBoolean('disable-email-verification', false)) {
         return new CM_Service_EmailVerification_Standard();
     }
     return CM_Service_Manager::getInstance()->get('email-verification', 'CM_Service_EmailVerification_ClientInterface');
 }
开发者ID:aladin1394,项目名称:CM,代码行数:10,代码来源:Email.php


示例10: __construct

 /**
  * @param string             $name
  * @param CM_Service_Manager $serviceManager
  */
 public function __construct($name, CM_Service_Manager $serviceManager = null)
 {
     $this->_construct(array('name' => $name));
     if (null === $serviceManager) {
         $serviceManager = CM_Service_Manager::getInstance();
     }
     $this->setServiceManager($serviceManager);
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:12,代码来源:Splittest.php


示例11: testRunJobLimit

 public function testRunJobLimit()
 {
     $serviceManager = new CM_Service_Manager();
     $logger = $this->mockObject('CM_Log_Logger');
     $serviceManager->registerInstance('logger', $logger);
     if (!extension_loaded('gearman')) {
         $this->markTestSkipped('Gearman Pecl Extension not installed.');
     }
     $gearmanWorker = $this->mockClass('GearmanWorker')->newInstanceWithoutConstructor();
     $workMethod = $gearmanWorker->mockMethod('work')->set(true);
     CM_Config::get()->CM_Jobdistribution_JobWorker->servers = [];
     $worker = $this->mockClass(CM_Jobdistribution_JobWorker::class)->newInstance([5]);
     $worker->mockMethod('_getGearmanWorker')->set($gearmanWorker);
     /** @var CM_Jobdistribution_JobWorker $worker */
     $worker->setServiceManager($serviceManager);
     $worker->run();
     $this->assertSame(5, $workMethod->getCallCount());
 }
开发者ID:cargomedia,项目名称:cm,代码行数:18,代码来源:JobWorkerTest.php


示例12: _deleteOlderThan

 /**
  * @param int $age
  */
 protected function _deleteOlderThan($age)
 {
     $age = (int) $age;
     $deleteOlderThan = time() - $age;
     $criteria = $this->_getCriteria();
     $criteria['createdAt'] = ['$lt' => new MongoDate($deleteOlderThan)];
     $mongoDb = CM_Service_Manager::getInstance()->getMongoDb();
     $mongoDb->remove(self::COLLECTION_NAME, $criteria, ['socketTimeoutMS' => 50000]);
     $this->_change();
 }
开发者ID:cargomedia,项目名称:cm,代码行数:13,代码来源:Log.php


示例13: onUnsubscribe

 public function onUnsubscribe(CM_Model_Stream_Subscribe $streamSubscribe)
 {
     if ($this->hasUser()) {
         $user = $streamSubscribe->getUser();
         if ($user && !$this->isSubscriber($user, $streamSubscribe)) {
             $delayedJobQueue = CM_Service_Manager::getInstance()->getDelayedJobQueue();
             $delayedJobQueue->addJob(new CM_User_OfflineJob(), ['user' => $user], CM_Model_User::OFFLINE_DELAY);
         }
     }
 }
开发者ID:cargomedia,项目名称:cm,代码行数:10,代码来源:User.php


示例14: prepare

 public function prepare(CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse)
 {
     $debug = CM_Service_Manager::getInstance()->getDebug();
     $stats = $debug->getStats();
     ksort($stats);
     $viewResponse->set('stats', $stats);
     $cacheNames = array('CM_Cache_Storage_Memcache', 'CM_Cache_Storage_Apc', 'CM_Cache_Storage_File');
     $viewResponse->getJs()->setProperty('cacheNames', $cacheNames);
     $viewResponse->set('cacheNames', $cacheNames);
 }
开发者ID:cargomedia,项目名称:cm,代码行数:10,代码来源:Debug.php


示例15: _execute

 protected function _execute(CM_Params $params)
 {
     $indexClassName = $params->getString('indexClassName');
     $id = $params->getString('id');
     $client = CM_Service_Manager::getInstance()->getElasticsearch()->getClient();
     /** @var CM_Elasticsearch_Type_Abstract $index */
     $index = new $indexClassName($client);
     $index->updateDocuments(array($id));
     $index->refreshIndex();
 }
开发者ID:cargomedia,项目名称:cm,代码行数:10,代码来源:UpdateDocumentJob.php


示例16: _execute

 protected function _execute(CM_Params $params)
 {
     CM_Service_Manager::getInstance()->getMailer()->send($params->getMailMessage('message'));
     if ($params->has('recipient') && $params->has('mailType')) {
         $recipient = $params->getUser('recipient');
         $mailType = $params->getInt('mailType');
         $action = new CM_Action_Email(CM_Action_Abstract::SEND, $recipient, $mailType);
         $action->prepare($recipient);
         $action->notify($recipient);
     }
 }
开发者ID:cargomedia,项目名称:cm,代码行数:11,代码来源:SendJob.php


示例17: __construct

 /**
  * @param string            $verbName
  * @param CM_Model_User|int $actor
  * @param int               $typeEmail
  */
 public function __construct($verbName, $actor, $typeEmail)
 {
     parent::__construct($verbName, $actor);
     $typeEmail = (int) $typeEmail;
     try {
         $className = CM_Mail_Mailable::_getClassName($typeEmail);
         $this->_nameEmail = ucwords(CM_Util::uncamelize(str_replace('_', '', preg_replace('#\\A[^_]++_[^_]++_#', '', $className)), ' '));
     } catch (CM_Class_Exception_TypeNotConfiguredException $exception) {
         CM_Service_Manager::getInstance()->getLogger()->warning('Unrecognized mail type when creating mail action', (new CM_Log_Context())->setException($exception));
         $this->_nameEmail = (string) $typeEmail;
     }
 }
开发者ID:cargomedia,项目名称:cm,代码行数:17,代码来源:Email.php


示例18: _executeJob

 /**
  * @param CM_Params $params
  * @return mixed
  * @throws Exception
  */
 private function _executeJob(CM_Params $params)
 {
     CM_Service_Manager::getInstance()->getNewrelic()->startTransaction('CM Job: ' . $this->_getClassName());
     try {
         $return = $this->_execute($params);
         CM_Service_Manager::getInstance()->getNewrelic()->endTransaction();
         return $return;
     } catch (Exception $ex) {
         CM_Service_Manager::getInstance()->getNewrelic()->endTransaction();
         throw $ex;
     }
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:17,代码来源:Abstract.php


示例19: setUp

 public function setUp()
 {
     CM_Db_Db::exec('ALTER TABLE cm_model_location_ip AUTO_INCREMENT = 1');
     CM_Db_Db::exec('ALTER TABLE cm_model_location_zip AUTO_INCREMENT = 1');
     CM_Db_Db::exec('ALTER TABLE cm_model_location_city AUTO_INCREMENT = 1');
     CM_Db_Db::exec('ALTER TABLE cm_model_location_state AUTO_INCREMENT = 1');
     CM_Db_Db::exec('ALTER TABLE cm_model_location_country AUTO_INCREMENT = 1');
     $this->_errorStream = new CM_OutputStream_Null();
     $file = new CM_File('/CM_OutputStream_File-' . uniqid(), CM_Service_Manager::getInstance()->getFilesystems()->getTmp());
     $file->truncate();
     $this->_outputStream = new CM_OutputStream_File($file);
 }
开发者ID:cargomedia,项目名称:cm,代码行数:12,代码来源:MaxMindTest.php


示例20: __construct

 /**
  * @param CM_Frontend_Environment|null $environment
  * @param boolean|null                 $languageRewrite
  * @param CM_Service_Manager|null      $serviceManager
  */
 public function __construct(CM_Frontend_Environment $environment = null, $languageRewrite = null, CM_Service_Manager $serviceManager = null)
 {
     if (!$environment) {
         $environment = new CM_Frontend_Environment();
     }
     $this->_environment = $environment;
     $this->_languageRewrite = (bool) $languageRewrite;
     if (null === $serviceManager) {
         $serviceManager = CM_Service_Manager::getInstance();
     }
     $this->setServiceManager($serviceManager);
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:17,代码来源:Render.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CM_Util类代码示例发布时间:2022-05-23
下一篇:
PHP CM_Params类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap