本文整理汇总了PHP中org_tubepress_impl_ioc_IocContainer::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP org_tubepress_impl_ioc_IocContainer::getInstance方法的具体用法?PHP org_tubepress_impl_ioc_IocContainer::getInstance怎么用?PHP org_tubepress_impl_ioc_IocContainer::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org_tubepress_impl_ioc_IocContainer
的用法示例。
在下文中一共展示了org_tubepress_impl_ioc_IocContainer::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHeadHtmlMeta
public function getHeadHtmlMeta()
{
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$qss = $ioc->get('org_tubepress_api_querystring_QueryStringService');
$page = $qss->getPageNum($_GET);
return $page > 1 ? "<meta name=\"robots\" content=\"noindex, nofollow\" />" : '';
}
示例2: testFetchGoodXmlCacheDisabled
function testFetchGoodXmlCacheDisabled()
{
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$httpClient = $ioc->get(org_tubepress_api_http_HttpClient::_);
$httpClient->shouldReceive('executeAndHandleResponse')->once()->andReturn('someValue');
$this->assertEquals('someValue', $this->_sut->fetch("http://www.ietf.org/css/ietf.css", false));
}
示例3: executeOptionsPage
/**
* Registers the TubePress options page
*
* @return void
*/
public static function executeOptionsPage()
{
/* grab the storage manager */
$iocContainer = org_tubepress_impl_ioc_IocContainer::getInstance();
$wpsm = $iocContainer->get(org_tubepress_api_options_StorageManager::_);
/* initialize our options in case we need to */
$wpsm->init();
/* get the form handler */
$optionsForm = $iocContainer->get(org_tubepress_api_options_ui_FormHandler::_);
$hrps = $iocContainer->get(org_tubepress_api_http_HttpRequestParameterService::_);
/* are we updating? */
if ($hrps->hasParam('tubepress_save')) {
self::_verifyNonce();
try {
$result = $optionsForm->onSubmit();
if ($result === null) {
echo '<div id="message" class="updated fade"><p><strong>Options updated</strong></p></div>';
} else {
self::_error($result);
}
} catch (Exception $error) {
self::_error($error->getMessage());
}
}
print $optionsForm->getHtml();
}
示例4: _wrappedParse
private function _wrappedParse($content)
{
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$context = $ioc->get(org_tubepress_api_exec_ExecutionContext::_);
$keyword = $context->get(org_tubepress_api_const_options_names_Advanced::KEYWORD);
if (!$this->somethingToParse($content, $keyword)) {
return;
}
preg_match("/\\[{$keyword}\\b(.*)\\]/", $content, $matches);
org_tubepress_impl_log_Log::log(self::$_logPrefix, 'Found a shortcode: %s', $matches[0]);
$context->setActualShortcodeUsed($matches[0]);
/* Anything matched? */
if (isset($matches[1]) && $matches[1] != '') {
$text = preg_replace('/[\\x{00a0}\\x{200b}]+/u', ' ', utf8_encode($matches[1]));
$text = self::_convertQuotes($text);
$pattern = '/(\\w+)\\s*=\\s*"([^"]*)"(?:\\s*,)?(?:\\s|$)|(\\w+)\\s*=\\s*\'([^\']*)\'(?:\\s*,)?(?:\\s|$)|(\\w+)\\s*=\\s*([^\\s\'"]+)(?:\\s*,)?(?:\\s|$)/';
if (preg_match_all($pattern, $text, $match, PREG_SET_ORDER)) {
org_tubepress_impl_log_Log::log(self::$_logPrefix, 'Candidate options detected in shortcode: %s', $matches[0]);
$toReturn = self::_buildNameValuePairArray($match, $ioc);
$context->setCustomOptions($toReturn);
}
} else {
org_tubepress_impl_log_Log::log(self::$_logPrefix, 'No custom options detected in shortcode: %s', $matches[0]);
}
}
示例5: getHeadHtmlMeta
public function getHeadHtmlMeta()
{
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$qss = $ioc->get(org_tubepress_api_http_HttpRequestParameterService::_);
$page = $qss->getParamValueAsInt(org_tubepress_api_const_http_ParamName::PAGE, 1);
return $page > 1 ? "<meta name=\"robots\" content=\"noindex, nofollow\" />" : '';
}
示例6: execute
/**
* Execute the command.
*
* @param array $context An array of context elements (may be empty).
*
* @return boolean True if this command was able to handle the execution. False otherwise.
*/
public function execute($context)
{
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$execContext = $ioc->get(org_tubepress_api_exec_ExecutionContext::_);
$playerName = $execContext->get(org_tubepress_api_const_options_names_Embedded::PLAYER_LOCATION);
if ($playerName !== org_tubepress_api_const_options_values_PlayerLocationValue::SOLO) {
return false;
}
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Solo player detected. Checking query string for video ID.');
/* see if we have a custom video ID set */
$qss = $ioc->get(org_tubepress_api_http_HttpRequestParameterService::_);
$videoId = $qss->getParamValue(org_tubepress_api_const_http_ParamName::VIDEO);
if ($videoId == '') {
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Solo player in use, but no video ID set in URL.');
return false;
}
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Building single video with ID %s', $videoId);
$result = $execContext->set(org_tubepress_api_const_options_names_Output::VIDEO, $videoId);
if ($result !== true) {
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Could not verify video ID.');
return false;
}
/* display the results as a thumb gallery */
$ioc->get(org_tubepress_spi_patterns_cor_Chain::_)->execute($context, array('org_tubepress_impl_shortcode_commands_SingleVideoCommand'));
return true;
}
示例7: getDelegateFormHandlers
protected function getDelegateFormHandlers()
{
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$tabs = $ioc->get(org_tubepress_impl_options_ui_DefaultTabsHandler::__);
$filter = $ioc->get(org_tubepress_impl_options_ui_fields_FilterMultiSelectField::__);
return array($tabs, $filter);
}
示例8: addToTemplate
protected function addToTemplate(org_tubepress_api_template_Template $template)
{
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$execContext = $ioc->get(org_tubepress_api_exec_ExecutionContext::_);
$currentMode = $execContext->get(org_tubepress_api_const_options_names_Output::GALLERY_SOURCE);
$template->setVariable(self::TEMPLATE_VAR_CURRENT_MODE, $currentMode);
}
示例9: on_boot
/**
* Perform boot procedure.
*
* @return void
*/
public function on_boot()
{
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$ed = $ioc->get(org_tubepress_api_environment_Detector::_);
$fse = $ioc->get(org_tubepress_api_filesystem_Explorer::_);
if (!$ed->isWordPress()) {
return;
}
global $tubepress_base_url;
$baseName = $fse->getTubePressInstallationDirectoryBaseName();
/** http://code.google.com/p/tubepress/issues/detail?id=495#c2 */
if ($this->_isWordPressMuDomainMapped()) {
$prefix = $this->_getScheme() . constant('COOKIE_DOMAIN');
} else {
$prefix = site_url();
}
$tubepress_base_url = $prefix . "/wp-content/plugins/{$baseName}";
/* register the plugin's message bundles */
load_plugin_textdomain('tubepress', false, "{$baseName}/sys/i18n");
add_filter('the_content', array('org_tubepress_impl_env_wordpress_Main', 'contentFilter'));
add_action('wp_head', array('org_tubepress_impl_env_wordpress_Main', 'headAction'));
add_action('init', array('org_tubepress_impl_env_wordpress_Main', 'initAction'));
add_action('admin_menu', array('org_tubepress_impl_env_wordpress_OptionsPage', 'menuAction'));
add_action('admin_enqueue_scripts', array('org_tubepress_impl_env_wordpress_OptionsPage', 'initAction'));
add_action('widgets_init', array('org_tubepress_impl_env_wordpress_Widget', 'initAction'));
}
示例10: testBoot
function testBoot()
{
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$pm = $ioc->get(org_tubepress_api_plugin_PluginManager::_);
$expectedSystemFilters = array(array(org_tubepress_api_const_plugin_FilterPoint::OPTION_SET_PRE_VALIDATION, 'org_tubepress_impl_plugin_filters_prevalidationoptionset_YouTubePlaylistPlPrefixRemover'), array(org_tubepress_api_const_plugin_FilterPoint::OPTION_SET_PRE_VALIDATION, 'org_tubepress_impl_plugin_filters_prevalidationoptionset_StringMagic'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_EMBEDDED, 'org_tubepress_impl_plugin_filters_embeddedtemplate_CoreVariables'), array(org_tubepress_api_const_plugin_FilterPoint::HTML_EMBEDDED, 'org_tubepress_impl_plugin_filters_embeddedhtml_PlayerJavaScriptApi'), array(org_tubepress_api_const_plugin_FilterPoint::HTML_GALLERY, 'org_tubepress_impl_plugin_filters_galleryhtml_GalleryJs'), array(org_tubepress_api_const_plugin_FilterPoint::JAVASCRIPT_GALLERYINIT, 'org_tubepress_impl_plugin_filters_galleryinitjs_GalleryInitJsBaseParams'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, 'org_tubepress_impl_plugin_filters_gallerytemplate_CoreVariables'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, 'org_tubepress_impl_plugin_filters_gallerytemplate_EmbeddedPlayerName'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, 'org_tubepress_impl_plugin_filters_gallerytemplate_Pagination'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, 'org_tubepress_impl_plugin_filters_gallerytemplate_Player'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, 'org_tubepress_impl_plugin_filters_gallerytemplate_VideoMeta'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_PLAYER, 'org_tubepress_impl_plugin_filters_playertemplate_CoreVariables'), array(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, 'org_tubepress_impl_plugin_filters_providerresult_ResultCountCapper'), array(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, 'org_tubepress_impl_plugin_filters_providerresult_VideoBlacklist'), array(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, 'org_tubepress_impl_plugin_filters_providerresult_PerPageSorter'), array(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, 'org_tubepress_impl_plugin_filters_providerresult_VideoPrepender'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_SEARCHINPUT, 'org_tubepress_impl_plugin_filters_searchinputtemplate_CoreVariables'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_SINGLEVIDEO, 'org_tubepress_impl_plugin_filters_singlevideotemplate_CoreVariables'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_SINGLEVIDEO, 'org_tubepress_impl_plugin_filters_singlevideotemplate_VideoMeta'), array(org_tubepress_api_const_plugin_FilterPoint::VARIABLE_READ_FROM_EXTERNAL_INPUT, 'org_tubepress_impl_plugin_filters_variablereadfromexternalinput_StringMagic'));
foreach ($expectedSystemFilters as $filter) {
$pm->shouldReceive('registerFilter')->with($filter[0], anInstanceOf($filter[1]))->once();
}
$pm->shouldReceive('registerListener')->with(org_tubepress_api_const_plugin_EventName::BOOT, anInstanceOf('org_tubepress_impl_plugin_listeners_StorageManagerInitListener'));
$pm->shouldReceive('registerListener')->with(org_tubepress_api_const_plugin_EventName::BOOT, anInstanceOf('org_tubepress_impl_plugin_listeners_WordPressBoot'));
$pm->shouldReceive('registerListener')->with(org_tubepress_api_const_plugin_EventName::BOOT, anInstanceOf('org_tubepress_impl_plugin_listeners_SkeletonExistsListener'));
$pm->shouldReceive('notifyListeners')->with(org_tubepress_api_const_plugin_EventName::BOOT)->once();
$envD = $ioc->get(org_tubepress_api_environment_Detector::_);
$envD->shouldReceive('isWordPress')->once()->andReturn(false);
$context = $ioc->get(org_tubepress_api_exec_ExecutionContext::_);
$context->shouldReceive('get')->with(org_tubepress_api_const_options_names_Advanced::DEBUG_ON)->andReturn(false);
$fe = $ioc->get(org_tubepress_api_filesystem_Explorer::_);
$fe->shouldReceive('getDirectoriesInDirectory')->once()->with('<<user-content-dir>>/plugins', anything())->andReturn(array('fakedirectory'));
$fe->shouldReceive('getFilenamesInDirectory')->once()->with('fakedirectory', anything())->andReturn(array(dirname(__FILE__) . '/../../../resources/simplePhpFile.php'));
$th = $ioc->get(org_tubepress_api_theme_ThemeHandler::_);
$th->shouldReceive('getUserContentDirectory')->once()->andReturn('<<user-content-dir>>');
$sm = $ioc->get(org_tubepress_api_options_StorageManager::_);
$sm->shouldReceive('init')->once();
$this->_sut->boot();
}
示例11: execute
/**
* Executes the given commands with the given context.
*
* @param array $context An array of context elements (may be empty).
* @param array $commands An array of org_tubepress_api_patterns_cor_Command class names to execute.
*
* @return unknown The result of the command execution.
*/
public function execute($context, $commands)
{
/* sanity checkin' */
if (!is_array($commands)) {
throw new Exception('execute() requires an array of commands');
}
if (!is_object($context)) {
throw new Exception('execute() requires an object to be passed as the context');
}
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
/* run the first command that wants to handle this */
foreach ($commands as $commandName) {
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Seeing if "%s" wants to handle execution', $commandName);
$command = $ioc->get($commandName);
if (!is_a($command, 'org_tubepress_api_patterns_cor_Command')) {
throw new Exception("{$commandName} does not implement org_tubepress_api_patterns_cor_Command");
}
$ableToHandle = call_user_func_array(array($command, 'execute'), array($context));
if ($ableToHandle === true) {
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, '%s handled execution', $commandName);
return true;
}
}
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'None of the supplied commands were able to handle the execution: ' . implode("', '", $commands));
return false;
}
示例12: _wrappedParse
private function _wrappedParse($content)
{
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$context = $ioc->get('org_tubepress_api_exec_ExecutionContext');
/* what trigger word are we using? */
$keyword = $context->get(org_tubepress_api_const_options_names_Advanced::KEYWORD);
if (!$this->somethingToParse($content, $keyword)) {
return;
}
$toReturn = array();
preg_match("/\\[{$keyword}\\b(.*)\\]/", $content, $matches);
if (sizeof($matches) === 0) {
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'No shortcodes detected in content');
return;
}
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Found a shortcode: %s', $matches[0]);
$context->setActualShortcodeUsed($matches[0]);
/* Anything matched? */
if (isset($matches[1]) && $matches[1] != '') {
$text = preg_replace('/[\\x{00a0}\\x{200b}]+/u', ' ', $matches[1]);
$text = self::_convertQuotes($text);
$pattern = '/(\\w+)\\s*=\\s*"([^"]*)"(?:\\s*,)?(?:\\s|$)|(\\w+)\\s*=\\s*\'([^\']*)\'(?:\\s*,)?(?:\\s|$)|(\\w+)\\s*=\\s*([^\\s\'"]+)(?:\\s*,)?(?:\\s|$)/';
if (preg_match_all($pattern, $text, $match, PREG_SET_ORDER)) {
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Custom options detected in shortcode: %s', $matches[0]);
$toReturn = self::_parseCustomOption($toReturn, $match, $ioc);
$context->setCustomOptions($toReturn);
}
} else {
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'No custom options detected in shortcode: %s', $matches[0]);
}
}
示例13: testCanHandleYouTube
function testCanHandleYouTube()
{
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$execContext = $ioc->get(org_tubepress_api_exec_ExecutionContext::_);
$execContext->shouldReceive('get')->once()->with(org_tubepress_api_const_options_names_Embedded::AUTOPLAY)->andReturn(false);
$execContext->shouldReceive('get')->once()->with(org_tubepress_api_const_options_names_Embedded::PLAYER_COLOR)->andReturn('123456');
$execContext->shouldReceive('get')->once()->with(org_tubepress_api_const_options_names_Embedded::PLAYER_HIGHLIGHT)->andReturn('654321');
$execContext->shouldReceive('get')->once()->with(org_tubepress_api_const_options_names_Embedded::SHOW_INFO)->andReturn(true);
$execContext->shouldReceive('get')->once()->with(org_tubepress_api_const_options_names_Embedded::LOOP)->andReturn(false);
$execContext->shouldReceive('get')->once()->with(org_tubepress_api_const_options_names_Embedded::SHOW_RELATED)->andReturn(true);
$execContext->shouldReceive('get')->once()->with(org_tubepress_api_const_options_names_Embedded::FULLSCREEN)->andReturn(false);
$execContext->shouldReceive('get')->once()->with(org_tubepress_api_const_options_names_Embedded::ENABLE_JS_API)->andReturn(false);
$execContext->shouldReceive('get')->once()->with(org_tubepress_api_const_options_names_Embedded::HIGH_QUALITY)->andReturn(true);
$execContext->shouldReceive('get')->once()->with(org_tubepress_api_const_options_names_Advanced::GALLERY_ID)->andReturn('some-gallery-id');
$execContext->shouldReceive('get')->once()->with(org_tubepress_api_const_options_names_Embedded::AUTOHIDE)->andReturn(true);
$execContext->shouldReceive('get')->once()->with(org_tubepress_api_const_options_names_Embedded::MODEST_BRANDING)->andReturn(false);
$mockTemplate = \Mockery::mock('org_tubepress_api_template_Template');
$mockChainContext = \Mockery::mock('stdClass');
$mockChainContext->providerName = org_tubepress_api_provider_Provider::YOUTUBE;
$mockChainContext->videoId = 'video_id';
$theme = $ioc->get(org_tubepress_api_theme_ThemeHandler::_);
$theme->shouldReceive('getTemplateInstance')->once()->with('embedded_flash/youtube.tpl.php')->andReturn($mockTemplate);
$this->assertTrue($this->_sut->execute($mockChainContext));
$this->assertEquals($mockTemplate, $mockChainContext->template);
$this->assertEquals('http://www.youtube.com/embed/video_id?color1=654321&color2=123456&rel=1&autoplay=0&loop=0&fs=0&showinfo=1&wmode=transparent&enablejsapi=0&autohide=1&modestbranding=0&hd=1', $mockChainContext->dataUrl->toString());
$this->assertEquals('youtube', $mockChainContext->embeddedImplementationName);
}
示例14: testVideoMetaAboveAndBelow
function testVideoMetaAboveAndBelow()
{
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$messageService = $ioc->get(org_tubepress_api_message_MessageService::_);
$messageService->shouldReceive('_')->atLeast()->once()->andReturnUsing(function ($msg) {
return "##{$msg}##";
});
$metaNames = org_tubepress_impl_util_LangUtils::getDefinedConstants(org_tubepress_api_const_options_names_Meta::_);
$shouldShow = array();
$labels = array();
$execContext = $ioc->get(org_tubepress_api_exec_ExecutionContext::_);
$odr = $ioc->get(org_tubepress_api_options_OptionDescriptorReference::_);
$odr->shouldReceive('findOneByName')->times(17)->andReturnUsing(function ($m) {
$mock = \Mockery::mock(org_tubepress_api_options_OptionDescriptor::_);
$mock->shouldReceive('getLabel')->once()->andReturn('video-' . $m);
return $mock;
});
foreach ($metaNames as $metaName) {
$shouldShow[$metaName] = "<<value of {$metaName}>>";
$labels[$metaName] = '##video-' . $metaName . '##';
$execContext->shouldReceive('get')->once()->with($metaName)->andReturnUsing(function ($m) {
return "<<value of {$m}>>";
});
}
$mockTemplate = \Mockery::mock(org_tubepress_api_template_Template::_);
$mockTemplate->shouldReceive('setVariable')->once()->with(org_tubepress_api_const_template_Variable::META_SHOULD_SHOW, $shouldShow);
$mockTemplate->shouldReceive('setVariable')->once()->with(org_tubepress_api_const_template_Variable::META_LABELS, $labels);
$providerResult = \Mockery::mock('org_tubepress_api_provider_ProviderResult');
$this->assertEquals($mockTemplate, $this->_sut->alter_galleryTemplate($mockTemplate, $providerResult, 1, org_tubepress_api_provider_Provider::YOUTUBE));
}
示例15: testHeadMetaPageTwo
function testHeadMetaPageTwo()
{
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$qss = $ioc->get(org_tubepress_api_http_HttpRequestParameterService::_);
$qss->shouldReceive('getParamValueAsInt')->once()->with(org_tubepress_api_const_http_ParamName::PAGE, 1)->andReturn(2);
$this->assertEquals('<meta name="robots" content="noindex, nofollow" />', $this->_sut->getHeadHtmlMeta());
}