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


PHP Block\BlockBase类代码示例

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


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

示例1: blockForm

 /**
  * Overrides \Drupal\Core\Block\BlockBase::blockForm().
  */
 public function blockForm($form, FormStateInterface $form_state)
 {
     $form = parent::blockForm($form, $form_state);
     // Retrieve existing configuration for this block.
     $config = $this->getConfiguration();
     // Add a form field to the existing block configuration form.
     $form['flickr_items'] = array('#type' => 'select', '#title' => t('Number of items'), '#options' => array(10 => 10, 12 => 12, 15 => 15, 16 => 16, 18 => 18, 20 => 20), '#description' => t('Number of items that will be shown in the slideshow.'), '#default_value' => isset($config['flickr_items']) ? $config['flickr_items'] : '');
     //    $config = $this->configuration;
     //    $defaults = $this->defaultConfiguration();
     //    $form['flickr_items'] = array(
     //      '#type' => 'select',
     //      '#title' => t('Number of items'),
     //      '#options' => array(
     //        10 => 10,
     //        12 => 12,
     //        15 => 15,
     //        16 => 16,
     //        18 => 18,
     //        20 => 20
     //      ),
     //      '#description' => t('This number of items will be shown in the Flickr block'),
     //      '#default_value' => $config['flickr_items'],
     //    );
     //
     return $form;
 }
开发者ID:batigolix,项目名称:doesdesign8,代码行数:29,代码来源:Dd_toolsFlickr.php

示例2: getCacheContexts

 /**
  * {@inheritdoc}
  */
 public function getCacheContexts()
 {
     // The block by itself doesn't really vary by user, but some of its
     // implementations are (collection module, I'm looking at you). For the sake
     // of semplicity, we add the user context here already.
     $contexts = parent::getCacheContexts();
     return Cache::mergeContexts($contexts, ['user']);
 }
开发者ID:ec-europa,项目名称:joinup-dev,代码行数:11,代码来源:GroupHeaderBlock.php

示例3: __construct

 /**
  * CircleBreadcrumbs constructor.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, MenuLinkManagerInterface $link, MenuActiveTrailInterface $active, $link_tree)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->linkManager = $link;
     $this->active = $active;
     $this->linkTree = $link_tree;
 }
开发者ID:danquah,项目名称:forlevd8,代码行数:10,代码来源:CircleBreadcrumbs.php

示例4: blockForm

 /**
  * {@inheritdoc}
  */
 public function blockForm($form, FormStateInterface $form_state)
 {
     $form = parent::blockForm($form, $form_state);
     $config = $this->getConfiguration();
     $form['hello_block_settings'] = array('#type' => 'textfield', '#title' => $this->t('Who'), '#description' => $this->t('Who do you want to say hello to?'), '#default_value' => isset($config['hello_block_settings']) ? $config['hello_block_settings'] : '');
     return $form;
 }
开发者ID:narekcat,项目名称:Drupal_module_example,代码行数:10,代码来源:HelloBlock.php

示例5: __construct

 /**
  * Constructs an SimplenewsSubscriptionBlock object.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Entity\EntityStorageInterface; $newsletterStorage
  *   The storage object for newsletters.
  * @param \Drupal\Core\Form\FormBuilderInterface $formBuilder
  *   The form builder object.
  * @param \Drupal\Core\Entity\Query\QueryInterface $newsletterQuery
  *   The entity query object for newsletters.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, FormBuilderInterface $formBuilder, QueryInterface $newsletterQuery)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->entityManager = $entity_manager;
     $this->formBuilder = $formBuilder;
     $this->newsletterQuery = $newsletterQuery;
 }
开发者ID:aritnath1990,项目名称:simplenewslatest,代码行数:23,代码来源:SimplenewsSubscriptionBlock.php

示例6: __construct

 /**
  * Creates a HelpBlock instance.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The current request.
  * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
  *   The module handler.
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The current route match.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, Request $request, ModuleHandlerInterface $module_handler, RouteMatchInterface $route_match)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->request = $request;
     $this->moduleHandler = $module_handler;
     $this->routeMatch = $route_match;
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:23,代码来源:HelpBlock.php

示例7: blockForm

 /**
  * {@inheritdoc}
  */
 public function blockForm($form, FormStateInterface $form_state)
 {
     $form = parent::blockForm($form, $form_state);
     // Add a form field to the existing block configuration form.
     $form['name'] = array('#type' => 'textfield', '#title' => t('Your Name'));
     return $form;
 }
开发者ID:KenG01,项目名称:Achieve-D8,代码行数:10,代码来源:MadLibsFormBlock.php

