Skip to content

Instantly share code, notes, and snippets.

geoidesic / console.text
Created Nov 26, 2020
Problem with sync from pouchDB
View console.text
vue.runtime.esm.js?5593:619 [Vue warn]: Error in v-on handler: "TypeError: target.once is not a function"
found in
---> <QBtn>
<StorybookLayout> at src/layouts/Storybook.vue
<App> at src/App.vue
geoidesic / DocumentRelationshipValidator.php
Created Aug 3, 2020
Handles validation for the JSONAPI relationships requests.
View DocumentRelationshipValidator.php
namespace App\Listener\JsonApi;
use Cake\ORM\Entity;
use Cake\Utility\Hash;
use Cake\Utility\Inflector;
use Cake\Validation\Validation;
use Crud\Error\Exception\CrudException;
geoidesic / CrudJsonApiListener.php
Created Aug 3, 2020
Will invoke a custom DocumentValidator class depending on the URL format.
View CrudJsonApiListener.php
namespace App\Listener;
use Cake\Core\Configure;
use Cake\Datasource\EntityInterface;
use Cake\Datasource\RepositoryInterface;
use Cake\Datasource\ResultSetDecorator;
use Cake\Datasource\ResultSetInterface;
geoidesic / RelationshipAction.php
Created Aug 3, 2020
Refactor attempt of the CrudJsonApiControllerTrait as a CRUD Action class extension (note the `print_r` which mysteriously doesn't yield the request body)
View RelationshipAction.php
namespace App\Crud\Action;
use Cake\Http\Response;
use Crud\Error\Exception\ValidationException;
use Crud\Event\Subject;
use Crud\Traits\FindMethodTrait;
use Crud\Traits\RedirectTrait;
geoidesic / CrudJsonControllerTrait
Created Aug 3, 2020
Adds actions to your `crud-json-api` controller to handle POST and PATCH relationships requests.
View CrudJsonControllerTrait
namespace App\Traits;
use Cake\Utility\Inflector;
use Cake\Utility\Hash;
trait CrudJsonApiControllerTrait
geoidesic / routes.php
Created Aug 3, 2020
Routing for CrudJsonControllerTrait
View routes.php
Router::prefix('api', function (RouteBuilder $routes) {
$routes->connect('/{controller}/{id}/relationships/{foreignTableName}', ['_method' => 'DELETE', 'action' => 'deleterelationships']);
$routes->connect('/{controller}/{id}/relationships/{foreignTableName}', ['_method' => 'PATCH', 'action' => 'updaterelationships']);
$routes->connect('/{controller}/{id}/relationships/{foreignTableName}', ['_method' => 'POST', 'action' => 'postrelationships']);