diff --git a/README.md b/README.md index df5c0ec..5437de4 100644 --- a/README.md +++ b/README.md @@ -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" \ No newline at end of file +field type "ivw_integration_settings" diff --git a/ivw_integration.info.yml b/ivw_integration.info.yml index 200a8fc..454cf6f 100644 --- a/ivw_integration.info.yml +++ b/ivw_integration.info.yml @@ -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 \ No newline at end of file + - token:token diff --git a/ivw_integration.services.yml b/ivw_integration.services.yml index bc04842..cb021e8 100644 --- a/ivw_integration.services.yml +++ b/ivw_integration.services.yml @@ -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'] \ No newline at end of file + arguments: ['@current_route_match', '@config.factory', '@entity_type.manager'] diff --git a/scripts/travis/test-source-code.sh b/scripts/travis/test-source-code.sh index 3354d60..b183513 100755 --- a/scripts/travis/test-source-code.sh +++ b/scripts/travis/test-source-code.sh @@ -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 diff --git a/src/Form/SettingsForm.php b/src/Form/SettingsForm.php index 96da497..656b013 100644 --- a/src/Form/SettingsForm.php +++ b/src/Form/SettingsForm.php @@ -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) { diff --git a/src/IvwLookupService.php b/src/IvwLookupService.php index cd1de29..becf0f4 100644 --- a/src/IvwLookupService.php +++ b/src/IvwLookupService.php @@ -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; /** @@ -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); @@ -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); } @@ -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) { diff --git a/src/IvwLookupServiceInterface.php b/src/IvwLookupServiceInterface.php index 384c3ac..32e5a98 100644 --- a/src/IvwLookupServiceInterface.php +++ b/src/IvwLookupServiceInterface.php @@ -17,12 +17,12 @@ 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); @@ -30,18 +30,18 @@ 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); @@ -49,17 +49,17 @@ public function byRoute($name, RouteMatchInterface $routeMatch, $parentOnly = FA * 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); @@ -67,17 +67,17 @@ public function byEntity($name, ContentEntityInterface $entity, $parentOnly = FA * 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); diff --git a/src/IvwTracker.php b/src/IvwTracker.php index ce854ac..52340f2 100644 --- a/src/IvwTracker.php +++ b/src/IvwTracker.php @@ -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( diff --git a/src/Plugin/Field/FieldWidget/IvwSettingsWidget.php b/src/Plugin/Field/FieldWidget/IvwSettingsWidget.php index 697d8d1..73ca48c 100644 --- a/src/Plugin/Field/FieldWidget/IvwSettingsWidget.php +++ b/src/Plugin/Field/FieldWidget/IvwSettingsWidget.php @@ -27,7 +27,7 @@ class IvwSettingsWidget extends WidgetBase implements ContainerFactoryPluginInte /** * The config factory. * - * @var ConfigFactoryInterface + * @var \Drupal\Core\Config\ConfigFactoryInterface */ protected $configFactory; @@ -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);