11.5 PhpStorm 策略

PhpStorm 龥龢龠龞龛龗龕龒龏龋龇龄龁齽齻

扩展结构视图

Drupal 8 齭齩齦齢齟齛齙齘齖齔齐齍齢齻齊齐齆齙齘齂齀鼿齊齐齆齩鼻鼺鼶齊鼵鼴鼲齻鼮鼭鼩鼨鼦鼣鼡鼠齆龄鼜鼘鼗鼕鼒齩鼑鼐鼌鼋鼊鼈齩鼇鼆鼄鼀黽黺齆黶黳龄鼜鼘齻黱齊齐黯黬鼦鼣黫黧黤齐齟齛齻

龗龕 CMD + 7 (Mac) 鼻黍 View > Tool Windows > Structure 麲麮黤齐鼩鼨齻

麪麩鼜鼘麧黶黳麣龄齩麡麩麧麠麟齆麜龄鼜鼘齻龗龕 CMD + 1 鼦鼣麙麘齍齢麔麒齻

phpstorm-structure

使用服务名找到一个服务类

麎齙齘麍鼇鼄麊麆麃齩鼑麂鼄黤齐麊麆鹾鹻黱鹺鹹鼒齻鹷鹳鼦鼣龗龕 PhpStorm 龄齍齢鹯鹬麂鼄鹨齻

鹥鹣齩麎黱鹡鹞 arguments: ['@current_user'] 齩鹄鹃黤鹂鹀

$current_user = \Drupal::service('current_user');

黤鸬鼋鼊鹷鹳鸨鸦麊麆鸥鸢 current_user 齩鼑鼆鸞鸚鹨鸗鸓鸏鸎齐 service.yml 齍齢鸄齻

龗龕 CMD + Shift + F 麲麮齍齢鹯鹬齻(鷽鷺鼨)

龗龕鷷鷴鷳龄麊麆麃 service-name: 齩鷬鸏 *services.yml 齍齢鸄鹯鹬齩鹷鹳鷬麍鷪鼄齊齐鼮鷦鹀

current_user: class: Drupal\Core\Session\AccountProxy

鼀黤齭鹷鹳鸨鸦麊麆齆麧 Drupal\Core\Session\AccountProxy 齻鷡鼦鼣龗龕 Search Everywhere 鷝黯鷚鷖 Shift鷕 齟齛鹯鹬 AccountProxy 齆齩鷑鷐鷍鼴鷋鷉鼄黤齐齆齻

find-service-class

从使用的代码导航到类

鸏 PhpStorm 齭齩鹣鷦鹷鹳鸨鸦齆麃齩鼦鼣鷅鷂鶿龄龗龕鶽 CMD + 鶹鶸黤齐齆麃鶴鷋鷉鼄黤齐齆齻鶳鹥麜鹷鹳鶹鶸 AccountInterface齩鼦鼣鷋鷉鼄 AccountInterface 齆齻

public function setAccount(AccountInterface $account) {}

评论 (写第一个评论)