Webprofiler has a set of helper classes and a Twig extension that render FQCN to a link that open the class in a configured IDE.
Let's move those classes to Devel and use them, for example, in the new Container info page.

Patch attached just to share the initial implementation but it lacks some error checks and tests.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lussoluca created an issue. See original summary.

lussoluca’s picture

lussoluca’s picture

Issue summary: View changes
lussoluca’s picture

Issue summary: View changes
lussoluca’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: move_ide_link-2851742-2.patch, failed testing.

willzyx’s picture

@luca great work!
I'm ok with move IDE link capabilities from webprofiler to devel. Quick review:

  1. +++ b/devel.services.yml
    @@ -30,3 +30,22 @@ services:
    +  devel.ide_link_generator:
    +    class: Drupal\devel\Helper\IdeLinkGenerator
    +    arguments: ['@config.factory']
    +    private: true
    +
    +  devel.class_shortener:
    +    class: Drupal\devel\Helper\ClassShortener
    +    private: true
    +
    +  deval.code_linker:
    +    class: Drupal\devel\Helper\CodeLinker
    +    arguments: ['@devel.ide_link_generator', '@devel.class_shortener']
    +
    +  twig.extension.devel:
    +    class: Drupal\devel\Twig\Extension\IdeLinkExtension
    +    arguments: ['@devel.ide_link_generator', '@devel.class_shortener']
    +    tags:
    +      - { name: twig.extension, priority: 100 }
    
    +++ b/webprofiler/config/install/webprofiler.config.yml
    @@ -1,9 +1,6 @@
    -ide_link: "txmt://open?url=file://@file&line=@line"
    

    the patch seems incomplete.. all the service classes are missing! :)

  2. +++ b/config/schema/devel.schema.yml
    @@ -27,6 +27,15 @@ devel.settings:
    +    ide_link:
    +      type: string
    +      label: 'IDE link'
    +    ide_link_remote:
    +      type: string
    +      label: 'IDE link remote path'
    +    ide_link_local:
    +      type: string
    +      label: 'IDE link local path'
    

    what about to group the ide link settings in a single entry? it might be more practical and clean IMHO

  3. +++ b/src/Controller/ContainerInfoController.php
    @@ -34,6 +40,11 @@ class ContainerInfoController extends ControllerBase implements ContainerAwareIn
    +   * @var \Drupal\devel\Helper\CodeLinker
    +   */
    +  private $linker;
    +
    +  /**
        * ServiceInfoController constructor.
        *
        * @param \Drupal\Core\DrupalKernelInterface $drupalKernel
    @@ -41,9 +52,10 @@ class ContainerInfoController extends ControllerBase implements ContainerAwareIn
    
    @@ -41,9 +52,10 @@ class ContainerInfoController extends ControllerBase implements ContainerAwareIn
        * @param \Drupal\devel\DevelDumperManagerInterface $dumper
        *   The dumper manager service.
        */
    -  public function __construct(DrupalKernelInterface $drupalKernel, DevelDumperManagerInterface $dumper) {
    +  public function __construct(DrupalKernelInterface $drupalKernel, DevelDumperManagerInterface $dumper, CodeLinker $linker) {
         $this->kernel = $drupalKernel;
         $this->dumper = $dumper;
    +    $this->linker = $linker;
       }
     
       /**
    @@ -52,7 +64,8 @@ class ContainerInfoController extends ControllerBase implements ContainerAwareIn
    
    @@ -52,7 +64,8 @@ class ContainerInfoController extends ControllerBase implements ContainerAwareIn
       public static function create(ContainerInterface $container) {
         return new static(
           $container->get('kernel'),
    -      $container->get('devel.dumper')
    +      $container->get('devel.dumper'),
    +      $container->get('deval.code_linker')
         );
    

    probably we can create a trait for this.. it could be reused in a lot of points and the changes to be made on existing code should be less invasive (of course it should only be used in application-level code, such as classes that would implement ContainerInjectionInterface)

  4. +++ b/config/install/devel.settings.yml
    @@ -6,3 +6,6 @@ rebuild_theme: FALSE
    +ide_link_local: ""
    
    +++ b/devel.services.yml
    @@ -30,3 +30,22 @@ services:
    +  twig.extension.devel:
    +    class: Drupal\devel\Twig\Extension\IdeLinkExtension
    +    arguments: ['@devel.ide_link_generator', '@devel.class_shortener']
    +    tags:
    +      - { name: twig.extension, priority: 100 }
    

    probably my fault but i cannot get the point of this twig extension :P