Skip to content

Commit

Permalink
More CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrfritsch committed Jun 30, 2017
1 parent 878e74d commit 210c53f
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace Drupal\dcx_track_media_usage\Exception;

/**
*
* Class FoundNonDcxEntityException.
*/
class FoundNonDcxEntityException extends \Exception {

/**
*
* Constructs FoundNonDcxEntityException.
*/
public function __construct($entity_type, $bundle, $entity_id) {
$message = sprintf("Found entity '%s::%s::%s' without DC-X ID.", $type, $bundle, $entity_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
use Drupal\field\Entity\FieldConfig;

/**
* Returns list of referenced media:image entities on entity reference fields
* attached to the given entity.
* Returns list of referenced media:image entities on entity reference fields.
*
* @TODO Replace hardcoded media:image with argument to make this a bit
* more flexible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
use Drupal\field\Entity\FieldConfig;

/**
* Returns list of referenced media:image entities on entity reference fields
* attached to the given entity.
* Returns list of referenced media:image entities on entity reference fields.
*
* @TODO Replace hardcoded media:image with argument to make this a bit
* more flexible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
use Drupal\field\Entity\FieldConfig;

/**
* Returns list of referenced media:image entities on entity reference fields
* attached to the given entity.
* Returns list of referenced media:image entities on entity reference fields.
*
* @TODO Replace hardcoded media:image with argument to make this a bit
* more flexible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class ReferencedEntityDiscoveryManager extends DefaultPluginManager {

/**
*
* {@inheritdoc}
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ interface ReferencedEntityDiscoveryPluginInterface extends PluginInspectionInter
* Find referenced entities on the given entity.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity.
* @param \Drupal\Component\Plugin\PluginManagerInterface $plugin_manager
* The plugin manager service.
*
* @return array
* List of referenced entities keyed by entity id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Drupal\Core\Entity\EntityInterface;
use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\dcx_track_media_usage\Exception\FoundNonDcxEntityException;

Expand All @@ -17,35 +16,33 @@ class ReferencedEntityDiscoveryService implements ReferencedEntityDiscoveryServi
use StringTranslationTrait;

/**
* A plugin manager taking care of plugins implementing the
* ReferencedEntityDiscoveryPluginInterface.
*
* @see ReferencedEntityDiscoveryPluginInterface
* A plugin manager.
*
* @var \Drupal\Component\Plugin\PluginManagerInterface
*/
protected $plugin_manager;
protected $pluginManager;

/**
* ReferencedEntityDiscoveryService constructor.
*
* @param \Drupal\Component\Plugin\PluginManagerInterface $plugin_manager
* The plugin manager service.
*/
public function __construct(PluginManagerInterface $plugin_manager, TranslationInterface $string_translation) {
$this->stringTranslation = $string_translation;
$this->plugin_manager = $plugin_manager;
public function __construct(PluginManagerInterface $plugin_manager) {
$this->pluginManager = $plugin_manager;
}

/**
* {@inheritdoc}
*/
public function discover(EntityInterface $entity, $return_entities = FALSE) {
$plugins = $this->plugin_manager->getDefinitions();
$plugins = $this->pluginManager->getDefinitions();

$referencedEntities = [];

foreach ($plugins as $plugin) {
$instance = $this->plugin_manager->createInstance($plugin['id']);
$referencedEntities += $instance->discover($entity, $this->plugin_manager);
$instance = $this->pluginManager->createInstance($plugin['id']);
$referencedEntities += $instance->discover($entity, $this->pluginManager);
}

$usage = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
interface ReferencedEntityDiscoveryServiceInterface {

/**
* Collect media:image entities referenced by this $entity in any way we can
* detect by the implemented plugins.
* Collect media:image entities referenced by this $entity.
*
* In any way we can detect by the implemented plugins.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* Entity.
* @param bool $return_entities
* Returns List of entities keyed by DC-X IDs instead of the IDs.
*
Expand Down
5 changes: 3 additions & 2 deletions modules/dcx_unpublish_media/dcx_unpublish_media.module
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
*/

use Drupal\Core\Entity\EntityInterface;

/**
* Implement hook_ENTITY_TYPE_update().
* Implements hook_ENTITY_TYPE_update().
*/
function dcx_unpublish_media_media_update($entity) {
// Only care about media images.
Expand Down Expand Up @@ -60,7 +61,7 @@ function dcx_unpublish_media_media_update($entity) {
}

/**
* Implements hook_ENTITY_TYPE_build_defaults_alter.
* Implements hook_ENTITY_TYPE_build_defaults_alter().
*/
function dcx_unpublish_media_media_build_defaults_alter(array &$build, EntityInterface $entity, $view_mode) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ class RequestSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events['kernel.request'] = ['kernel_request'];
$events['kernel.request'] = ['kernelRequest'];

return $events;
}

/**
* This method is called whenever the kernel.request event is dispatched.
*
* @param GetResponseEvent $event
* @param \Symfony\Component\EventDispatcher\Event $event
* Kernel request event.
*/
public function kernel_request(Event $event) {
public function kernelRequest(Event $event) {

$publicPath = PublicStream::basePath();

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/IllegalAssetTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Drupal\dcx_integration\Exception;

/**
*
* Class IllegalAssetTypeException.
*/
class IllegalAssetTypeException extends \Exception {

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/IllegalAttributeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Drupal\dcx_integration\Exception;

/**
*
* Class IllegalAttributeException.
*/
class IllegalAttributeException extends \Exception {

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/MandatoryAttributeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Drupal\dcx_integration\Exception;

/**
*
* Class MandatoryAttributeException.
*/
class MandatoryAttributeException extends \Exception {

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/UnknownDocumentTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Drupal\dcx_integration\Exception;

/**
*
* Class UnknownDocumentTypeException.
*/
class UnknownDocumentTypeException extends \Exception {

Expand Down

0 comments on commit 210c53f

Please sign in to comment.