File tree Expand file tree Collapse file tree 3 files changed +21
-11
lines changed Expand file tree Collapse file tree 3 files changed +21
-11
lines changed Original file line number Diff line number Diff line change 33namespace  Codeception \Module ;
44
55use  Codeception \Module ;
6- use  Drupal \Core \Entity \ContentEntityInterface ;
76use  Drupal \Core \Url ;
87use  Codeception \TestCase ;
98
1716 *          cleanup_test: true 
1817 *          cleanup_failed: false 
1918 *          cleanup_suite: true 
19+  *          entities: 
20+  *            - node 
21+  *            - taxonomy_term. 
2022 * 
2123 * @package Codeception\Module 
2224 */ 
@@ -31,6 +33,11 @@ class DrupalEntity extends Module {
3133    'cleanup_test '  => TRUE ,
3234    'cleanup_failed '  => TRUE ,
3335    'cleanup_suite '  => TRUE ,
36+     'entity_registry '  => [
37+       'node ' ,
38+       'taxonomy_term ' ,
39+       'media ' ,
40+     ],
3441  ];
3542
3643  /** 
@@ -173,14 +180,18 @@ public function getEntityFromUrl($url) {
173180    if  ($ parameters$ urlgetRouteParameters ()) {
174181      // Determine if the current route represents an entity. 
175182      foreach  ($ parametersas  $ name$ options
176-         if  (isset ($ options'type ' ]) && strpos ($ options'type ' ], 'entity: ' ) === 0 ) {
177-           $ entity$ urlgetParameter ($ name
178-           if  ($ entityinstanceof  ContentEntityInterface && $ entityhasLinkTemplate ('canonical ' )) {
179-             return  $ entity
183+         $ entity$ urlgetRouteParameters ();
184+         if  (in_array ($ name$ this _getConfig ('entities ' ))) {
185+           try  {
186+             $ storageentityTypeManager ()->getStorage ($ name
187+             $ entity$ storageload ($ options
188+             if  ($ entity
189+               return  $ entity
190+             }
191+           }
192+           catch  (\Exception   $ e
193+             continue ;
180194          }
181- 
182-           // Since entity was found, no need to iterate further. 
183-           return  FALSE ;
184195        }
185196      }
186197    }
Original file line number Diff line number Diff line change 2323 *            - paragraph 
2424 *          cleanup_test: false 
2525 *          cleanup_failed: false 
26-  *          cleanup_suite: true 
27-  * 
26+  *          cleanup_suite: true. 
2827 * 
2928 * @package Codeception\Module 
3029 */ 
@@ -69,6 +68,7 @@ class DrupalUser extends Module {
6968   * 
7069   * @return \Drupal\user\Entity\User 
7170   *   User object. 
71+    * 
7272   * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException 
7373   * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException 
7474   * @throws \Drupal\Core\Entity\EntityStorageException 
Original file line number Diff line number Diff line change 33namespace  Codeception \Module ;
44
55use  Codeception \Module ;
6- use  Codeception \TestCase ;
76use  Drupal \Core \Logger \RfcLogLevel ;
87use  Drupal \Component \Utility \Xss ;
98
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments