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


PHP CM_Service_Manager::getInstance方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: _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

示例5: 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

示例6: __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

示例7: _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

示例8: _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

示例9: 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

示例10: 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

示例11: _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

示例12: _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

示例13: log

 /**
  * @param string $message
  */
 public static function log($message)
 {
     $message = (string) $message;
     $trace = debug_backtrace();
     $className = 'none';
     $functionName = 'none';
     if (isset($trace[1])) {
         $className = isset($trace[1]['class']) ? $trace[1]['class'] : $className;
         $functionName = isset($trace[1]['function']) ? $trace[1]['function'] : $functionName;
     }
     CM_Service_Manager::getInstance()->getLogger()->debug(sprintf('%s:%s - %s', $className, $functionName, $message));
 }
开发者ID:cargomedia,项目名称:cm,代码行数:15,代码来源:Debug.php

示例14: 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

示例15: __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::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。