本文整理汇总了PHP中Oro\Bundle\ConfigBundle\Config\ConfigManager::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigManager::get方法的具体用法?PHP ConfigManager::get怎么用?PHP ConfigManager::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\ConfigBundle\Config\ConfigManager
的用法示例。
在下文中一共展示了ConfigManager::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* @param string $dataClass Parent entity class name
* @param File|Attachment $entity File entity
* @param string $fieldName Field name where new file/image field was added
*
* @return \Symfony\Component\Validator\ConstraintViolationListInterface
*/
public function validate($dataClass, $entity, $fieldName = '')
{
/** @var Config $entityAttachmentConfig */
if ($fieldName === '') {
$entityAttachmentConfig = $this->attachmentConfigProvider->getConfig($dataClass);
$mimeTypes = $this->getMimeArray($entityAttachmentConfig->get('mimetypes'));
if (!$mimeTypes) {
$mimeTypes = array_merge($this->getMimeArray($this->config->get('oro_attachment.upload_file_mime_types')), $this->getMimeArray($this->config->get('oro_attachment.upload_image_mime_types')));
}
} else {
$entityAttachmentConfig = $this->attachmentConfigProvider->getConfig($dataClass, $fieldName);
/** @var FieldConfigId $fieldConfigId */
$fieldConfigId = $entityAttachmentConfig->getId();
if ($fieldConfigId->getFieldType() === 'file') {
$configValue = 'upload_file_mime_types';
} else {
$configValue = 'upload_image_mime_types';
}
$mimeTypes = $this->getMimeArray($this->config->get('oro_attachment.' . $configValue));
}
$fileSize = $entityAttachmentConfig->get('maxsize') * 1024 * 1024;
foreach ($mimeTypes as $id => $value) {
$mimeTypes[$id] = trim($value);
}
return $this->validator->validate($entity->getFile(), [new FileConstraint(['maxSize' => $fileSize, 'mimeTypes' => $mimeTypes])]);
}
示例2: process
/**
* Applies the given notifications to the given object
*
* @param mixed $object
* @param EmailNotificationInterface[] $notifications
* @param LoggerInterface $logger Override for default logger. If this parameter is specified
* this logger will be used instead of a logger specified
* in the constructor
*/
public function process($object, $notifications, LoggerInterface $logger = null)
{
if (!$logger) {
$logger = $this->logger;
}
foreach ($notifications as $notification) {
$emailTemplate = $notification->getTemplate();
try {
list($subjectRendered, $templateRendered) = $this->renderer->compileMessage($emailTemplate, ['entity' => $object]);
} catch (\Twig_Error $e) {
$identity = method_exists($emailTemplate, '__toString') ? (string) $emailTemplate : $emailTemplate->getSubject();
$logger->error(sprintf('Rendering of email template "%s" failed. %s', $identity, $e->getMessage()), ['exception' => $e]);
continue;
}
$senderEmail = $this->cm->get('oro_notification.email_notification_sender_email');
$senderName = $this->cm->get('oro_notification.email_notification_sender_name');
if ($notification instanceof SenderAwareEmailNotificationInterface && $notification->getSenderEmail()) {
$senderEmail = $notification->getSenderEmail();
$senderName = $notification->getSenderName();
}
if ($emailTemplate->getType() == 'txt') {
$type = 'text/plain';
} else {
$type = 'text/html';
}
foreach ((array) $notification->getRecipientEmails() as $email) {
$message = \Swift_Message::newInstance()->setSubject($subjectRendered)->setFrom($senderEmail, $senderName)->setTo($email)->setBody($templateRendered, $type);
$this->mailer->send($message);
}
$this->addJob(self::SEND_COMMAND);
}
}
示例3: getConfigValue
/**
* @param string $name
* @return array|string
*/
protected function getConfigValue($name)
{
if (!$this->configManager) {
$this->configManager = $this->container->get('oro_config.manager');
}
return $this->configManager->get($name);
}
示例4: process
/**
* Applies the given notifications to the given object
*
* @param mixed $object
* @param EmailNotificationInterface[] $notifications
* @param LoggerInterface $logger Override for default logger. If this parameter is specified
* this logger will be used instead of a logger specified
* in the constructor
*/
public function process($object, $notifications, LoggerInterface $logger = null)
{
if (!$logger) {
$logger = $this->logger;
}
foreach ($notifications as $notification) {
/** @var EmailTemplate $emailTemplate */
$emailTemplate = $notification->getTemplate();
try {
list($subjectRendered, $templateRendered) = $this->renderer->compileMessage($emailTemplate, array('entity' => $object));
} catch (\Twig_Error $e) {
$logger->error(sprintf('Rendering of email template "%s"%s failed. %s', $emailTemplate->getSubject(), method_exists($emailTemplate, 'getId') ? sprintf(' (id: %d)', $emailTemplate->getId()) : '', $e->getMessage()), array('exception' => $e));
continue;
}
$senderEmail = $this->cm->get('oro_notification.email_notification_sender_email');
$senderName = $this->cm->get('oro_notification.email_notification_sender_name');
$type = $emailTemplate->getType() == 'txt' ? 'text/plain' : 'text/html';
$recipients = $notification->getRecipientEmails();
foreach ((array) $recipients as $email) {
$message = \Swift_Message::newInstance()->setSubject($subjectRendered)->setFrom($senderEmail, $senderName)->setTo($email)->setBody($templateRendered, $type);
$this->mailer->send($message);
}
$this->addJob(self::SEND_COMMAND);
}
}
示例5: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$defaultWysiwygOptions = ['plugins' => ['textcolor', 'code', 'link', 'bdesk_photo'], 'toolbar_type' => self::TOOLBAR_DEFAULT, 'skin_url' => 'bundles/oroform/css/tinymce', 'valid_elements' => implode(',', $this->htmlTagProvider->getAllowedElements()), 'menubar' => false, 'statusbar' => false, 'relative_urls' => false, 'remove_script_host' => false, 'convert_urls' => true];
$defaults = ['wysiwyg_enabled' => (bool) $this->configManager->get('oro_form.wysiwyg_enabled'), 'wysiwyg_options' => $defaultWysiwygOptions, 'page-component' => ['module' => 'oroui/js/app/components/view-component', 'options' => ['view' => 'oroform/js/app/views/wysiwig-editor/wysiwyg-editor-view', 'content_css' => 'bundles/oroform/css/wysiwyg-editor.css']]];
$resolver->setDefaults($defaults);
$resolver->setNormalizers(['wysiwyg_options' => function (Options $options, $wysiwygOptions) use($defaultWysiwygOptions) {
if (empty($wysiwygOptions['toolbar_type']) || !array_key_exists($wysiwygOptions['toolbar_type'], $this->toolbars)) {
$toolbarType = self::TOOLBAR_DEFAULT;
} else {
$toolbarType = $wysiwygOptions['toolbar_type'];
}
$wysiwygOptions['toolbar'] = $this->toolbars[$toolbarType];
$wysiwygOptions = array_merge($defaultWysiwygOptions, $wysiwygOptions);
unset($wysiwygOptions['toolbar_type']);
return $wysiwygOptions;
}, 'attr' => function (Options $options, $attr) {
$pageComponent = $options->get('page-component');
$wysiwygOptions = (array) $options->get('wysiwyg_options');
if ($this->assetHelper) {
if (!empty($pageComponent['options']['content_css'])) {
$pageComponent['options']['content_css'] = $this->assetHelper->getUrl($pageComponent['options']['content_css']);
}
if (!empty($wysiwygOptions['skin_url'])) {
$wysiwygOptions['skin_url'] = $this->assetHelper->getUrl($wysiwygOptions['skin_url']);
}
}
$pageComponent['options'] = array_merge($pageComponent['options'], $wysiwygOptions);
$pageComponent['options']['enabled'] = (bool) $options->get('wysiwyg_enabled');
$attr['data-page-component-module'] = $pageComponent['module'];
$attr['data-page-component-options'] = json_encode($pageComponent['options']);
return $attr;
}]);
}
示例6: isFresh
/**
* Check whenever given language package up to date
*
* @param string $languageCode
*
* @return bool
*/
public function isFresh($languageCode)
{
if (!isset($this->processedLanguages[$languageCode])) {
$configData = $this->cm->get(TranslationStatusInterface::META_CONFIG_KEY);
$stats = $this->statisticProvider->get();
if (isset($configData[$languageCode])) {
$stats = array_filter($stats, function ($langInfo) use($languageCode) {
return $langInfo['code'] === $languageCode;
});
$lang = array_pop($stats);
if ($lang) {
$installationDate = $this->getDateTimeFromString($configData[$languageCode]['lastBuildDate']);
$currentBuildDate = $this->getDateTimeFromString($lang['lastBuildDate']);
$this->processedLanguages[$languageCode] = $installationDate >= $currentBuildDate;
} else {
// could not retrieve current language stats, so assume that it's fresh
$this->processedLanguages[$languageCode] = true;
}
} else {
// if we do not have information about installed time then assume that needs update
$this->processedLanguages[$languageCode] = false;
}
}
return $this->processedLanguages[$languageCode];
}
示例7: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$isWysiwygEnabled = $this->configManager->get('oro_form.wysiwyg_enabled');
$resolver->setDefaults(['translatable_class' => 'Oro\\Bundle\\EmailBundle\\Entity\\EmailTemplate', 'intention' => 'emailtemplate_translation', 'extra_fields_message' => 'This form should not contain extra fields: "{{ extra_fields }}"', 'cascade_validation' => true, 'labels' => [], 'content_options' => [], 'subject_options' => [], 'fields' => function (Options $options) use($isWysiwygEnabled) {
return ['subject' => array_merge(['field_type' => 'text'], $options->get('subject_options')), 'content' => array_merge(['field_type' => 'oro_rich_text', 'attr' => ['class' => 'template-editor', 'data-wysiwyg-enabled' => $isWysiwygEnabled], 'wysiwyg_options' => ['height' => '250px']], $options->get('content_options'))];
}]);
}
示例8: isDefaultBranch
public function isDefaultBranch(Branch $branch)
{
$defaultBranchId = $this->manager->get('diamante_email_processing.default_branch');
if (empty($defaultBranchId)) {
return false;
}
return (int) $defaultBranchId === $branch->getId();
}
示例9: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name', 'text', ['label' => 'orob2b.rfp.requeststatus.name.label', 'required' => true])->add('sortOrder', 'integer', ['label' => 'orob2b.rfp.requeststatus.sort_order.label', 'required' => true]);
$lang = $this->localeSettings->getLanguage();
$notificationLangs = $this->userConfig->get('oro_locale.languages');
$notificationLangs = array_unique(array_merge($notificationLangs, [$lang]));
$localeLabels = $this->localeSettings->getLocalesByCodes($notificationLangs, $lang);
$builder->add('translations', 'orob2b_rfp_request_status_translation', ['label' => 'orob2b.rfp.requeststatus.label.label', 'required' => false, 'locales' => $notificationLangs, 'labels' => $localeLabels]);
}
示例10: addApplicationUrl
/**
* @param array $result
* @param bool $addValue
*/
protected function addApplicationUrl(array &$result, $addValue)
{
if ($addValue) {
$val = $this->configManager->get('oro_ui.application_url');
} else {
$val = ['type' => 'string', 'label' => $this->translator->trans('oro.email.emailtemplate.app_url')];
}
$result['appURL'] = $val;
}
示例11: build
/**
* Modify menu by adding, removing or editing items.
*
* @param \Knp\Menu\ItemInterface $menu
* @param array $options
* @param string|null $alias
*/
public function build(ItemInterface $menu, array $options = array(), $alias = null)
{
$options['orderBy'] = array(array('field' => NavigationHistoryItem::NAVIGATION_HISTORY_COLUMN_VISIT_COUNT));
$maxItems = $this->configOptions->get('oro_navigation.maxItems');
if (!is_null($maxItems)) {
$options['maxItems'] = $maxItems;
}
parent::build($menu, $options, $alias);
}
示例12: sendEmail
/**
* @param UserInterface $user
* @param array $templateData
* @param string $type
*
* @return int The return value is the number of recipients who were accepted for delivery
*/
protected function sendEmail(UserInterface $user, array $templateData, $type)
{
list($subjectRendered, $templateRendered) = $templateData;
$senderEmail = $this->configManager->get('oro_notification.email_notification_sender_email');
$senderName = $this->configManager->get('oro_notification.email_notification_sender_name');
$email = $this->emailHolderHelper->getEmail($user);
$message = \Swift_Message::newInstance()->setSubject($subjectRendered)->setFrom($senderEmail, $senderName)->setTo($email)->setBody($templateRendered, $type);
return $this->mailer->send($message);
}
示例13: preSubmit
/**
* Preset default values if default checkbox set
*
* @param FormEvent $event
*/
public function preSubmit(FormEvent $event)
{
$data = $event->getData();
foreach ($data as $key => $val) {
if (!empty($val['use_parent_scope_value'])) {
$data[$key]['value'] = $this->configManager->get(str_replace(ConfigManager::SECTION_VIEW_SEPARATOR, ConfigManager::SECTION_MODEL_SEPARATOR, $key), true);
}
}
$event->setData($data);
}
示例14: getAction
/**
* Get the current configuration
*
* @AclAncestor("oro_config_system")
*
* @return JsonResponse
*/
public function getAction()
{
$data = [];
foreach ($this->options as $option) {
$viewKey = $option['section'] . ConfigManager::SECTION_VIEW_SEPARATOR . $option['name'];
$modelKey = $option['section'] . ConfigManager::SECTION_MODEL_SEPARATOR . $option['name'];
$data[$viewKey] = ['value' => $this->configManager->get($modelKey), 'scope' => 'app', 'use_parent_scope_value' => false];
}
return new JsonResponse($data);
}
示例15: configureCredentials
/**
* Configure credentials
*
* @param ConfigManager $configManager
*/
public function configureCredentials(ConfigManager $configManager)
{
$clientIdKey = sprintf('oro_sso.%s_sso_client_id', $this->getName());
if ($clientId = $configManager->get($clientIdKey)) {
$this->options['client_id'] = $clientId;
}
$clientSecretKey = sprintf('oro_sso.%s_sso_client_secret', $this->getName());
if ($clientSecret = $configManager->get($clientSecretKey)) {
$this->options['client_secret'] = $clientSecret;
}
}