/**
  * Overwrites LazyPluginCollection::get().
  */
 public function &get($instance_id)
 {
     /* @var \Drupal\restful\Plugin\resource\ResourceInterface $resource */
     $resource = parent::get($instance_id);
     // Allow altering the resource, this way we can read the resource's
     // definition to return a different class that is using composition.
     drupal_alter('restful_resource', $resource);
     $resource = $resource->isEnabled() ? $resource : NULL;
     return $resource;
 }
 /**
  * Tests the setEncryptionMethod method.
  *
  * @covers ::setEncryptionMethod
  */
 public function testSetEncryptionMethod()
 {
     // Set up a mock for the EncryptionProfile class to mock some methods.
     $encryption_profile = $this->getMockBuilder('\\Drupal\\encrypt\\Entity\\EncryptionProfile')->setMethods(['getPluginCollection'])->disableOriginalConstructor()->getMock();
     $this->pluginCollection->expects($this->once())->method('addInstanceID');
     // Set up expectations for encryption profile.
     $encryption_profile->expects($this->any())->method('getPluginCollection')->will($this->returnValue($this->pluginCollection));
     // Set up expectations for encryption method.
     $this->encryptionMethod->expects($this->any())->method('getPluginId')->will($this->returnValue('test_encryption_method'));
     $encryption_profile->setEncryptionMethod($this->encryptionMethod);
 }
 /**
  * {@inheritdoc}
  */
 public function getConfiguration()
 {
     $configuration = parent::getConfiguration();
     // Remove configuration if it matches the defaults.
     foreach ($configuration as $instance_id => $instance_config) {
         $default_config = array();
         $default_config['id'] = $instance_id;
         $default_config += $this->get($instance_id)->defaultConfiguration();
         if ($default_config === $instance_config) {
             unset($configuration[$instance_id]);
         }
     }
     return $configuration;
 }
 /**
  * {@inheritdoc}
  */
 public function getConfiguration()
 {
     $configuration = parent::getConfiguration();
     // Remove configuration if it matches the defaults.
     foreach ($configuration as $instance_id => $instance_config) {
         $default_config = array();
         $default_config['id'] = $instance_id;
         $default_config += $this->get($instance_id)->defaultConfiguration();
         // In order to determine if a plugin is configured, we must compare it to
         // its default configuration. The default configuration of a plugin does
         // not contain context_mapping and it is not used when the plugin is not
         // configured, so remove the context_mapping from the instance config to
         // compare the remaining values.
         unset($instance_config['context_mapping']);
         if ($default_config === $instance_config) {
             unset($configuration[$instance_id]);
         }
     }
     return $configuration;
 }
 /**
  * {@inheritdoc}
  *
  * @return \Drupal\tour\TipPluginInterface
  */
 public function &get($instance_id)
 {
     return parent::get($instance_id);
 }
 /**
  * {@inheritdoc}
  *
  * @param \Drupal\address\Entity\ZoneInterface $parent_zone
  *   The parent zone.
  */
 public function __construct(PluginManagerInterface $manager, array $configurations, ZoneInterface $parent_zone)
 {
     parent::__construct($manager, $configurations);
     $this->parentZone = $parent_zone;
 }
 /**
  * {@inheritdoc}
  */
 public function getConfiguration()
 {
     $configuration = parent::getConfiguration();
     // Remove configuration if it matches the defaults. In self::getAll(), we
     // load all available filters, in addition to the enabled filters stored in
     // configuration. In order to prevent those from bleeding through to the
     // stored configuration, remove all filters that match the default values.
     // Because filters are disabled by default, this will never remove the
     // configuration of an enabled filter.
     foreach ($configuration as $instance_id => $instance_config) {
         $default_config = array();
         $default_config['id'] = $instance_id;
         $default_config += $this->get($instance_id)->defaultConfiguration();
         if ($default_config === $instance_config) {
             unset($configuration[$instance_id]);
         }
     }
     return $configuration;
 }
 /**
  * {@inheritdoc}
  */
 public function remove($instance_id)
 {
     $this->get($instance_id)->remove();
     parent::remove($instance_id);
 }
 /**
  * {@inheritdoc}
  */
 public function getConfiguration()
 {
     $configuration = parent::getConfiguration();
     // Remove disabled protections.
     foreach ($configuration as $instance_id => $instance_config) {
         if (empty($instance_config['status'])) {
             unset($configuration[$instance_id]);
         }
     }
     return $configuration;
 }