Skip to content

Instantly share code, notes, and snippets.

View ApiAppController.php
<?php
namespace App\Controller\Api;
use App\Controller\AppController;
use Crud\Controller\Component\CrudComponent;
use Crud\Controller\ControllerTrait;
use Exception;
/**
* ApiApp Controller
View FromElements.js
import React from 'react';
import {useField} from 'formik';
import {FormFeedback, FormGroup, Input, Label} from 'reactstrap';
export const InputText = ({label, ...props}) => {
props.type = props.type || 'text';
const [field, meta, helpers] = useField(props);
const id = `${field.name}Input`;
const isInvalid = !!(meta.touched && meta.error);
const errorMsg = meta.error || ' ';
View ApiAuthenticator.php
<?php
namespace App\Authentication\Authenticator;
use ArrayAccess;
use Authentication\Authenticator\FormAuthenticator;
use Authentication\Authenticator\Result;
use Authentication\Identifier\IdentifierInterface;
use Cake\Utility\Security;
use Firebase\JWT\JWT;
View JsonAuthenticator.php
<?php
namespace App\Authentication\Authenticator;
use Authentication\Authenticator\FormAuthenticator;
use Psr\Http\Message\ServerRequestInterface;
/**
* Class ApiAuthenticator
* @package App\Authentication\Authenticator
View Application.php
<?php
public function getAuthenticationService(ServerRequestInterface $request, ResponseInterface $response)
{
$service = new AuthenticationService();
$fields = [
'username' => 'email',
'password' => 'password'
];
View linked-entities-composer.json
{
"name": "angelxmoreno/cakephp-linked-entities",
"description": "LinkedEntities plugin for CakePHP 3.x",
"homepage": "https://github.com/angelxmoreno/cakephp-linked-entities",
"support": {
"issues": "https://github.com/angelxmoreno/cakephp-linked-entities/issues"
},
"type": "cakephp-plugin",
@angelxmoreno
angelxmoreno / phpunit.xml.dist
Created Aug 31, 2018
LinkedEntities phpunit.xml.dist
View phpunit.xml.dist
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
verbose="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
@angelxmoreno
angelxmoreno / AfterSaveOrDeleteBehavior.php
Created Aug 23, 2018
CakePHP 3 Behavior to adds a Model\Table callback triggered after a save or after a delete
View AfterSaveOrDeleteBehavior.php
<?php
namespace FiveTalents\Model\Behavior;
use Cake\Datasource\EntityInterface;
use Cake\Event\Event;
use Cake\ORM\Behavior;
/**
* AfterSaveOrDelete behavior
@angelxmoreno
angelxmoreno / serverless-php.md
Last active Aug 14, 2018
Example of running PHP code on AWS Lambda
View serverless-php.md
View function.php
<?php
class Helper {
public function render(array $payment_methods, $error_saving_plans = false, $boleto_tab_checked = false)
{
$html = '';
foreach (self::TAB_NAMES as $tab_name) {
$payment_enabled = $this->isPaymentEnabled($tab_name, $payment_methods);
$tab_disabled = $this->isTabDisabled($tab_name, $error_saving_plans);
$checked = $this->shouldBeChecked($tab_name, $payment_enabled, $tab_disabled, $boleto_tab_checked);