示例8: blockAccess

 /**
  * {@inheritdoc}
  */
 protected function blockAccess(AccountInterface $account)
 {
     if ($this->getContextValue('user') instanceof UserInterface) {
         drupal_set_message('User context found.');
     }
     return parent::blockAccess($account);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:10,代码来源:TestContextAwareBlock.php

示例9: __construct

 /**
  * Construct.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  * @param mixed $plugin_definition
  * @param \Drupal\Core\Entity\EntityManager $entity_manager
  * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query
  * @param \Drupal\Core\Entity\EntityFormBuilder $entity_form_builder
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManager $entity_manager, QueryFactory $entity_query, EntityFormBuilder $entity_form_builder)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->entity_manager = $entity_manager;
     $this->entity_query = $entity_query;
     $this->entity_form_builder = $entity_form_builder;
 }
开发者ID:WondrousLLC,项目名称:contact_form_block,代码行数:18,代码来源:ContactFormBlock.php

示例10: __construct

 /**
  * Construct.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param string $plugin_definition
  *   The plugin implementation definition.
  *
  * Add type-hinted parameters for any services to be injected into this class
  * following the normal parameters.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManager $entity_manager, QueryFactory $entity_query)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     // Make each of injected service available as a variable in the class.
     $this->entity_manager = $entity_manager;
     $this->entity_query = $entity_query;
 }
开发者ID:Lullabot,项目名称:challenge4,代码行数:20,代码来源:DemoBlock.php

示例11: blockForm

 /**
  * {@inheritdoc}
  */
 public function blockForm($form, &$form_state)
 {
     $form = parent::blockForm($form, $form_state);
     $config = $this->getConfiguration();
     $form['demo_block_settings'] = array('#type' => 'textfield', '#title' => $this->t('Who'), '#description' => $this->t('Our custom block'), '#default_value' => isset($config['demo_block_settings']) ? $config['demo_block_settings'] : '');
     return $form;
 }
开发者ID:flesheater,项目名称:drupal8_modules_experiments,代码行数:10,代码来源:CustomBlock.php

示例12: __construct

 /**
  * Constructs a new NodeFormBlock plugin
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Entity\EntityManagerInterface $entityManger
  *   The entity manager.
  * @param \Drupal\Core\Entity\EntityFormBuilderInterface $entityFormBuilder
  *   The entity form builder.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entityManager, EntityFormBuilderInterface $entityFormBuilder)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->setConfiguration($configuration);
     $this->entityManager = $entityManager;
     $this->entityFormBuilder = $entityFormBuilder;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:21,代码来源:NodeFormBlock.php

示例13: __construct

 /**
  * Constructs RecentContent class.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param string $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Entity\Query\QueryFactory
  *   The entity query factory.
  * @param EntityTypeManagerInterface $entity_type_manager
  *   The entity type manager.
  * @param \Drupal\Core\Render\RendererInterface
  *   The renderer.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, QueryFactory $entity_query, EntityTypeManagerInterface $entity_type_manager, RendererInterface $renderer)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->entityQuery = $entity_query;
     $this->entityTypeManager = $entity_type_manager;
     $this->renderer = $renderer;
 }
开发者ID:wizzlern,项目名称:cacheit,代码行数:23,代码来源:RecentContent.php

示例14: __construct

 /**
  * Constructs a new SwitchUserBlock object.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Session\AccountInterface $current_user
  *   Current user.
  * @param \Drupal\Core\Entity\EntityStorageInterface $user_storage
  *   The user storage.
  * @param \Drupal\Core\Form\FormBuilderInterface $form_builder
  *   The form builder service.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, AccountInterface $current_user, EntityStorageInterface $user_storage, FormBuilderInterface $form_builder)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->formBuilder = $form_builder;
     $this->currentUser = $current_user;
     $this->userStorage = $user_storage;
 }
开发者ID:AllieRays,项目名称:debugging-drupal-8,代码行数:23,代码来源:SwitchUserBlock.php

示例15: __construct

 /**
  * Creates a NodeBlock instance.
  *
  * @param array $configuration
  * @param string $plugin_id
  * @param mixed $plugin_definition
  * @param EntityManagerInterface $entity_manager
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->viewBuilder = $entity_manager->getViewBuilder('node');
     $this->nodeStorage = $entity_manager->getStorage('node');
     $this->node = $entity_manager->getStorage('node')->load($this->getDerivativeId());
 }
开发者ID:louhichi,项目名称:d8-demo-modules,代码行数:15,代码来源:NodeBlock.php


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