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


PHP Plugin\PluginManagerInterface类代码示例

本文整理汇总了PHP中Drupal\Component\Plugin\PluginManagerInterface的典型用法代码示例。如果您正苦于以下问题:PHP PluginManagerInterface类的具体用法?PHP PluginManagerInterface怎么用?PHP PluginManagerInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __construct

 /**
  * Constructs an EntityComparisonBase object.
  *
  * @param DiffFormatter $diff_formatter
  *   Diff formatter service.
  * @param DateFormatter $date
  *   DateFormatter service.
  * @param PluginManagerInterface $plugin_manager
  *   The Plugin manager service.
  * @param DiffEntityParser $entityParser
  *   The diff field builder plugin manager.
  */
 public function __construct(DiffFormatter $diff_formatter, DateFormatter $date, PluginManagerInterface $plugin_manager, DiffEntityParser $entityParser)
 {
     $this->diffFormatter = $diff_formatter;
     $this->date = $date;
     $this->fieldTypeDefinitions = $plugin_manager->getDefinitions();
     $this->config = $this->config('diff.settings');
     $this->pluginsConfig = $this->config('diff.plugins');
     $this->nonBreakingSpace = new FormattableMarkup(' ', array());
     $this->entityParser = $entityParser;
 }
开发者ID:Progressable,项目名称:openway8,代码行数:22,代码来源:EntityComparisonBase.php

