diff --git a/google_vision.module b/google_vision.module index 551e03b..cda9bec 100644 --- a/google_vision.module +++ b/google_vision.module @@ -2,6 +2,7 @@ /** * @file + * Implements the Google Cloud Vision API properties. */ use Drupal\Core\Form\FormStateInterface; @@ -11,6 +12,7 @@ use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\taxonomy\Entity\Vocabulary; + /** * Implements hook_entity_presave(). */ @@ -38,7 +40,7 @@ function google_vision_entity_presave(EntityInterface $entity) { $vocabularies = Vocabulary::loadMultiple(); // Create a vocabulary if not already present. if (!isset($vocabularies[$new_vid])) { - $vocabulary = \Drupal\taxonomy\Entity\Vocabulary::create(array( + $vocabulary = Vocabulary::create(array( 'vid' => $new_vid, 'machine_name' => $new_vid, 'name' => $name, @@ -125,6 +127,8 @@ function google_vision_form_field_config_form_image_builder($entity_type, FieldC * values in files. */ function google_vision_add_terms_to_vocabulary($file, $field, $vid, $labels) { + // Initialize the values array. + $values = []; // Get existing values from field. $values = $file->get($field->getName())->getValue(); $taxonomy_term_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); diff --git a/src/Controller/SimilarContentController.php b/src/Controller/SimilarContentController.php index e16df87..27dd88e 100644 --- a/src/Controller/SimilarContentController.php +++ b/src/Controller/SimilarContentController.php @@ -16,6 +16,7 @@ use Drupal\Core\Database\Connection; * Returns the related content based on dominant color of the images. */ class SimilarContentController extends ControllerBase { + /** * Database Service Object. * @@ -32,6 +33,12 @@ class SimilarContentController extends ControllerBase { /** * Get the file title. + * + * @param integer $fid. + * The file id. + * + * @return string $title. + * The title of the file id passed. */ public function getFileTitle($fid) { $query = $this->connection->select('file_managed', 'fm'); @@ -43,6 +50,12 @@ class SimilarContentController extends ControllerBase { /** * Returns the list of image links which share the same dominant color. + * + * @param \Drupal\file\FileInterface $file. + * The file of which the similar contents are to be displayed. + * + * @return array $build. + * The rendered list of items to be displayed. */ public function fetchContent(FileInterface $file) { // Get the file id.