Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / image_widget_crop / modules / image_widget_crop_examples / src / Controller / FrontPage.php
index a2167bf656a767305426f8744f9c55ade1b8d3df..17c5cb49c938d3f37f69ffd4c0148f37dc983b9a 100644 (file)
@@ -3,25 +3,50 @@
 namespace Drupal\image_widget_crop_examples\Controller;
 
 use Drupal\Core\Controller\ControllerBase;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\Url;
+use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
  * Simple front page controller for image_widget_crop_example module.
  */
 class FrontPage extends ControllerBase {
 
+  /**
+   * The entity type manager.
+   *
+   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
+   */
+  protected $entityTypeManager;
+
+  /**
+   * Constructs a Form mode manager FrontPage object.
+   *
+   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
+   *   The entity manager service.
+   */
+  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
+    $this->entityTypeManager = $entity_type_manager;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container) {
+    return new static(
+      $container->get('entity_type.manager')
+    );
+  }
+
   /**
    * Node types that were created for Image Widget Crop Example.
    *
    * @var array
    */
   protected $iwcExampleNodeTypes = [
-    'crop_file_entity_example',
-    'crop_file_imce_example',
-    'crop_media_example',
     'crop_responsive_example',
-    'crop_entity_browser_example',
     'crop_simple_example',
+    'crop_media_example',
   ];
 
   /**
@@ -30,7 +55,7 @@ class FrontPage extends ControllerBase {
   public function content() {
     $items = [];
     foreach ($this->iwcExampleNodeTypes as $node_type) {
-      $node_type = \Drupal::entityTypeManager()->getStorage('node_type')->load($node_type);
+      $node_type = $this->entityTypeManager->getStorage('node_type')->load($node_type);
       $items['#items'][] = $this->t('<a href="@url">@label',
         [
           '@url' => Url::fromRoute('node.add', ['node_type' => $node_type->id()])->toString(),