コード例 #1
0
ファイル: AbstractTest.php プロジェクト: NicolasSchmutz/cm
 /**
  * @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;
 }
コード例 #2
0
ファイル: ServiceTest.php プロジェクト: cargomedia/cm
 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());
 }
コード例 #3
0
ファイル: UserContentTest.php プロジェクト: cargomedia/cm
 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);
 }
コード例 #4
0
ファイル: UserContentTest.php プロジェクト: cargomedia/cm
 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());
 }
コード例 #5
0
ファイル: Statement.php プロジェクト: cargomedia/cm
 /**
  * @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');
 }
コード例 #6
0
ファイル: UpdateSequenceTest.php プロジェクト: cargomedia/cm
 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());
 }
コード例 #7
0
ファイル: FileSystemTest.php プロジェクト: cargomedia/cm
 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);
 }
コード例 #8
0
ファイル: CliTest.php プロジェクト: cargomedia/cm
 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());
 }
コード例 #9
0
ファイル: Email.php プロジェクト: aladin1394/CM
 /**
  * @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');
 }
コード例 #10
0
ファイル: Splittest.php プロジェクト: NicolasSchmutz/cm
 /**
  * @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);
 }
コード例 #11
0
ファイル: JobWorkerTest.php プロジェクト: cargomedia/cm
 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());
 }
コード例 #12
0
ファイル: Log.php プロジェクト: cargomedia/cm
 /**
  * @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();
 }
コード例 #13
0
ファイル: User.php プロジェクト: cargomedia/cm
 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);
         }
     }
 }
コード例 #14
0
ファイル: Debug.php プロジェクト: cargomedia/cm
 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);
 }
コード例 #15
0
ファイル: UpdateDocumentJob.php プロジェクト: cargomedia/cm
 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();
 }
コード例 #16
0
ファイル: SendJob.php プロジェクト: cargomedia/cm
 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);
     }
 }
コード例 #17
0
ファイル: Email.php プロジェクト: cargomedia/cm
 /**
  * @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;
     }
 }
コード例 #18
0
ファイル: Abstract.php プロジェクト: NicolasSchmutz/cm
 /**
  * @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;
     }
 }
コード例 #19
0
ファイル: MaxMindTest.php プロジェクト: cargomedia/cm
 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);
 }
コード例 #20
0
ファイル: Render.php プロジェクト: NicolasSchmutz/cm
 /**
  * @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);
 }
コード例 #21
0
ファイル: Debug.php プロジェクト: cargomedia/cm
 /**
  * @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));
 }
コード例 #22
0
ファイル: Cli.php プロジェクト: NicolasSchmutz/cm
 /**
  * @param string|null $filterIndexName
  * @throws CM_Exception_Invalid
  * @return CM_Elasticsearch_Type_Abstract[]
  */
 protected function _getTypes($filterIndexName = null)
 {
     $types = CM_Service_Manager::getInstance()->getElasticsearch()->getTypes();
     if (null !== $filterIndexName) {
         $types = \Functional\filter($types, function (CM_Elasticsearch_Type_Abstract $type) use($filterIndexName) {
             return $type->getIndex()->getName() === $filterIndexName;
         });
         if (count($types) === 0) {
             throw new CM_Exception_Invalid('No type with such index name: ' . $filterIndexName);
         }
     }
     return $types;
 }
コード例 #23
0
ファイル: InstallationTest.php プロジェクト: cargomedia/cm
 public function testGetModules()
 {
     $filesystemTmp = CM_Service_Manager::getInstance()->getFilesystems()->getTmp();
     $dirRoot = $filesystemTmp->getAdapter()->getPathPrefix() . '/foo-app/';
     $composerFile = new \Composer\Json\JsonFile($dirRoot . 'composer.json');
     $composerFile->write(array('name' => 'foo/bar', 'require' => array('cargomedia/cm' => '*'), 'extra' => ['cm-modules' => ['Package' => ['path' => 'package/']]]));
     $filesystemTmp->ensureDirectory('foo-app/vendor/composer/');
     $installedFile = new \Composer\Json\JsonFile($dirRoot . 'vendor/composer/installed.json');
     $installedFile->write([['name' => 'cargomedia/cm', 'version' => '1.3.10', 'type' => 'library', 'extra' => ['cm-modules' => ['CM' => ['path' => '']]], 'autoload' => ['psr-0' => ['CM_' => 'library/']]]]);
     $installation = new CM_App_Installation($dirRoot);
     $expectedModules = [new CM_App_Module('CM', 'vendor/cargomedia/cm/'), new CM_App_Module('Package', 'package/')];
     $this->assertEquals($expectedModules, $installation->getModules());
 }
コード例 #24
0
ファイル: EmailTest.php プロジェクト: NicolasSchmutz/cm
 public function testDisableEmailVerification()
 {
     $emailVerificationMock = $this->getMock('CM_Service_EmailVerification_Standard', ['isValid']);
     $emailVerificationMock->expects($this->never())->method('isValid');
     $serviceManager = CM_Service_Manager::getInstance();
     $emailVerificationDefault = $serviceManager->get('email-verification');
     $serviceManager->unregister('email-verification');
     $serviceManager->registerInstance('email-verification', $emailVerificationMock);
     $field = new CM_FormField_Email(['name' => 'email', 'disable-email-verification' => true]);
     $environment = new CM_Frontend_Environment();
     $this->assertSame('*****@*****.**', $field->validate($environment, '*****@*****.**'));
     $serviceManager->unregister('email-verification');
     $serviceManager->registerInstance('email-verification', $emailVerificationDefault);
 }
コード例 #25
0
ファイル: ClientTest.php プロジェクト: cargomedia/cm
 public function testReconnectTimeout()
 {
     $config = CM_Service_Manager::getInstance()->getDatabases()->getMaster()->getConfig();
     $config['reconnectTimeout'] = 5;
     $client = new CM_Db_Client($config);
     $client->connect();
     $firstTime = $client->getLastConnect();
     $timeForward = 100;
     CMTest_TH::timeForward($timeForward);
     $client->createStatement('SELECT 1')->execute();
     $this->assertSameTime($firstTime + $timeForward, $client->getLastConnect(), 5);
     CMTest_TH::timeForward($timeForward);
     $client->createStatement('SELECT 1')->execute();
     $this->assertSameTime($firstTime + 2 * $timeForward, $client->getLastConnect(), 5);
 }
コード例 #26
0
ファイル: UserContent.php プロジェクト: cargomedia/cm
 /**
  * @param string                  $namespace
  * @param string                  $filename
  * @param int|null                $sequence
  * @param CM_Service_Manager|null $serviceManager
  */
 public function __construct($namespace, $filename, $sequence = null, CM_Service_Manager $serviceManager = null)
 {
     $namespace = (string) $namespace;
     $filename = (string) $filename;
     if (null !== $sequence) {
         $sequence = (int) $sequence;
     }
     if (null === $serviceManager) {
         $serviceManager = CM_Service_Manager::getInstance();
     }
     $this->_pathRelative = $this->_calculateRelativeDir($namespace, $filename, $sequence);
     $this->_namespace = $namespace;
     $this->setServiceManager($serviceManager);
     $filesystem = $serviceManager->getUserContent()->getFilesystem($this->getNamespace());
     parent::__construct($this->getPathRelative(), $filesystem);
 }
コード例 #27
0
ファイル: Elasticsearch.php プロジェクト: cargomedia/cm
 /**
  * @param int|null $offset
  * @param int|null $count
  * @return array
  */
 private function _getResult($offset = null, $count = null)
 {
     $cacheKey = array($this->_query->getSort(), $offset, $count);
     if (($result = $this->_cacheGet($cacheKey)) === false) {
         $data = array('query' => $this->_query->getQuery(), 'sort' => $this->_query->getSort());
         if ($this->_fields) {
             $data['fields'] = $this->_fields;
         }
         if ($offset !== null) {
             $data['from'] = $offset;
         }
         if ($count !== null) {
             $data['size'] = $count;
         }
         $searchResult = CM_Service_Manager::getInstance()->getElasticsearch()->query($this->_types, $data);
         $result = array('items' => array(), 'total' => 0);
         if (isset($searchResult['hits'])) {
             foreach ($searchResult['hits']['hits'] as $hit) {
                 if ($this->_fields && array_key_exists('fields', $hit)) {
                     if ($this->_returnType) {
                         $idArray = array('id' => $hit['_id'], 'type' => $hit['_type']);
                     } else {
                         $idArray = array('id' => $hit['_id']);
                     }
                     $fields = $hit['fields'];
                     $fields = Functional\map($fields, function ($field) {
                         if (is_array($field) && 1 == count($field)) {
                             $field = reset($field);
                         }
                         return $field;
                     });
                     $result['items'][] = array_merge($idArray, $fields);
                 } else {
                     if ($this->_returnType) {
                         $item = array('id' => $hit['_id'], 'type' => $hit['_type']);
                     } else {
                         $item = $hit['_id'];
                     }
                     $result['items'][] = $item;
                 }
             }
             $result['total'] = $searchResult['hits']['total'];
         }
         $this->_cacheSet($cacheKey, $result);
     }
     return $result;
 }
