Version 1
[yaffs-website] / web / core / modules / migrate / src / Event / EventBase.php
1 <?php
2
3 namespace Drupal\migrate\Event;
4
5 use Drupal\migrate\Plugin\MigrationInterface;
6 use Drupal\migrate\MigrateMessageInterface;
7 use Symfony\Component\EventDispatcher\Event as SymfonyEvent;
8
9 class EventBase extends SymfonyEvent {
10
11   /**
12    * The migration.
13    *
14    * @var \Drupal\migrate\Plugin\MigrationInterface
15    */
16   protected $migration;
17
18   /**
19    * The current message service.
20    *
21    * @var \Drupal\migrate\MigrateMessageInterface
22    */
23   protected $message;
24
25   /**
26    * Constructs a Migrate event object.
27    *
28    * @param \Drupal\migrate\Plugin\MigrationInterface $migration
29    *   The migration being run.
30    * @param \Drupal\migrate\MigrateMessageInterface $message
31    *   The Migrate message service.
32    */
33   public function __construct(MigrationInterface $migration, MigrateMessageInterface $message) {
34     $this->migration = $migration;
35     $this->message = $message;
36   }
37
38   /**
39    * Gets the migration.
40    *
41    * @return \Drupal\migrate\Plugin\MigrationInterface
42    *   The migration being run.
43    */
44   public function getMigration() {
45     return $this->migration;
46   }
47
48   /**
49    * Logs a message using the Migrate message service.
50    *
51    * @param string $message
52    *   The message to log.
53    * @param string $type
54    *   The type of message, for example: status or warning.
55    */
56   public function logMessage($message, $type = 'status') {
57     $this->message->display($message, $type);
58   }
59
60 }