Skip to content

Commit

Permalink
Merge pull request #622 from art-institute-of-chicago/feature/twill-g…
Browse files Browse the repository at this point in the history
…uide

Follow the Twill upgrade guide
  • Loading branch information
nikhiltri authored Jan 17, 2025
2 parents 6cea83e + 9594292 commit 5e13874
Show file tree
Hide file tree
Showing 466 changed files with 1,451 additions and 1,034 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ APP_LOG_LEVEL='debug'
APP_URL='www.test'
APP_PROTOCOL='https'
HOSTNAME='www.test'
ADMIN_APP_URL='admin.www.test'

ALLOWED_DOMAINS='www.artic.edu,anothersubdomain.artic.edu'
KIOSK_DOMAIN='kiosk.artic.edu'
Expand Down
26 changes: 15 additions & 11 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
* text=auto eol=lf
* text=auto eol=lf

*.blade.php diff=html
*.css diff=css linguist-vendored
*.html diff=html
*.md diff=markdown
*.php diff=php
*.blade.php diff=html
*.css diff=css linguist-vendored
*.html diff=html
*.md diff=markdown
*.php diff=php

*.scss linguist-vendored
*.js linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored

/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore

/tests export-ignore
/phpunit.xml export-ignore
/docs export-ignore
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ docker-compose.override.yml
/public/storage
/public/test
.vault_pass
/public/assets/admin
/public/assets/twill
/public/assets/vendor
/public/mix-manifest.json
/public/sitemap.xml
Expand Down
8 changes: 4 additions & 4 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
trailingComma: all
trailingComma: none
printWidth: 80
tabWidth: 4
tabWidth: 2
useTabs: false
singleQuote: true
trailingCommaPHP: php5
braceStyle: psr-2
requirePragma: false
insertPragma: false
semi: false
vueIndentScriptAndStyle: true
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Portions of the website rely heavily on our [API](https://api.artic.edu). Check
## Requirements

* PHP 8.1
* Node 8.17.0
* NPM 6.13.0
* PostgreSQL 15
* Node 20.17.0 (lts/iron)
* NPM 10.8.2
* PostgreSQL 16
* Homestead stable `release` branch
* krpano 1.12.* (for virtual tour blocks)

Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/GenerateSitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private function addRemoteModels(&$sitemap)
* Add a URL by module
* Anything paginated and CMS-native of format `/resources/{id}/{slug}`
*/
private function addNativeModel(&$sitemap, $class, string $route, float $priority = 0.8, $changeFrequency = Url::CHANGE_FREQUENCY_DAILY, $paramCallback = null, $additionalFields = [])
private function addNativeModel(&$sitemap, string $class, string $route, float $priority = 0.8, string $changeFrequency = Url::CHANGE_FREQUENCY_DAILY, $paramCallback = null, array $additionalFields = [])
{
// `id` is always needed for retrieving slugs
$fields = array_values(array_unique(array_merge($additionalFields, ['id', 'updated_at'])));
Expand Down Expand Up @@ -226,7 +226,7 @@ private function addUrl(&$sitemap, string $url, float $priority = 0.8, $changeFr
* Add to the sitemap
* Ensures everything is prefixed w/ SITEMAP_BASE_URL
*/
private function add(&$sitemap, $url)
private function add(&$sitemap, \Spatie\Sitemap\Tags\Url $url)
{
$tmpUrl = $url->url ?? $url;

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/UpdateSponsors.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function handle()
}
}

private function getParagraphBlock($model, $position, $content)
private function getParagraphBlock(\App\Models\Sponsor $model, int $position, $content)
{
return [
'blockable_id' => $model->id,
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Exceptions;

use A17\Twill\Exceptions\Handler as ExceptionHandler;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Sentry\Laravel\Integration;
use Throwable;

Expand Down
8 changes: 0 additions & 8 deletions app/Http/Controllers/Admin/DiningHourController.php

This file was deleted.

8 changes: 0 additions & 8 deletions app/Http/Controllers/Admin/ExperienceImageController.php

This file was deleted.

8 changes: 0 additions & 8 deletions app/Http/Controllers/Admin/ExperienceModalController.php

This file was deleted.

8 changes: 0 additions & 8 deletions app/Http/Controllers/Admin/FamilyController.php

This file was deleted.

8 changes: 0 additions & 8 deletions app/Http/Controllers/Admin/FaqController.php

This file was deleted.

8 changes: 0 additions & 8 deletions app/Http/Controllers/Admin/FeaturedHourController.php

This file was deleted.

8 changes: 0 additions & 8 deletions app/Http/Controllers/Admin/HomeArtistController.php

This file was deleted.

8 changes: 0 additions & 8 deletions app/Http/Controllers/Admin/OfferController.php

This file was deleted.

10 changes: 0 additions & 10 deletions app/Http/Controllers/Admin/TicketedEventController.php

This file was deleted.

8 changes: 0 additions & 8 deletions app/Http/Controllers/Admin/TourStopController.php

This file was deleted.

8 changes: 0 additions & 8 deletions app/Http/Controllers/Admin/WaitTimeController.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/Http/Controllers/DigitalPublicationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function showListing($id)
return $this->showDetail($id, true);
}

private function showDetail($id, $showAll = false)
private function showDetail($id, bool $showAll = false)
{
$item = $this->repository->published()->find((int) $id);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace App\Http\Controllers\Admin;
namespace App\Http\Controllers\Twill;

class AdmissionController extends ModuleController
class AdmissionController extends \App\Http\Controllers\Twill\ModuleController
{
protected $moduleName = 'admissions';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace App\Http\Controllers\Admin;
namespace App\Http\Controllers\Twill;

use App\Repositories\CategoryRepository;

class ArticleController extends ModuleController
class ArticleController extends \App\Http\Controllers\Twill\ModuleController
{
protected $moduleName = 'articles';

Expand Down Expand Up @@ -69,7 +69,7 @@ protected function formData($request)
];
}

public function getBrowserData($prependScope = [])
protected function getBrowserData(array $prependScope = []): array
{
if ($this->request->has('is_unlisted')) {
$prependScope['is_unlisted'] = $this->request->get('is_unlisted');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace App\Http\Controllers\Admin;
namespace App\Http\Controllers\Twill;

class ArtistController extends BaseApiController
class ArtistController extends \App\Http\Controllers\Twill\BaseApiController
{
protected $moduleName = 'artists';
protected $hasAugmentedModel = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace App\Http\Controllers\Admin;
namespace App\Http\Controllers\Twill;

class ArtworkController extends BaseApiController
class ArtworkController extends \App\Http\Controllers\Twill\BaseApiController
{
protected $moduleName = 'artworks';
protected $hasAugmentedModel = true;
Expand Down Expand Up @@ -80,7 +80,7 @@ protected function formData($request)
];
}

public function browser()
public function browser(): \Illuminate\Http\JsonResponse
{
// Allow to filter by IDS when listing artworks.
return response()->json($this->getBrowserData(['id' => request('artwork_ids')]));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace App\Http\Controllers\Admin;
namespace App\Http\Controllers\Twill;

class AuthorController extends ModuleController
class AuthorController extends \App\Http\Controllers\Twill\ModuleController
{
protected $moduleName = 'authors';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
*
*/

namespace App\Http\Controllers\Admin;
namespace App\Http\Controllers\Twill;

use App\Helpers\UrlHelpers;

class BaseApiController extends ModuleController
class BaseApiController extends \App\Http\Controllers\Twill\ModuleController
{
/**
* Option to setup links and the possibility of augmenting a model
Expand Down Expand Up @@ -54,7 +54,7 @@ public function augment($datahubId)
return $this->redirectToForm($item->id);
}

protected function getRepository()
protected function getRepository(): \A17\Twill\Repositories\ModuleRepository
{
if ($this->hasAugmentedModel) {
return parent::getRepository();
Expand All @@ -63,7 +63,7 @@ protected function getRepository()
return $this->getApiRepository();
}

protected function getBrowserTableData($items)
protected function getBrowserTableData(\Illuminate\Support\Collection|\Illuminate\Pagination\LengthAwarePaginator $items, bool $forRepeater = false): array
{
// Ensure data is an array and not an object to avoid json_encode wrong conversion
$results = array_values(parent::getBrowserTableData($items));
Expand All @@ -85,7 +85,7 @@ protected function getApiRepository()
return $this->app->make("{$this->namespace}\Repositories\\Api\\" . $this->modelName . 'Repository');
}

public function getIndexItems($scopes = [], $forcePagination = false)
protected function getIndexItems($scopes = [], $forcePagination = false)
{
$perPage = request('offset') ?? $this->perPage ?? 50;
$items = $this->getApiRepository()->get($this->indexWith, $scopes, $this->orderScope(), $perPage, $forcePagination);
Expand All @@ -108,7 +108,7 @@ public function getIndexItems($scopes = [], $forcePagination = false)
/**
* Disable sorting by default for API listings. This has to be implemented individually on each controller
*/
protected function orderScope()
protected function orderScope(): array
{
return [];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?php

namespace App\Http\Controllers\Admin\Behaviors;
namespace App\Http\Controllers\Twill\Behaviors;

use Illuminate\Http\JsonResponse;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;

trait IsNestedModule
{
/**
* PUB-35, PUB-127: Adds check for `$parentModuleId`
*/
public function browser($parentModuleId = null)
public function browser($parentModuleId = null): JsonResponse
{
$this->submodule = isset($parentModuleId);
$this->submoduleParentId = $parentModuleId;
Expand All @@ -20,12 +22,12 @@ public function browser($parentModuleId = null)
/**
* PUB-35, PUB-127, PUB-146: Override inherited function to fix `edit` link
*/
protected function getBrowserTableData($items)
protected function getBrowserTableData(Collection|LengthAwarePaginator $items, bool $forRepeater = false): array
{
$withImage = $this->moduleHas('medias');

return $items->map(function ($item) use ($withImage) {
$columnsData = Collection::make($this->browserColumns)->mapWithKeys(function ($column) use ($item, $withImage) {
$columnsData = Collection::make($this->browserColumns)->mapWithKeys(function ($column) use ($item) {
return $this->getItemColumnData($item, $column);
})->toArray();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace App\Http\Controllers\Admin;
namespace App\Http\Controllers\Twill;

use App\Models\BuildingClosure;

class BuildingClosureController extends ModuleController
class BuildingClosureController extends \App\Http\Controllers\Twill\ModuleController
{
protected $moduleName = 'buildingClosures';

Expand Down
Loading

0 comments on commit 5e13874

Please sign in to comment.