コード例 #28
0
ファイル: Abstract.php プロジェクト: cargomedia/cm
 /**
  * @param CM_InputStream_Interface|null  $streamInput
  * @param CM_OutputStream_Interface|null $streamOutput
  * @param CM_OutputStream_Interface|null $streamError
  */
 public function __construct(CM_InputStream_Interface $streamInput = null, CM_OutputStream_Interface $streamOutput = null, CM_OutputStream_Interface $streamError = null)
 {
     if (null === $streamInput) {
         $streamInput = new CM_InputStream_Null();
     }
     $this->_streamInput = $streamInput;
     if (null === $streamOutput) {
         $streamOutput = new CM_OutputStream_Null();
     }
     $this->_streamOutput = $streamOutput;
     if (null === $streamError) {
         $streamError = new CM_OutputStream_Null();
     }
     $this->_streamError = $streamError;
     $this->setServiceManager(CM_Service_Manager::getInstance());
     $this->_initialize();
 }
コード例 #29
0
ファイル: Layout.php プロジェクト: NicolasSchmutz/cm
 /**
  * @return string
  */
 public function fetch()
 {
     $page = $this->_getPage();
     $layout = $this->_getLayout();
     $page->checkAccessible($this->getRender()->getEnvironment());
     $frontend = $this->getRender()->getGlobalResponse();
     $viewResponse = new CM_Frontend_ViewResponse($layout);
     $viewResponse->setTemplateName('default');
     $layout->prepare($this->getRender()->getEnvironment(), $viewResponse);
     $viewResponse->set('viewResponse', $viewResponse);
     $viewResponse->set('page', $page);
     $viewResponse->set('pageTitle', $this->fetchTitle());
     $viewResponse->set('pageDescription', $this->fetchDescription());
     $viewResponse->set('pageKeywords', $this->fetchKeywords());
     $viewResponse->set('renderAdapter', $this);
     $environmentDefault = new CM_Frontend_Environment($this->getRender()->getEnvironment()->getSite());
     $renderDefault = new CM_Frontend_Render($environmentDefault);
     $viewResponse->set('renderDefault', $renderDefault);
     $viewResponse->set('languageList', new CM_Paging_Language_Enabled());
     $serviceManager = CM_Service_Manager::getInstance();
     $options = array();
     $options['deployVersion'] = CM_App::getInstance()->getDeployVersion();
     $options['renderStamp'] = floor(microtime(true) * 1000);
     $options['site'] = CM_Params::encode($this->getRender()->getSite());
     $options['url'] = $this->getRender()->getSite()->getUrl();
     $options['urlCdn'] = $this->getRender()->getSite()->getUrlCdn();
     $options['urlUserContentList'] = $serviceManager->getUserContent()->getUrlList();
     $options['language'] = $this->getRender()->getLanguage();
     $options['debug'] = CM_Bootloader::getInstance()->isDebug();
     $options['stream'] = $serviceManager->getStreamMessage()->getClientOptions();
     if ($viewer = $this->getRender()->getViewer()) {
         $options['stream']['channel']['key'] = CM_Model_StreamChannel_Message_User::getKeyByUser($viewer);
         $options['stream']['channel']['type'] = CM_Model_StreamChannel_Message_User::getTypeStatic();
     }
     $frontend->getOnloadHeaderJs()->append('cm.options = ' . CM_Params::encode($options, true));
     if ($viewer = $this->getRender()->getViewer()) {
         $frontend->getOnloadHeaderJs()->append('cm.viewer = ' . CM_Params::encode($viewer, true));
     }
     $frontend->treeExpand($viewResponse);
     $frontend->getOnloadReadyJs()->append('cm.getLayout()._ready();');
     $frontend->getOnloadHeaderJs()->append('cm.ready();');
     $html = $this->getRender()->fetchViewResponse($viewResponse);
     $frontend->treeCollapse();
     return $html;
 }
コード例 #30
0
ファイル: Abstract.php プロジェクト: NicolasSchmutz/cm
 /**
  * @param string[] $keys
  * @return mixed[]
  */
 public final function getMulti(array $keys)
 {
     CM_Service_Manager::getInstance()->getDebug()->incStats(strtolower($this->_getName()) . '-getMulti', $keys);
     foreach ($keys as &$key) {
         $key = self::_getKeyArmored($key);
     }
     $values = $this->_getMulti($keys);
     $result = array();
     $runtime = $this->_getRuntime();
     foreach ($values as $armoredKey => $value) {
         $key = $this->_extractKeyArmored($armoredKey);
         $result[$key] = $value;
         if ($runtime) {
             $runtime->set($key, $value);
         }
     }
     return $result;
 }