Skip to content

Instantly share code, notes, and snippets.

View linxlad's full-sized avatar

Nathan Daly linxlad

  • Bury St Edmunds, England
View GitHub Profile
@yahuarkuntur
yahuarkuntur / FOSUBUserProvider.php
Last active November 18, 2016 18:23
My Integration of FosUserBundle and HWIOAuthBundle (symfony 2.7 and hwi/oauth-bundle 0.3.9)
<?php
namespace AppBundle\Services;
use HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface;
use HWI\Bundle\OAuthBundle\Security\Core\User\FOSUBUserProvider as BaseClass;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* https://gist.github.com/danvbe/4476697
@nkbt
nkbt / .eslintrc.js
Last active April 23, 2024 03:19
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
<?php // file [project]/Library/View.php
namespace YourNamespace\Library;
class extendedView extends \Phalcon\Mvc\View
{
public function getPartial($path, $params = array())
{
ob_start();
$this->partial($path, $params);
return ob_get_clean();
@rianorie
rianorie / gist:7f9bf5c92d2559cf2bff
Created November 3, 2014 16:03
Phalcon PHP getPartial
<?php // file [project]/Library/View.php
namespace YourNamespace\Library;
class extendedView extends \Phalcon\Mvc\View
{
public function getPartial($path, $params = array())
{
ob_start();
$this->partial($path, $params);
return ob_get_clean();
@stecman
stecman / RestController.php
Last active August 17, 2022 15:20
Generic REST controller for use in the Phalcon PHP framework
<?php
use Phalcon\Mvc\Controller;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Mvc\DispatcherInterface;
use Phalcon\Mvc\Model\CriteriaInterface;
use Phalcon\Mvc\ModelInterface;
use Phalcon\Mvc\View;
abstract class RestController extends Controller
@JamesMGreene
JamesMGreene / gitflow-breakdown.md
Last active April 30, 2024 14:11
`git flow` vs. `git`: A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@Graceas
Graceas / FormErrorsSerializer.php
Created September 10, 2013 06:26
Symfony 2 Form Error Serializer. May be used for AJAX form validation. Allows tree and flat array styles for errors.
class FormErrorsSerializer {
public function serializeFormErrors(\Symfony\Component\Form\Form $form, $flat_array = false, $add_form_name = false, $glue_keys = '_')
{
$errors = array();
$errors['global'] = array();
$errors['fields'] = array();
foreach ($form->getErrors() as $error) {
$errors['global'][] = $error->getMessage();
@danvbe
danvbe / 1-Explanations.md
Last active April 21, 2023 15:39
A way to integrate FosUserBundle and HWIOAuthBundle

I have managed to install this… and make it work. I implemented it for Facebook and Google, but you can extend it. My solution it is mostly as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:

  • the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
  • set the service for oauth_user_provider in the security.yml with your custom created service

Here are the steps:

  1. Routing. In routing.yml I have added all the routes for both bundles.
  2. Configuration. I have set the config.yml mostly as it is presented in the HWIOAuthBundle.
  3. Security. I have set the security.yml mostly as it is presented in the HWIOAuthBundle (though my routes are using /login pattern, not /connect). Also, the oauth_user_provider is set for my custom service.