The drop is always movingYou know that saying about standing on the shoulders of giants? Drupal is standing on a huge pile of midgetsAll content management systems suck, Drupal just happens to suck less.Popular open source software is more secure than unpopular open source software, because insecure software becomes unpopular fast. [That doesn't happen for proprietary software.]Drupal makes sandwiches happen.There is a module for that

Debugging Drupal 8 plugins

Submitted by nk on Wed, 2013-04-24 19:36

When developing (with) Drupal 8, you will occasionally see the superb helpful exception from DefaultFactory: the plugin did not specify an instance class. A what did not a-do a what?? Glad you asked. For example, here's BlockManager:

<?php
 
public function __construct(array $namespaces) {
   
$this->discovery = new AnnotatedClassDiscovery('block', 'block', $namespaces);
   
$this->discovery = new DerivativeDiscoveryDecorator($this->discovery);
   
$this->discovery = new AlterDecorator($this->discovery, 'block');
   
$this->discovery = new CacheDecorator($this->discovery, 'block_plugins:' . language(LANGUAGE_TYPE_INTERFACE)->langcode, 'block', CacheBackendInterface::CACHE_PERMANENT, array('block'));
  }

 
/**
   * Overrides \Drupal\Component\Plugin\PluginManagerBase::createInstance().
   */
 
public function createInstance($plugin_id, array $configuration = array(), Block $entity = NULL) {
   
$plugin_definition = $this->discovery->getDefinition($plugin_id);
   
$plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition);
    return new
$plugin_class($configuration, $plugin_id, $plugin_definition, $entity);
  }
?>

So what happens here is that the $plugin_definition array does not contain a class key. More often than not, it's completely empty in fact. How does this array get assembled? First we call the getDefinition method of CacheDecorator. This will try to retrieve the definitions from cache, if it doesn't succeed it will call the getDefinition method of whatever it decorated, in this case (just look at the line above CacheDecorator in __construct), it calls the getDefinition method of the AlterDecorator. AlterDecorator calls an alter hook on... you can now guess, on the definitions returned by the getDefinition method of DerivativeDiscoveryDecorator. Which, in turn, calls the getDefinition method of AnnotatedClassDiscovery (a separate blog post in itself) and adds whatever derivatives it sees fit. What's a derivative? For example, in Views, derivatives make it possible to provide one row plugin per entity type by define just a single plugin with a class which generates the plugin definitions. In this case, we have one plugin per custom block.

So here's a list of what happens in case of a cache miss:

  1. AnnotatedClassDiscovery looks for class in directories like .../modules/$module_name/lib/Drupal/$module_name/Plugin/$defining_module/$plugin_type for plugin classes. In this case, the $defining_module is 'block', and $plugin_type is also block. You can run ls core/modules/*/lib/Drupal/*/Plugin/block/block to see what it finds (except that the two * is held to be the same).
  2. AnnotatedClassDiscovery reads class annotations, these are the base definitions.
  3. DerivativeDiscoveryDecorator takes the 'derivate' class from the base definitions and adds those.
  4. An alter hook runs on the definitions.
  5. These decorated, altered definitions get cached.

Phew!

Commenting on this Story is closed.