示例2: testGetWithConfigurablePlugin

 /**
  * Tests the get() method with a configurable plugin.
  */
 public function testGetWithConfigurablePlugin()
 {
     $plugin = $this->getMock('Drupal\\search\\Plugin\\ConfigurableSearchPluginInterface');
     $plugin->expects($this->once())->method('setSearchPageId')->with('fruit_stand')->will($this->returnValue($plugin));
     $this->pluginManager->expects($this->once())->method('createInstance')->will($this->returnValue($plugin));
     $this->assertSame($plugin, $this->searchPluginBag->get('banana'));
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:SearchPluginBagTest.php

示例3: convert

    /**
     * {@inheritdoc}
     */
    public function convert(TargetInterface $target)
    {
        /** @var \Pharborist\Functions\FunctionDeclarationNode $function */
        $function = $target->getIndexer('function')->get('hook_user_login');
        // The $edit parameter is defunct in Drupal 8, but we'll leave it in
        // there as an empty array to prevent errors, and move it to the back
        // of the line.
        /** @var \Pharborist\Functions\ParameterNode $edit */
        $edit = $function->getParameterList()->shift()->setReference(FALSE)->setValue(ArrayNode::create([]));
        $function->appendParameter($edit);
        // Slap a FIXME on the hook implementation, informing the developer that
        // $edit and $category are dead.
        $comment = $function->getDocComment();
        $comment_text = $comment ? $comment->getCommentText() : '';
        if ($comment_text) {
            $comment_text .= "\n\n";
        }
        $comment_text .= <<<'END'
@FIXME
The $edit parameter is gone in Drupal 8. It has been left here in order to
prevent 'undefined variable' errors, but it will never actually be passed to
this hook. You'll need to modify this function and remove every reference to it.
END;
        $function->setDocComment(DocCommentNode::create($comment_text));
        $rewriter = $this->rewriters->createInstance('_rewriter:user');
        $this->rewriteFunction($rewriter, $function->getParameterAtIndex(0), $target);
        $target->save($function);
    }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:31,代码来源:HookUserLogin.php

示例4: convert

 /**
  * {@inheritdoc}
  */
 public function convert(TargetInterface $target)
 {
     // If the hook implementation contains logic, we cannot convert it and
     // that's that. So we'll leave a FIXME and bail out.
     /** @var \Pharborist\Functions\FunctionDeclarationNode $hook */
     $hook = $target->getIndexer('function')->get('hook_menu');
     if ($hook->is(new ContainsLogicFilter())) {
         $hook->setDocComment(DocCommentNode::create($this->pluginDefinition['fixme']));
         $target->save($hook);
         return;
     }
     $hook_menu = new HookMenu($target, $this->routeConverters);
     foreach ($hook_menu->getSourceRoutes() as $path => $route) {
         /** @var \Drupal\drupalmoduleupgrader\Routing\Drupal7\RouteWrapper $route */
         if ($route->containsKey('page callback')) {
             $plugin_id = $this->routeConverters->hasDefinition($route['page callback']) ? $route['page callback'] : 'default';
             /** @var \Drupal\drupalmoduleupgrader\Routing\RouteConverterInterface $converter */
             $this->routeConverters->createInstance($plugin_id)->buildRoute($target, $route);
         }
     }
     $routing = [];
     foreach ($hook_menu->getDestinationRoutes() as $name => $route) {
         $routing[$name] = ['path' => $route->getPath()->__toString(), 'defaults' => $route->getDefaults(), 'requirements' => $route->getRequirements()];
     }
     $this->writeInfo($target, 'routing', $routing);
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:29,代码来源:Routing.php

示例5: getProcess

 /**
  * {@inheritdoc}
  */
 public function getProcess()
 {
     if (!$this->init) {
         $this->init = TRUE;
         $source_plugin = $this->migrationPluginManager->createInstance($this->pluginId)->getSourcePlugin();
         if ($source_plugin instanceof RequirementsInterface) {
             try {
                 $source_plugin->checkRequirements();
             } catch (RequirementsException $e) {
                 // Kill the rest of the method.
                 $source_plugin = [];
             }
         }
         foreach ($source_plugin as $row) {
             $field_type = $row->getSourceProperty('type');
             if (!isset($this->processedFieldTypes[$field_type]) && $this->cckPluginManager->hasDefinition($field_type)) {
                 $this->processedFieldTypes[$field_type] = TRUE;
                 // Allow the cckfield plugin to alter the migration as necessary so
                 // that it knows how to handle fields of this type.
                 if (!isset($this->cckPluginCache[$field_type])) {
                     $this->cckPluginCache[$field_type] = $this->cckPluginManager->createInstance($field_type, [], $this);
                 }
                 call_user_func([$this->cckPluginCache[$field_type], $this->pluginDefinition['cck_plugin_method']], $this);
             }
         }
     }
     return parent::getProcess();
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:31,代码来源:CckMigration.php

示例6: generateFieldMetadata

 /**
  * {@inheritdoc}
  */
 public function generateFieldMetadata(FieldItemListInterface $items, $view_mode)
 {
     $entity = $items->getEntity();
     $field_name = $items->getFieldDefinition()->getName();
     // Early-return if user does not have access.
     $access = $this->accessChecker->accessEditEntityField($entity, $field_name);
     if (!$access) {
         return array('access' => FALSE);
     }
     // Early-return if no editor is available.
     $formatter_id = EntityViewDisplay::collectRenderDisplay($entity, $view_mode)->getRenderer($field_name)->getPluginId();
     $editor_id = $this->editorSelector->getEditor($formatter_id, $items);
     if (!isset($editor_id)) {
         return array('access' => FALSE);
     }
     // Gather metadata, allow the editor to add additional metadata of its own.
     $label = $items->getFieldDefinition()->getLabel();
     $editor = $this->editorManager->createInstance($editor_id);
     $metadata = array('label' => String::checkPlain($label), 'access' => TRUE, 'editor' => $editor_id, 'aria' => t('Entity @type @id, field @field', array('@type' => $entity->getEntityTypeId(), '@id' => $entity->id(), '@field' => $label)));
     $custom_metadata = $editor->getMetadata($items);
     if (count($custom_metadata)) {
         $metadata['custom'] = $custom_metadata;
     }
     return $metadata;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:28,代码来源:MetadataGenerator.php

示例7: initializePlugin

 /**
  * {@inheritdoc}
  */
 protected function initializePlugin($plugin_id)
 {
     if (isset($this->pluginInstances[$plugin_id])) {
         return;
     }
     $this->pluginInstances[$plugin_id] = $this->manager->createInstance($plugin_id, array(), $this->style);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:FullcalendarPluginBag.php

示例8: testManager

 /**
  * Tests the configurable text editor manager.
  */
 public function testManager()
 {
     $this->editorManager = $this->container->get('plugin.manager.editor');
     // Case 1: no text editor available:
     // - listOptions() should return an empty list of options
     // - getAttachments() should return an empty #attachments array (and not
     //   a JS settings structure that is empty)
     $this->assertIdentical(array(), $this->editorManager->listOptions(), 'When no text editor is enabled, the manager works correctly.');
     $this->assertIdentical(array(), $this->editorManager->getAttachments(array()), 'No attachments when no text editor is enabled and retrieving attachments for zero text formats.');
     $this->assertIdentical(array(), $this->editorManager->getAttachments(array('filtered_html', 'full_html')), 'No attachments when no text editor is enabled and retrieving attachments for multiple text formats.');
     // Enable the Text Editor Test module, which has the Unicorn Editor and
     // clear the editor manager's cache so it is picked up.
     $this->enableModules(array('editor_test'));
     $this->editorManager = $this->container->get('plugin.manager.editor');
     $this->editorManager->clearCachedDefinitions();
     // Case 2: a text editor available.
     $this->assertIdentical('Unicorn Editor', (string) $this->editorManager->listOptions()['unicorn'], 'When some text editor is enabled, the manager works correctly.');
     // Case 3: a text editor available & associated (but associated only with
     // the 'Full HTML' text format).
     $unicorn_plugin = $this->editorManager->createInstance('unicorn');
     $editor = entity_create('editor', array('format' => 'full_html', 'editor' => 'unicorn'));
     $editor->save();
     $this->assertIdentical(array(), $this->editorManager->getAttachments(array()), 'No attachments when one text editor is enabled and retrieving attachments for zero text formats.');
     $expected = array('library' => array(0 => 'editor_test/unicorn'), 'drupalSettings' => ['editor' => ['formats' => ['full_html' => ['format' => 'full_html', 'editor' => 'unicorn', 'editorSettings' => $unicorn_plugin->getJSSettings($editor), 'editorSupportsContentFiltering' => TRUE, 'isXssSafe' => FALSE]]]]);
     $this->assertIdentical($expected, $this->editorManager->getAttachments(array('filtered_html', 'full_html')), 'Correct attachments when one text editor is enabled and retrieving attachments for multiple text formats.');
     // Case 4: a text editor available associated, but now with its JS settings
     // being altered via hook_editor_js_settings_alter().
     \Drupal::state()->set('editor_test_js_settings_alter_enabled', TRUE);
     $expected['drupalSettings']['editor']['formats']['full_html']['editorSettings']['ponyModeEnabled'] = FALSE;
     $this->assertIdentical($expected, $this->editorManager->getAttachments(array('filtered_html', 'full_html')), 'hook_editor_js_settings_alter() works correctly.');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:34,代码来源:EditorManagerTest.php

示例9: createInstance

 /**
  * {@inheritdoc}
  */
 public function createInstance($plugin_id, array $configuration = [])
 {
     if ($this->hasDefinition($plugin_id)) {
         return $this->decoratedFactory->createInstance($plugin_id, $configuration);
     } else {
         throw new PluginNotFoundException($plugin_id);
     }
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:11,代码来源:PluginManagerDecorator.php

示例10: initializePlugin

 /**
  * {@inheritdoc}
  */
 protected function initializePlugin($instance_id)
 {
     $configuration = isset($this->configurations[$instance_id]) ? $this->configurations[$instance_id] : array();
     if (!isset($configuration[$this->pluginKey])) {
         throw new PluginNotFoundException($instance_id);
     }
     $this->set($instance_id, $this->manager->createInstance($configuration[$this->pluginKey], $configuration));
 }
开发者ID:jhoffman-tm,项目名称:waldorf-deployment,代码行数:11,代码来源:DefaultLazyPluginCollection.php

示例11: preRenderTextFormat

 /**
  * Additional #pre_render callback for 'text_format' elements.
  */
 function preRenderTextFormat(array $element)
 {
     // Allow modules to programmatically enforce no client-side editor by
     // setting the #editor property to FALSE.
     if (isset($element['#editor']) && !$element['#editor']) {
         return $element;
     }
     // filter_process_format() copies properties to the expanded 'value' child
     // element, including the #pre_render property. Skip this text format
     // widget, if it contains no 'format'.
     if (!isset($element['format'])) {
         return $element;
     }
     $format_ids = array_keys($element['format']['format']['#options']);
     // Early-return if no text editor is associated with any of the text formats.
     $editors = Editor::loadMultiple($format_ids);
     if (count($editors) === 0) {
         return $element;
     }
     // Use a hidden element for a single text format.
     $field_id = $element['value']['#id'];
     if (!$element['format']['format']['#access']) {
         // Use the first (and only) available text format.
         $format_id = $format_ids[0];
         $element['format']['editor'] = array('#type' => 'hidden', '#name' => $element['format']['format']['#name'], '#value' => $format_id, '#attributes' => array('class' => array('editor'), 'data-editor-for' => $field_id));
     } else {
         $element['format']['format']['#attributes']['class'][] = 'editor';
         $element['format']['format']['#attributes']['data-editor-for'] = $field_id;
     }
     // Hide the text format's filters' guidelines of those text formats that have
     // a text editor associated: they're rather useless when using a text editor.
     foreach ($editors as $format_id => $editor) {
         $element['format']['guidelines'][$format_id]['#access'] = FALSE;
     }
     // Attach Text Editor module's (this module) library.
     $element['#attached']['library'][] = 'editor/drupal.editor';
     // Attach attachments for all available editors.
     $element['#attached'] = drupal_merge_attached($element['#attached'], $this->pluginManager->getAttachments($format_ids));
     // Apply XSS filters when editing content if necessary. Some types of text
     // editors cannot guarantee that the end user won't become a victim of XSS.
     if (!empty($element['value']['#value'])) {
         $original = $element['value']['#value'];
         $format = FilterFormat::load($element['format']['format']['#value']);
         // Ensure XSS-safety for the current text format/editor.
         $filtered = editor_filter_xss($original, $format);
         if ($filtered !== FALSE) {
             $element['value']['#value'] = $filtered;
         }
         // Only when the user has access to multiple text formats, we must add data-
         // attributes for the original value and change tracking, because they are
         // only necessary when the end user can switch between text formats/editors.
         if ($element['format']['format']['#access']) {
             $element['value']['#attributes']['data-editor-value-is-changed'] = 'false';
             $element['value']['#attributes']['data-editor-value-original'] = $original;
         }
     }
     return $element;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:61,代码来源:Element.php

示例12: transform

 /**
  * {@inheritdoc}
  */
 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
 {
     $field_type = is_array($value) ? $value[0] : $value;
     try {
         return $this->cckPluginManager->createInstance($field_type, [], $this->migration)->getFieldType($row);
     } catch (PluginNotFoundException $e) {
         return parent::transform($value, $migrate_executable, $row, $destination_property);
     }
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:12,代码来源:FieldType.php

示例13: getPermissions

 /**
  * Returns permissions.
  *
  * @return array[]
  *   The structure is the same as that of *.permissions.yml files.
  */
 public function getPermissions()
 {
     $permissions = [];
     $definitions = $this->paymentMethodConfigurationManager->getDefinitions();
     foreach ($definitions as $plugin_id => $definition) {
         $permissions['payment.payment_method_configuration.create.' . $plugin_id] = array('title' => $this->t('Create %plugin_label payment method configurations', array('%plugin_label' => $definition['label'])));
     }
     return $permissions;
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:15,代码来源:Permissions.php

示例14: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     // Only run key provider settings validation if the form is being submitted
     if ($form_state->isSubmitted()) {
         $plugin = $this->manager->createInstance($form_state->getValue('key_provider'), []);
         $plugin->validateConfigurationForm($form, $form_state);
     }
     parent::validateForm($form, $form_state);
 }
开发者ID:rlhawk,项目名称:key,代码行数:12,代码来源:KeyForm.php

示例15: testFormatTagsSettings

 /**
  * Test the format tags settings.
  *
  * @dataProvider formatTagsSettingsTestCases
  */
 public function testFormatTagsSettings($filter_plugins, $expected_format_tags)
 {
     foreach ($filter_plugins as $filter_plugin_id => $filter_plugin_settings) {
         $this->format->setFilterConfig($filter_plugin_id, $filter_plugin_settings);
     }
     $this->format->save();
     $internal_plugin = $this->ckeditorPluginManager->createInstance('internal', []);
     $plugin_config = $internal_plugin->getConfig($this->editor);
     $this->assertEquals($expected_format_tags, explode(';', $plugin_config['format_tags']));
 }
开发者ID:Greg-Boggs,项目名称:electric-dev,代码行数:15,代码来源:InternalTest.php


注:本文中的Drupal\Component\Plugin\PluginManagerInterface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。