Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

Commit

Permalink
Adjust coding styles based on drupal/coder 2.11 release (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtodor authored and chrfritsch committed Mar 6, 2017
1 parent e25cad3 commit c0168d3
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 48 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ on admin/config/system/ivw.
On this page you can also configure various aspects of your measurement.
If you select a checkbox, that makes a value overridable, you can
override this settings on terms and nodes, that have a field of the
field type "ivw_integration_settings"
field type "ivw_integration_settings"
7 changes: 1 addition & 6 deletions ivw_integration.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,4 @@ package: Tracking
core: 8.x

dependencies:
- token

# Information added by drush on 2015-12-10
version: '8.x-1.x-dev'
project: 'ivw_integration'
datestamp: 1449764516
- token:token
2 changes: 1 addition & 1 deletion ivw_integration.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ services:
arguments: ['@config.factory', '@token']
ivw_integration.lookup:
class: Drupal\ivw_integration\IvwLookupService
arguments: ['@current_route_match', '@config.factory', '@entity_type.manager']
arguments: ['@current_route_match', '@config.factory', '@entity_type.manager']
2 changes: 1 addition & 1 deletion scripts/travis/test-source-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ composer global require drupal/coder

# run phpcs
phpcs --config-set installed_paths ~/.composer/vendor/drupal/coder/coder_sniffer
phpcs --standard=Drupal --report=summary -p .
phpcs --standard=Drupal --ignore=PULL_REQUEST_TEMPLATE.md --report=summary -p .
phpcs --standard=DrupalPractice --report=summary -p .

# JS ESLint checking
Expand Down
6 changes: 3 additions & 3 deletions src/Form/SettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ class SettingsForm extends ConfigFormBase {
/**
* The token object.
*
* @var Token
* @var \Drupal\Core\Utility\Token
*/
protected $token = array();

/**
* Constructs a \Drupal\ivw_integration\SettingsForm object.
*
* @param ConfigFactoryInterface $config_factory
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
* @param Token $token
* @param \Drupal\Core\Utility\Token $token
* The token object.
*/
public function __construct(ConfigFactoryInterface $config_factory, Token $token) {
Expand Down
11 changes: 6 additions & 5 deletions src/IvwLookupService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\node\Entity\Node;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\TermInterface;

/**
Expand Down Expand Up @@ -74,7 +72,7 @@ public function byRoute($name, RouteMatchInterface $route, $parentOnly = FALSE)

// FIXME is this part required?
if (is_numeric($entity)) {
$entity = Node::load($entity);
$entity = $this->entityTypeManager->getStorage('node')->load($entity);
}
if ($entity instanceof TermInterface) {
$setting = $this->searchTerm($name, $entity, $parentOnly);
Expand Down Expand Up @@ -143,7 +141,10 @@ protected function searchEntity($name, ContentEntityInterface $entity, $parentOn
if ($fieldType === 'entity_reference' && $fieldDefinition->getSetting('target_type') === 'taxonomy_term') {
$fieldName = $fieldDefinition->getName();
if ($tid = $entity->$fieldName->target_id) {
$term = Term::load($tid);
/** @var \Drupal\taxonomy\TermInterface $term */
$term = $this->entityTypeManager->getStorage('taxonomy_term')
->load($tid);

if ($term) {
$termOverride = $this->searchTerm($name, $term);
}
Expand Down Expand Up @@ -185,7 +186,7 @@ protected function searchTerm($name, TermInterface $term, $parentOnly = FALSE) {
}
}

/* @var TermStorage $termStorage */
/* @var \Drupal\taxonomy\TermStorage $termStorage */
$termStorage = $this->entityTypeManager->getStorage('taxonomy_term');

foreach ($termStorage->loadParents($term->id()) as $parent) {
Expand Down
50 changes: 25 additions & 25 deletions src/IvwLookupServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,67 +17,67 @@ interface IvwLookupServiceInterface {
* Automatically uses the current route to look up an IVW property.
*
* @param string $name
* The name of the IVW property to look up.
* The name of the IVW property to look up.
* @param bool $parentOnly
* If set to TRUE, skips lookup on first level ivw_settings field.
* If set to TRUE, skips lookup on first level ivw_settings field.
*
* @return string
* The property value
* The property value
*/
public function byCurrentRoute($name, $parentOnly = FALSE);

/**
* Find value by route.
*
* @param string $name
* The name of the IVW property to look up.
* The name of the IVW property to look up.
* @param \Drupal\Core\Routing\RouteMatchInterface $routeMatch
* The route matching the entity (node, term) on which to look up
* properties.
* The route matching the entity (node, term) on which to look up
* properties.
* @param bool $parentOnly
* If set to TRUE, skips lookup on first level ivw_settings field.
* This is used when determining which property the
* currently examined entity WOULD inherit if it had
* no property for $name in its own ivw settings.
* If set to TRUE, skips lookup on first level ivw_settings field.
* This is used when determining which property the
* currently examined entity WOULD inherit if it had
* no property for $name in its own ivw settings.
*
* @return string
* The property value
* The property value
*/
public function byRoute($name, RouteMatchInterface $routeMatch, $parentOnly = FALSE);

/**
* Find value by entity.
*
* @param string $name
* The name of the IVW property to look up.
* The name of the IVW property to look up.
* @param \Drupal\Core\Entity\ContentEntityInterface $entity
* The content entity (usually node) to look up the property on.
* The content entity (usually node) to look up the property on.
* @param bool $parentOnly
* If set to TRUE, skips lookup on first level ivw_settings field.
* This is used when determining which property the
* currently examined entity WOULD inherit if it had
* no property for $name in its own ivw settings.
* If set to TRUE, skips lookup on first level ivw_settings field.
* This is used when determining which property the
* currently examined entity WOULD inherit if it had
* no property for $name in its own ivw settings.
*
* @return string
* The property value
* The property value
*/
public function byEntity($name, ContentEntityInterface $entity, $parentOnly = FALSE);

/**
* Find value by entity.
*
* @param string $name
* The name of the IVW property to look up.
* The name of the IVW property to look up.
* @param \Drupal\taxonomy\TermInterface $term
* The term to look up the property on.
* The term to look up the property on.
* @param bool $parentOnly
* If set to TRUE, skips lookup on first level ivw_settings field.
* This is used when determining which property the
* currently examined entity WOULD inherit if it had
* no property for $name in its own ivw settings.
* If set to TRUE, skips lookup on first level ivw_settings field.
* This is used when determining which property the
* currently examined entity WOULD inherit if it had
* no property for $name in its own ivw settings.
*
* @return string
* The property value
* The property value
*/
public function byTerm($name, TermInterface $term, $parentOnly = FALSE);

Expand Down
8 changes: 4 additions & 4 deletions src/IvwTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ class IvwTracker implements IvwTrackerInterface, CacheableDependencyInterface {
/**
* The config factory.
*
* @var ConfigFactoryInterface
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;

/**
* The token object.
*
* @var Token
* @var \Drupal\Core\Utility\Token
*/
protected $token;

/**
* Generates IVW tracking information.
*
* @param ConfigFactoryInterface $config_factory
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory service.
* @param Token $token
* @param \Drupal\Core\Utility\Token $token
* Token service.
*/
public function __construct(
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/Field/FieldWidget/IvwSettingsWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class IvwSettingsWidget extends WidgetBase implements ContainerFactoryPluginInte
/**
* The config factory.
*
* @var ConfigFactoryInterface
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;

Expand Down Expand Up @@ -297,7 +297,7 @@ public function formElement(
* The name of the IVW property to look up.
*
* @return string
* The property value.
* The property value.
*/
private function getParentSetting($name) {
return $this->lookupService->byCurrentRoute($name, TRUE);
Expand Down

0 comments on commit c0168d3

Please sign in to comment.