Submitted by happydog8686 on Tue, 2013-07-02 10:28.

   
九省份暴雨洪涝致39死13失踪
    截至昨天16时,内蒙古、四川等9省份6月29日以来的较强降雨引发的灾害,已造成39人死亡,13人失踪。在鄂尔多斯,短时强降雨夺去了低洼棚户区多人的生命。
 
 
  暴雨洪灾致39人死亡
  据国家减灾办统计,6月29日夜间以来,我国四川盆地、安徽南部及东北、华北部分地区出现较强降雨,并伴有雷电、冰雹等强对流天气,引发洪涝和山体滑坡等地质灾害,已致河北、山西、内蒙古、吉林、黑龙江、安徽、湖北、重庆、四川等9省区市受灾。
  截至7月1日16时,此次灾害过程已造成39人死亡、13人失踪。根据各地的伤亡报告,内蒙古因灾死亡18人、失踪4人,安徽因灾死亡9人、失踪4人,四川因灾死亡9人、失踪5人,重庆因灾死亡2人,湖北因灾死亡1人。
  据气象部门预测,今年第6号热带风暴“温比亚”于7月1日上午加强为强热带风暴,7月1日夜间到2日上午在广东阳江到海南琼海一带沿海登陆。
  针对“温比亚”可能造成的影响,国家减灾委、民政部于7月1日11时紧急启动救灾预警响应。国家减灾办要求广东、广西、海南、贵州、云南等地民政部门及时发布预警信息,认真做好应急救助准备,确保各项防范应对措施和责任落实到位,确保受灾群众基本生活。
  □内蒙古
 
  鄂尔多斯15死4失踪
  6月30日下午,内蒙古鄂尔多斯突遭暴雨及冰雹袭击,造成鄂尔多斯东胜区城区低洼处积水严重,部分平房浸水,道路交通堵塞。部分城市基础设施及植被受到破坏,道路堵塞,电力线路中断,有79处塌方。
  据鄂尔多斯市政府透露,强对流天气还引发山洪。6月30日17时许,由鄂尔多斯市东胜区开往伊金霍洛旗的一辆货车和一辆金杯面包车行驶至铜匠川时,突遇山洪暴发,被洪水冲入河槽。经初步核实,金杯面包车系中石油呼包鄂输油管线项目施工单位运送工人车辆,车内共21人,截至7月1日1时30分,有11人获救、3人死亡、7人失踪。当地组织了400多人沿铜匠川河槽两岸全力搜救。
  截至7月1日下午,鄂尔多斯暴雨已造成15人死亡,4人失踪,4人受伤。
  多名死者住低洼棚户区
  鄂尔多斯气象台台长段景瑞介绍,6月30日的降水强度较大,降水时间过于集中。当天14时30分至15时30分,受灾最重的东胜区降水量高达57毫米,打破了有气象记录以来当地单小时雨量极值。
  段景瑞说,这次灾害中,多人由于居住在低洼地带的棚户区而被夺去生命。事发当晚,他到灾害现场调研时发现,一处房屋建在公路旁的一条深沟里,房顶的高度和公路高度差不多等高。段景瑞说:“暴雨引发的洪水很快就让这里积水严重,并且漫过了房屋的屋顶。加上这里的居民防范意识较差,等意识到有危险的时候,已经来不及了。”
 
 
  上半年洪灾致死人口历史同期较少
  国家防汛抗旱总指挥部1日发布的数据显示,今年以来的洪涝灾害共造成全国死亡157人,失踪16人。
  截至7月1日统计,今年以来全国因强降雨、融雪、台风等引发洪水致使26个省(区、市)2719万人遭受洪涝灾害,死亡157人,失踪16人,农作物受灾1864千公顷,倒塌房屋6万间,直接经济损失约280亿元。
  与2000年以来同期均值相比,洪涝灾害死亡人口偏少近六成,受灾人口偏少五成,直接经济损失偏少近一成,农作物受灾面积偏少四成。受灾区域主要分布在广东、湖南、湖北、广西、江西、安徽、福建、四川、贵州等九个省区,其洪涝灾害直接经济损失、因灾死亡人数占全国总数近八成。
  □重庆
 
  趸船翻覆5人失踪
  1日11时许,重庆嘉陵江朝天门码头一工作趸船发生翻覆,18人落水。截至14时30分,仍有5人下落不明。
  受6月30日嘉陵江流域强降雨影响,嘉陵江重庆段水位24小时内陡涨10.77米。7月1日上午11时许,重庆市轮船总公司所属63号工作趸船因洪峰冲击,发生断缆漂流翻覆,趸船上共有18人落水,其中公司员工17人、员工小孩1人。
  重庆市委市政府立即组织海事、交通、公安等部门及企业全力施救。
  截至14时30分,已有13人获救,仍有5人下落不明,包括员工的小孩。搜救工作仍在进行。
  54年来最大暴雨灌潼南
  6月30日,1959年来最强暴雨猛袭重庆潼南,崇龛、柏梓等10个乡镇出现严重洪涝灾害,受灾最严重的崇龛镇几乎全部被淹。
  6月30日8时至7月1日8时,潼南县12个乡镇累计降雨量均达200毫米以上,新华镇达324毫米。潼南县6月30日的日降水量突破了1959年以来的历史极值。
  据介绍,6月30日晚该镇已完全停电。7月1日9时,两条街道全部被淹,110多户居民被转移,交通完全瘫痪。
  据介绍,光盘光盘,即高密度光盘(Compact Disc)是近代发展起来不同于磁性载体的光学存储介质,用聚焦的氢离子激光束处理记录介质的方法存储和再生信息,又称激光光盘。由于软盘的容量太小,光盘凭借大容量得以广泛使用。我们听的CD是一种光盘,看的VCD、DVD也是一种光盘。http://szdiscyuan.cn.alibaba.com/,此次潼南出现洪涝灾害,主要是因为涪、琼两江上游特大暴雨和潼南本地大暴雨叠加影响,潼南沿江各镇街出现严重过境洪涝。相关的主题文章:

  • http://www.drupal4hu.com/node/364#comment-2217
  • http://www.men33.com/viewthread.php?tid=283187&extra=
  • http://www.ycjsyy.com/bbs/viewthread.php?tid=20040&extra=

光盘,即高密度光盘(Compact Disc)是近代发展起来不同于磁性载体的光学存储介质,用聚焦的氢离子激光束处理记录介质的方法存储和再生信息,又称激光光盘。由于软盘的容量太小,光盘凭借大容量得以广泛使用。我们听的CD是一种光盘,看的VCD、DVD也是一种光盘。http://szdiscyuan.cn.alibaba.com/

Submitted by 38retawman24 on Mon, 2013-07-29 22:33.

&copy,轮盘麒麟宫;2012 CBS Interactive,华人策略论坛. All rights reserved. 北京智德典康电子商务有限公司(中关村在线) 版权所有,太阳城. 京公网安备:110108902134北京海淀区知春路113号银网核心A座9F服务热线:010-62550505传真:010-62529275