diff --git a/src/Vocabulary.php b/src/Vocabulary.php index 0e7d1c3..e9bb91f 100644 --- a/src/Vocabulary.php +++ b/src/Vocabulary.php @@ -1,6 +1,6 @@ asJson([ 'success' => $success, - 'message' => $message + 'message' => $message, ]); } catch (Throwable $exception) { $message = $exception->getMessage(); @@ -76,7 +75,6 @@ public function actionInstallExamples(): Response } /** - * @return bool * @throws Throwable */ private function createFieldType(): bool @@ -113,8 +111,8 @@ private function createFieldType(): bool 'initialRows' => '4', 'multiline' => '', 'placeholder' => null, - 'uiMode' => 'normal' - ] + 'uiMode' => 'normal', + ], ], 'new2' => [ 'id' => null, @@ -130,23 +128,23 @@ private function createFieldType(): bool 'heading' => 'Title', 'handle' => 'title', 'width' => '', - 'type' => 'singleline' + 'type' => 'singleline', ], 'col2' => [ 'heading' => 'Body', 'handle' => 'body', 'width' => '', - 'type' => 'multiline' - ] + 'type' => 'multiline', + ], ], 'maxRows' => '', - 'minRows' => '' - ] - ] - ] - ] - ] - ] + 'minRows' => '', + ], + ], + ], + ], + ], + ], ]); $success = Craft::$app->getFields()->saveField($field); @@ -156,7 +154,6 @@ private function createFieldType(): bool } /** - * @return bool * @throws SectionNotFoundException * @throws SiteNotFoundException * @throws Throwable @@ -173,7 +170,7 @@ private function createExampleSection(): bool 'uriFormat' => '{slug}', 'enabledByDefault' => true, 'template' => 'glossary-example.twig', - 'siteId' => Craft::$app->getSites()->getPrimarySite()->id + 'siteId' => Craft::$app->getSites()->getPrimarySite()->id, ]); $section = new Section([ @@ -181,8 +178,8 @@ private function createExampleSection(): bool 'handle' => 'glossaryExample', 'type' => Section::TYPE_SINGLE, 'siteSettings' => [ - $siteSettings - ] + $siteSettings, + ], ]); $success = Craft::$app->getSections()->saveSection($section); @@ -192,7 +189,6 @@ private function createExampleSection(): bool } /** - * @return bool * @throws EntryTypeNotFoundException * @throws InvalidConfigException * @throws Throwable @@ -216,7 +212,7 @@ private function createExampleEntryType(): bool $fields = $tabs[0]->getFields(); $fields = array_unique(array_merge($fields, [ - $field + $field, ])); $tabs[0]->setFields($fields); @@ -232,9 +228,8 @@ private function createExampleEntryType(): bool } /** - * Adds an A-Z example + * Adds an A-Z example. * - * @return bool * @throws Exception * @throws Throwable * @throws ElementNotFoundException @@ -246,7 +241,8 @@ private function createExampleEntry(): bool $entry = Entry::find() ->section('glossaryExample') ->slug('glossary-example') - ->one(); + ->one() + ; if ($entry) { // Always work with a clean surface @@ -266,18 +262,18 @@ private function createExampleEntry(): bool 'glossaryItem' => [ [ 'title' => 'Address Resolution Protocol', - 'body' => 'A TCP/IP protocol to query MAC address of the target device by its IP address, so as to ensure right communication services.' + 'body' => 'A TCP/IP protocol to query MAC address of the target device by its IP address, so as to ensure right communication services.', ], [ 'title' => 'Adjacent Channel Selectivity', - 'body' => 'A measurement of a receiver’s ability to process a desired signal while rejecting a strong signal in an adjacent channel.' + 'body' => 'A measurement of a receiver’s ability to process a desired signal while rejecting a strong signal in an adjacent channel.', ], [ 'title' => 'AIE', - 'body' => 'Air Interface Encryption, an encryption method used in TETRA on the Air Interface signalling only (control signalling and user payload).' + 'body' => 'Air Interface Encryption, an encryption method used in TETRA on the Air Interface signalling only (control signalling and user payload).', ], [ 'title' => 'Air Interface', - 'body' => 'In wireless communication, the air interface is the radio-based communication link between the mobile station and the active base station.' - ] - ] + 'body' => 'In wireless communication, the air interface is the radio-based communication link between the mobile station and the active base station.', + ], + ], ]; $glossaries[] = $glossary; @@ -291,15 +287,15 @@ private function createExampleEntry(): bool 'glossaryItem' => [ [ 'title' => 'BS', - 'body' => 'Base Station' + 'body' => 'Base Station', ], [ 'title' => 'Base Station', - 'body' => 'In wireless communication, a base station is a wireless communication station installed at a fixed location and used as part of a two-way radio system.' + 'body' => 'In wireless communication, a base station is a wireless communication station installed at a fixed location and used as part of a two-way radio system.', ], [ 'title' => 'Bit Error Rate', - 'body' => 'The number of received bits that have been altered due to noise, interference, and distortion, divided by the total number of transferred bits during a studied time interval locking. A measure of the receiver\'s ability to resist the strong interference signals.' - ] - ] + 'body' => 'The number of received bits that have been altered due to noise, interference, and distortion, divided by the total number of transferred bits during a studied time interval locking. A measure of the receiver\'s ability to resist the strong interference signals.', + ], + ], ]; $glossaries[] = $glossary; @@ -313,9 +309,9 @@ private function createExampleEntry(): bool 'glossaryItem' => [ [ 'title' => 'Call Out', - 'body' => 'Standardized paging and resource management method for TETRA systems.' - ] - ] + 'body' => 'Standardized paging and resource management method for TETRA systems.', + ], + ], ]; $glossaries[] = $glossary; @@ -329,7 +325,7 @@ private function createExampleEntry(): bool $glossary['type'] = 'glossary'; $glossary['fields'] = [ 'glossaryHeading' => $letter, - 'glossaryItem' => [] + 'glossaryItem' => [], ]; $glossaries[] = $glossary; @@ -339,7 +335,7 @@ private function createExampleEntry(): bool $newBlocks['blocks'] = []; foreach ($glossaries as $key => $glossary) { - $newBlocks['blocks']['new:' . ($key + 1)] = $glossary; + $newBlocks['blocks']['new:'.($key + 1)] = $glossary; } $existingBlocks = $entry->getFieldValue('vocabulary')->ids(); @@ -358,11 +354,10 @@ private function createExampleEntry(): bool } /** - * @return bool * @throws Exception */ private function createExampleTemplates(): bool { - return copy(Craft::$app->getPlugins()->getPlugin('vocabulary')->getBasePath() . '/templates/glossary-example.twig', Craft::$app->getPath()->getSiteTemplatesPath() . '/glossary-example.twig'); + return copy(Craft::$app->getPlugins()->getPlugin('vocabulary')->getBasePath().'/templates/glossary-example.twig', Craft::$app->getPath()->getSiteTemplatesPath().'/glossary-example.twig'); } } diff --git a/src/fields/Vocabulary.php b/src/fields/Vocabulary.php index 4211fb2..2cd3cf6 100644 --- a/src/fields/Vocabulary.php +++ b/src/fields/Vocabulary.php @@ -1,6 +1,6 @@ getView()->renderTemplate('vocabulary/_components/fields/Vocabulary_settings', [ - 'field' => $this + 'field' => $this, ]); } } diff --git a/src/translations/en/vocabulary.php b/src/translations/en/vocabulary.php index 79d90fd..4c2574e 100644 --- a/src/translations/en/vocabulary.php +++ b/src/translations/en/vocabulary.php @@ -1,6 +1,6 @@