private function _registerOauthClient(tubepress_api_ioc_ContainerInterface $container) { $container->register('ehough_coauthor_spi_v1_TemporaryCredentialsStorageInterface', 'ehough_coauthor_impl_v1_SessionCredentialsStorage')->addArgument(false); $container->register('ehough_coauthor_spi_v1_SignerInterface', 'ehough_coauthor_impl_v1_Signer'); $container->register('ehough_coauthor_spi_v1_RemoteCredentialsFetcherInterface', 'ehough_coauthor_impl_v1_DefaultRemoteCredentialsFetcher')->addArgument(new tubepress_impl_ioc_Reference('ehough_shortstop_api_HttpClientInterface'))->addArgument(new tubepress_impl_ioc_Reference('ehough_coauthor_spi_v1_SignerInterface')); $container->register('ehough_coauthor_api_v1_ClientInterface', 'ehough_coauthor_impl_v1_DefaultV1Client')->addArgument(new tubepress_impl_ioc_Reference('ehough_coauthor_spi_v1_TemporaryCredentialsStorageInterface'))->addArgument(new tubepress_impl_ioc_Reference('ehough_coauthor_spi_v1_RemoteCredentialsFetcherInterface'))->addArgument(new tubepress_impl_ioc_Reference('ehough_coauthor_spi_v1_SignerInterface')); }
public static function registerChainDefinitionByClassNames(tubepress_api_ioc_ContainerInterface $container, $chainName, array $classNames) { $references = array(); foreach ($classNames as $className) { $container->register($className, $className); array_push($references, new ehough_iconic_Reference($className)); } self::registerChainDefinitionByReferences($container, $chainName, $references); }
private function _registerPluggables(tubepress_api_ioc_ContainerInterface $container) { $container->register('tubepress_addons_jwplayer_impl_embedded_JwPlayerPluggableEmbeddedPlayerService', 'tubepress_addons_jwplayer_impl_embedded_JwPlayerPluggableEmbeddedPlayerService')->addTag(tubepress_spi_embedded_PluggableEmbeddedPlayerService::_); $container->register('tubepress_addons_jwplayer_impl_options_JwPlayerOptionsProvider', 'tubepress_addons_jwplayer_impl_options_JwPlayerOptionsProvider')->addTag(tubepress_spi_options_PluggableOptionDescriptorProvider::_); $fieldIndex = 0; $fieldMap = array(tubepress_addons_jwplayer_api_const_options_names_Embedded::COLOR_BACK => 'tubepress_impl_options_ui_fields_SpectrumColorField', tubepress_addons_jwplayer_api_const_options_names_Embedded::COLOR_FRONT => 'tubepress_impl_options_ui_fields_SpectrumColorField', tubepress_addons_jwplayer_api_const_options_names_Embedded::COLOR_LIGHT => 'tubepress_impl_options_ui_fields_SpectrumColorField', tubepress_addons_jwplayer_api_const_options_names_Embedded::COLOR_SCREEN => 'tubepress_impl_options_ui_fields_SpectrumColorField'); foreach ($fieldMap as $name => $class) { $container->register('jwplayer_field_' . $fieldIndex++, $class)->addArgument($name); } $fieldReferences = array(); for ($x = 0; $x < $fieldIndex; $x++) { $fieldReferences[] = new tubepress_impl_ioc_Reference('jwplayer_field_' . $x); } $map = array(tubepress_addons_core_api_const_options_ui_OptionsPageParticipantConstants::CATEGORY_ID_PLAYER => array(tubepress_addons_jwplayer_api_const_options_names_Embedded::COLOR_BACK, tubepress_addons_jwplayer_api_const_options_names_Embedded::COLOR_FRONT, tubepress_addons_jwplayer_api_const_options_names_Embedded::COLOR_LIGHT, tubepress_addons_jwplayer_api_const_options_names_Embedded::COLOR_SCREEN)); $container->register('jw_player_options_page_participant', 'tubepress_impl_options_ui_BaseOptionsPageParticipant')->addArgument('jwplayer_participant')->addArgument('JW Player')->addArgument(array())->addArgument($fieldReferences)->addArgument($map)->addTag('tubepress_spi_options_ui_PluggableOptionsPageParticipantInterface'); }
/** * Provides add-ons with the ability to modify the TubePress IOC container * before it is put into production. * * @param tubepress_api_ioc_ContainerInterface $container The core IOC container. * * @throws InvalidArgumentException If a service tag doesn't include the event attribute. * * @api * @since 3.1.0 */ public function process(tubepress_api_ioc_ContainerInterface $container) { if (!$container->hasDefinition(tubepress_api_event_EventDispatcherInterface::_)) { return; } $eventDispatcherDefinition = $container->getDefinition(tubepress_api_event_EventDispatcherInterface::_); $listenerServiceIds = $container->findTaggedServiceIds(tubepress_api_ioc_ContainerExtensionInterface::TAG_EVENT_LISTENER); foreach ($listenerServiceIds as $serviceId => $events) { foreach ($events as $event) { $priority = isset($event['priority']) ? $event['priority'] : 0; if (!isset($event['event'])) { throw new InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "%s" tags.', $serviceId, tubepress_api_ioc_ContainerExtensionInterface::TAG_EVENT_LISTENER)); } if (!isset($event['method'])) { $onSuffix = preg_replace_callback(array('/(?<=\\b)[a-z]/i', '/[^a-z0-9]/i'), array($this, '_callbackStrToUpper'), $event['event']); $event['method'] = 'on' . $onSuffix; $event['method'] = preg_replace('/[^a-z0-9]/i', '', $event['method']); } $eventDispatcherDefinition->addMethodCall('addListenerService', array($event['event'], array($serviceId, $event['method']), $priority)); } } }
/** * Provides add-ons with the ability to modify the TubePress IOC container * before it is put into production. * * @param tubepress_api_ioc_ContainerInterface $container The core IOC container. * * @throws InvalidArgumentException If a service tag doesn't include the event attribute. * * @api * @since 3.1.0 */ public function process(tubepress_api_ioc_ContainerInterface $container) { $consumerIds = $container->findTaggedServiceIds(tubepress_api_ioc_ContainerExtensionInterface::TAG_TAGGED_SERVICES_CONSUMER); foreach ($consumerIds as $consumerId => $tags) { $consumerDefinition = $container->getDefinition($consumerId); foreach ($tags as $tagData) { if (!isset($tagData['tag'])) { throw new InvalidArgumentException('Tagged set consumers must specify which tagged services they would like to consume'); } $matchingServiceIds = $container->findTaggedServiceIds($tagData['tag']); if (empty($matchingServiceIds)) { continue; } if (!isset($tagData['method'])) { throw new InvalidArgumentException('Tagged set consumers must specify which method to run for each tagged service ID'); } $references = array(); foreach ($matchingServiceIds as $id => $attributes) { $references[] = new tubepress_impl_ioc_Reference($id); } $consumerDefinition->addMethodCall($tagData['method'], array($references)); } } }
private function _07_recordFinishTime() { if (!$this->_bootLogger->isEnabled()) { return; } $now = microtime(true); $this->_logDebug(sprintf('Boot completed in <code>%f</code> milliseconds. Actual performance will be better when debugging is not active.', ($now - $this->_startTime) * 1000.0)); /** * @var $realLogger tubepress_api_log_LoggerInterface */ $realLogger = self::$_SERVICE_CONTAINER->get(tubepress_api_log_LoggerInterface::_); /** * Flush the boot logger to the real logger. */ $this->_bootLogger->flushTo($realLogger); $this->_bootLogger->onBootComplete(); /** * Activate the real logger. */ $realLogger->onBootComplete(); }
private function _registerOptionsPageParticipant(tubepress_api_ioc_ContainerInterface $container) { $fieldIndex = 0; $container->register('youtube_options_field_' . $fieldIndex++, 'tubepress_impl_options_ui_fields_TextField')->addArgument(tubepress_addons_youtube_api_const_options_names_Feed::DEV_KEY)->addMethodCall('setSize', array(120)); $gallerySourceMap = array(array(tubepress_addons_youtube_api_const_options_values_GallerySourceValue::YOUTUBE_SEARCH, 'tubepress_impl_options_ui_fields_TextField', tubepress_addons_youtube_api_const_options_names_GallerySource::YOUTUBE_TAG_VALUE), array(tubepress_addons_youtube_api_const_options_values_GallerySourceValue::YOUTUBE_USER, 'tubepress_impl_options_ui_fields_TextField', tubepress_addons_youtube_api_const_options_names_GallerySource::YOUTUBE_USER_VALUE), array(tubepress_addons_youtube_api_const_options_values_GallerySourceValue::YOUTUBE_PLAYLIST, 'tubepress_impl_options_ui_fields_TextField', tubepress_addons_youtube_api_const_options_names_GallerySource::YOUTUBE_PLAYLIST_VALUE), array(tubepress_addons_youtube_api_const_options_values_GallerySourceValue::YOUTUBE_FAVORITES, 'tubepress_impl_options_ui_fields_TextField', tubepress_addons_youtube_api_const_options_names_GallerySource::YOUTUBE_FAVORITES_VALUE), array(tubepress_addons_youtube_api_const_options_values_GallerySourceValue::YOUTUBE_MOST_POPULAR, 'tubepress_impl_options_ui_fields_DropdownField', tubepress_addons_youtube_api_const_options_names_GallerySource::YOUTUBE_MOST_POPULAR_VALUE), array(tubepress_addons_youtube_api_const_options_values_GallerySourceValue::YOUTUBE_RELATED, 'tubepress_impl_options_ui_fields_TextField', tubepress_addons_youtube_api_const_options_names_GallerySource::YOUTUBE_RELATED_VALUE)); foreach ($gallerySourceMap as $gallerySourceFieldArray) { $container->register('youtube_options_subfield_' . $fieldIndex, $gallerySourceFieldArray[1])->addArgument($gallerySourceFieldArray[2]); $container->register('youtube_options_field_' . $fieldIndex, 'tubepress_impl_options_ui_fields_GallerySourceRadioField')->addArgument($gallerySourceFieldArray[0])->addArgument(new tubepress_impl_ioc_Reference('youtube_options_subfield_' . $fieldIndex++)); } $fieldMap = array(tubepress_addons_youtube_api_const_options_names_Embedded::AUTOHIDE => 'tubepress_impl_options_ui_fields_DropdownField', tubepress_addons_youtube_api_const_options_names_Embedded::CLOSED_CAPTIONS => 'tubepress_impl_options_ui_fields_BooleanField', tubepress_addons_youtube_api_const_options_names_Embedded::DISABLE_KEYBOARD => 'tubepress_impl_options_ui_fields_BooleanField', tubepress_addons_youtube_api_const_options_names_Embedded::FULLSCREEN => 'tubepress_impl_options_ui_fields_BooleanField', tubepress_addons_youtube_api_const_options_names_Embedded::MODEST_BRANDING => 'tubepress_impl_options_ui_fields_BooleanField', tubepress_addons_youtube_api_const_options_names_Embedded::SHOW_ANNOTATIONS => 'tubepress_impl_options_ui_fields_BooleanField', tubepress_addons_youtube_api_const_options_names_Embedded::SHOW_RELATED => 'tubepress_impl_options_ui_fields_BooleanField', tubepress_addons_youtube_api_const_options_names_Embedded::THEME => 'tubepress_impl_options_ui_fields_DropdownField', tubepress_addons_youtube_api_const_options_names_Embedded::SHOW_CONTROLS => 'tubepress_impl_options_ui_fields_DropdownField', tubepress_addons_youtube_api_const_options_names_Feed::FILTER => 'tubepress_impl_options_ui_fields_DropdownField', tubepress_addons_youtube_api_const_options_names_Feed::EMBEDDABLE_ONLY => 'tubepress_impl_options_ui_fields_BooleanField'); foreach ($fieldMap as $id => $class) { $container->register('youtube_options_field_' . $fieldIndex++, $class)->addArgument($id); } $fieldReferences = array(); for ($x = 0; $x < $fieldIndex; $x++) { $fieldReferences[] = new tubepress_impl_ioc_Reference('youtube_options_field_' . $x); } $map = array(tubepress_addons_core_api_const_options_ui_OptionsPageParticipantConstants::CATEGORY_ID_GALLERYSOURCE => array(tubepress_addons_youtube_api_const_options_values_GallerySourceValue::YOUTUBE_SEARCH, tubepress_addons_youtube_api_const_options_values_GallerySourceValue::YOUTUBE_USER, tubepress_addons_youtube_api_const_options_values_GallerySourceValue::YOUTUBE_PLAYLIST, tubepress_addons_youtube_api_const_options_values_GallerySourceValue::YOUTUBE_FAVORITES, tubepress_addons_youtube_api_const_options_values_GallerySourceValue::YOUTUBE_MOST_POPULAR, tubepress_addons_youtube_api_const_options_values_GallerySourceValue::YOUTUBE_RELATED), tubepress_addons_core_api_const_options_ui_OptionsPageParticipantConstants::CATEGORY_ID_PLAYER => array(tubepress_addons_youtube_api_const_options_names_Embedded::AUTOHIDE, tubepress_addons_youtube_api_const_options_names_Embedded::CLOSED_CAPTIONS, tubepress_addons_youtube_api_const_options_names_Embedded::DISABLE_KEYBOARD, tubepress_addons_youtube_api_const_options_names_Embedded::FULLSCREEN, tubepress_addons_youtube_api_const_options_names_Embedded::MODEST_BRANDING, tubepress_addons_youtube_api_const_options_names_Embedded::SHOW_ANNOTATIONS, tubepress_addons_youtube_api_const_options_names_Embedded::SHOW_RELATED, tubepress_addons_youtube_api_const_options_names_Embedded::THEME, tubepress_addons_youtube_api_const_options_names_Embedded::SHOW_CONTROLS), tubepress_addons_core_api_const_options_ui_OptionsPageParticipantConstants::CATEGORY_ID_FEED => array(tubepress_addons_youtube_api_const_options_names_Feed::FILTER, tubepress_addons_youtube_api_const_options_names_Feed::DEV_KEY, tubepress_addons_youtube_api_const_options_names_Feed::EMBEDDABLE_ONLY)); $container->register('youtube_options_page_participant', 'tubepress_impl_options_ui_BaseOptionsPageParticipant')->addArgument('youtube_participant')->addArgument('YouTube')->addArgument(array())->addArgument($fieldReferences)->addArgument($map)->addTag('tubepress_spi_options_ui_PluggableOptionsPageParticipantInterface'); }
private function _setEphemeralServicesToContainer(tubepress_api_ioc_ContainerInterface $tubePressContainer, \Symfony\Component\DependencyInjection\ContainerInterface $symfonyContainer) { $tubePressContainer->set('tubepress_api_ioc_ContainerInterface', $tubePressContainer); $tubePressContainer->set('symfony_service_container', $symfonyContainer); $tubePressContainer->set('tubepress_internal_logger_BootLogger', $this->_logger); $tubePressContainer->set(tubepress_api_boot_BootSettingsInterface::_, $this->_bootSettings); }
/** * You can modify the container here before it is dumped to PHP code. * * @param tubepress_api_ioc_ContainerInterface $self * * @api */ public function process(tubepress_api_ioc_ContainerInterface $self) { $parameters = $this->_delegate->getParameterBag()->all(); /** * These will all be tubepress_impl_ioc_IconicDefinitionWrapper instances */ $definitions = $self->getDefinitions(); /** * @var $extension tubepress_api_ioc_ContainerExtensionInterface */ foreach ($this->_extensions as $extension) { $tmpContainer = new tubepress_impl_ioc_IconicContainer($this->_delegate->getParameterBag()); $extension->load($tmpContainer); $this->merge($tmpContainer); } $self->addDefinitions($definitions); $this->_delegate->getParameterBag()->add($parameters); }
/** * Allows extensions to load services into the TubePress IOC container. * * @param tubepress_api_ioc_ContainerInterface $container A tubepress_api_ioc_ContainerInterface instance. * * @return void * * @api * @since 3.1.0 */ public final function load(tubepress_api_ioc_ContainerInterface $container) { $container->register('tubepress_addons_embedplus_impl_embedded_EmbedPlusPluggableEmbeddedPlayerService', 'tubepress_addons_embedplus_impl_embedded_EmbedPlusPluggableEmbeddedPlayerService')->addTag(tubepress_spi_embedded_PluggableEmbeddedPlayerService::_); }
private function _registerHttpRequestDefaultHeadersListener(tubepress_api_ioc_ContainerInterface $container) { $container->register('ehough_shortstop_impl_listeners_request_RequestDefaultHeadersListener', 'ehough_shortstop_impl_listeners_request_RequestDefaultHeadersListener')->addArgument(new tubepress_impl_ioc_Reference('ehough_shortstop_spi_HttpContentDecoder'))->addTag(self::TAG_EVENT_LISTENER, array('event' => ehough_shortstop_api_Events::REQUEST, 'method' => 'onPreRequest', 'priority' => 10000)); }
private function _registerWpFunctionWrapper(tubepress_api_ioc_ContainerInterface $container) { $container->register(tubepress_addons_wordpress_spi_WordPressFunctionWrapper::_, 'tubepress_addons_wordpress_impl_DefaultWordPressFunctionWrapper'); }