<?php
/**
 * Copyright (c) 2014 Andreas Fischer <bantu@owncloud.com>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */

namespace OC\DB;

/**
* Various PostgreSQL specific helper functions.
*/
class PgSqlTools {
	/**
	* @brief Resynchronizes all sequences of a database after using INSERTs
	*        without leaving out the auto-incremented column.
	* @param \OC\DB\Connection $conn
	* @return null
	*/
	public function resynchronizeDatabaseSequences(Connection $conn) {
		$databaseName = $conn->getDatabase();
		foreach ($conn->getSchemaManager()->listSequences() as $sequence) {
			$sequenceName = $sequence->getName();
			$sqlInfo = 'SELECT table_schema, table_name, column_name
				FROM information_schema.columns
				WHERE column_default = ? AND table_catalog = ?';
			$sequenceInfo = $conn->fetchAssoc($sqlInfo, array(
				"nextval('$sequenceName'::regclass)",
				$databaseName
			));
			$tableName = $sequenceInfo['table_name'];
			$columnName = $sequenceInfo['column_name'];
			$sqlMaxId = "SELECT MAX($columnName) FROM $tableName";
			$sqlSetval = "SELECT setval('$sequenceName', ($sqlMaxId))";
			$conn->executeQuery($sqlSetval);
		}
	}
}

<?php
/**
 * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
 * Copyright (c) 2014 Andreas Fischer <bantu@owncloud.com>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */

namespace OC\DB;

/**
* Various PostgreSQL specific helper functions.
*/
class PgSqlTools {
	/**
	* @brief Resynchronizes all sequences of a database after using INSERTs
	*        without leaving out the auto-incremented column.
	* @param \OC\DB\Connection $conn
	* @return null
	*/
	public function resynchronizeDatabaseSequences(Connection $conn) {
		$databaseName = $conn->getDatabase();
		foreach ($conn->getSchemaManager()->listSequences() as $sequence) {
			$sequenceName = $sequence->getName();
			$sqlInfo = 'SELECT table_schema, table_name, column_name
				FROM information_schema.columns
				WHERE column_default = ? AND table_catalog = ?';
			$sequenceInfo = $conn->fetchAssoc($sqlInfo, array(
				"nextval('$sequenceName'::regclass)",
				$databaseName
			));
			$tableName = $sequenceInfo['table_name'];
			$columnName = $sequenceInfo['column_name'];
			$sqlMaxId = "SELECT MAX($columnName) FROM $tableName";
			$sqlSetval = "SELECT setval('$sequenceName', ($sqlMaxId))";
			$conn->executeQuery($sqlSetval);
		}
	}
}

Add Bart to PgSqlTools copyright.

Add Bart to PgSqlTools copyright.


<?php

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;

// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
//if (isset($_SERVER['HTTP_CLIENT_IP'])
//    || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
//    || !in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1'))
//) {
//    header('HTTP/1.0 403 Forbidden');
//    exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
//}

$loader = require_once __DIR__.'/../app/bootstrap.php.cache';

$loader = new \Symfony\Component\ClassLoader\ApcClassLoader('sf2', $loader);
$loader->register(true);

Debug::enable();

require_once __DIR__.'/../app/AppKernel.php';

$kernel = new AppKernel('test', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

<?php

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;

// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
//if (isset($_SERVER['HTTP_CLIENT_IP'])
//    || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
//    || !in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1'))
//) {
//    header('HTTP/1.0 403 Forbidden');
//    exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
//}

$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
Debug::enable();

require_once __DIR__.'/../app/AppKernel.php';

$kernel = new AppKernel('test', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

Disable apc cache for building

Disable apc cache for building


<?php
  $client_id = 'YOUR_CLIENT_ID';
  $client_secret = 'YOUR_CLIENT_SECRET';
  $signing_secret = 'YOUR_SIGNING_SECRET';
  $apim_subscription_key = 'YOUR APIM SUBSCRIPTION_KEY';
  $callback_url = 'http://localhost:8080/callback.php';
  $scope = 'full_access';
  $auth_endpoint = 'http://www.sageone.com/oauth2/auth';
  $us_token_endpoint = 'http://mysageone.na.sageone.com/oauth2/token';
  $ca_token_endpoint = 'http://mysageone.ca.sageone.com/oauth2/token';
  $uki_token_endpoint = 'http://app.sageone.com/oauth2/token';
  $us_base_endpoint = 'https://api.columbus.sage.com/us/sageone/';
  $ca_base_endpoint = 'https://api.columbus.sage.com/ca/sageone/';
  $uki_base_endpoint = 'https://api.columbus.sage.com/uki/sageone/';

?>

<?php
  $client_id = 'YOUR_CLIENT_ID';
  $client_secret = 'YOUR_CLIENT_SECRET';
  $signing_secret = 'YOUR_SIGNING_SECRET';
  $apim_subscription_key = 'YOUR APIM SUBSCRIPTION_KEY';
  $callback_url = 'http://localhost:8080/callback.php';
  $scope = 'full_access';
  $auth_endpoint = 'http://www.sageone.com/oauth2/auth';
  $us_token_endpoint = 'http://mysageone.na.sageone.com/oauth2/token';
  $ca_token_endpoint = 'http://mysageone.ca.sageone.com/oauth2/token';
  $uki_token_endpoint = 'http://api.sageone.com/oauth2/token';
  $us_base_endpoint = 'https://api.columbus.sage.com/us/sageone/';
  $ca_base_endpoint = 'https://api.columbus.sage.com/ca/sageone/';
  $uki_base_endpoint = 'https://api.columbus.sage.com/uki/sageone/';

?>

Fix wrong UKI token endpoint

Fix wrong UKI token endpoint


<?php

    global $wp_query;

    $slider_or_image       = '';
    $page_parent_image     = function_exists('get_field') ? get_field('header_image', $wp_query->post->post_parent) : '';
    $page_parent_animation = function_exists('get_field') ? get_field('show_vobe_animation', $wp_query->post->post_parent) : '';
    $page_google_map       = function_exists('get_field') ? get_field('show_google_map', $wp_query->post->post_parent) : '';

    if ( $page_parent_image ) {

        $slider_or_image =  wp_get_attachment_image( $page_parent_image, 'full' );

    } else if ( is_front_page() ) {

        $slider_or_image = do_shortcode( '[responsive_slider]' );

    } else if ( $page_parent_animation ) {

        $slider_or_image = get_template_part('templates/animation');

    } else if ( $page_google_map ) {

        $options = get_option('plugin_options');
        $slider_or_image = $options['vobe_google_map_code'];

    }

    echo $slider_or_image;

?>

<?php

    global $wp_query;

    $slider_or_image       = '';
    $page_image            = function_exists('get_field') ? get_field('header_image', $wp_query->queried_object_id) : '';
    $page_parent_image     = function_exists('get_field') ? get_field('header_image', $wp_query->post->post_parent) : '';
    $post_parent_image     = function_exists('get_field') ? get_field('header_image', intval(get_option('page_for_posts'))) : '';
    $page_parent_animation = function_exists('get_field') ? get_field('show_vobe_animation', $wp_query->post->post_parent) : '';
    $page_google_map       = function_exists('get_field') ? get_field('show_google_map', $wp_query->post->post_parent) : '';

    if ( $page_parent_image ) {

        $slider_or_image =  wp_get_attachment_image( $page_parent_image, 'full' );

    } else if ( is_front_page() ) {

        $slider_or_image = do_shortcode( '[responsive_slider]' );

    } else if ( $page_parent_animation ) {

        $slider_or_image = get_template_part('templates/animation');

    } else if ( $page_google_map ) {

        $options = get_option('plugin_options');
        $slider_or_image = $options['vobe_google_map_code'];

    } else if ( is_single() ) {

        $slider_or_image =  wp_get_attachment_image( $post_parent_image, 'full' );

    } else {

        $slider_or_image =  wp_get_attachment_image( $page_image, 'full' );

    }

    echo $slider_or_image;

?>

Fix header on post pages.

Fix header on post pages.


<?php
    namespace Page;

    class User
    {
        public function index()
        {
            $this->router->redirect('user/profile');
        }

        public function profile()
        {
            $this->load->model('Manga');
            $this->load->library('Image');
            $this->load->library('Date');

            $cfg = $this->config->loadInfo('Manga');

            $mangas = $this->manga->getUserManga($this->auth->getUserId(), 0, 36);
            $history = $this->manga->getUserHistory($this->auth->getUserId());

            $this->load->storeView('User', [
                'mangas'=>$mangas,
                'history'=>$history,
                'mangapath'=>$cfg['path']
            ]);

            $this->load->layout('Fresh', [
                'title'=>'My Reading History'
            ]);
        }
    }

?>

<?php
    namespace Page;

    class User
    {
        public function index()
        {
            $this->router->redirect('user/profile');
        }

        public function profile()
        {
            $this->load->model('Manga');
            $this->load->library('Image');
            $this->load->library('Date');

            $cfg = $this->config->loadInfo('Manga');

            $mangas = $this->manga->getUserManga(
                $this->auth->getUserId(), 0, 36);
            $history = $this->manga->getUserHistory(
                $this->auth->getUserId(), 0, 31);

            $this->load->storeView('User', [
                'mangas'=>$mangas,
                'history'=>$history,
                'mangapath'=>$cfg['path']
            ]);

            $this->load->layout('Fresh', [
                'title'=>'My Reading History'
            ]);
        }
    }

?>

Add limit to history in user profile

Add limit to history in user profile


 <?php
/**
 * Adapted from Oauth2-server-php cookbook
 * @see http://bshaffer.github.io/oauth2-server-php-docs/cookbook/
 */

// include our OAuth2 Server object
require_once __DIR__.'/server.php';
require_once __DIR__.'/config.php';

/*

  The Mattermost server seems to be returning bare http urls, even
  though there is no http url in the config.json.  If we are using
  https we need to modify them.

*/
$redirect_url_scheme = substr($_POST["redirect_uri"], 0, 5);

if ($url_scheme == "https" && $redirect_url_scheme == "http:") {
    $_POST["redirect_uri"] = "https" . substr($_POST["redirect_uri"], 4);
}

/*

 Handle a request for an OAuth2.0 Access Token and send the response
 to the client

*/
$server->handleTokenRequest(OAuth2\Request::createFromGlobals())->send();
?>

 <?php
/**
 * Adapted from Oauth2-server-php cookbook
 * @see http://bshaffer.github.io/oauth2-server-php-docs/cookbook/
 */

// include our OAuth2 Server object
require_once __DIR__.'/server.php';
require_once __DIR__.'/config.php';

/*

  The Mattermost server seems to be returning bare http urls, even if
  there is no http url in the config.json.  If we are using https we
  need to modify them.

*/
$redirect_url_scheme = substr($_POST["redirect_uri"], 0, 5);

if ($url_scheme == "https" && $redirect_url_scheme == "http:") {
    $_POST["redirect_uri"] = "https" . substr($_POST["redirect_uri"], 4);
}

/*

 Handle a request for an OAuth2.0 Access Token and send the response
 to the client

*/
$server->handleTokenRequest(OAuth2\Request::createFromGlobals())->send();
?>

Clarify language in comment relating to URL modification


<?php

namespace Enzyme\Axiom\Instances;

/**
 * A model/instance with an unique identifier.
 */
interface InstanceInterface
{
    /**
     * Get this instance's unique identifier.
     *
     * @return mixed
     */
    public function getId();
}

<?php

namespace Enzyme\Axiom\Instances;

/**
 * A model/instance with an unique identifier.
 */
interface InstanceInterface
{
    /**
     * Get all the properties for this instance.
     *
     * @return array
     */
    public function getProperties();

    /**
     * Get the value associated with the given property.
     *
     * @param mixed $property
     *
     * @return mixed
     */
    public function getValueFor($property);

    /**
     * Whether this instance has a value for the given property.
     *
     * @param mixed $property
     *
     * @return boolean
     */
    public function hasValueFor($property);
}

Modify instance interface to support read only properties.


<?php namespace PKleindienst\BlogSearch;

use System\Classes\PluginBase;

/**
 * blogSearch Plugin Information File
 */
class Plugin extends PluginBase
{
    /**
     * @var array Plugin dependencies
     */
    public $require = [ 'RainLab.Blog' ];

    /**
     * Returns information about this plugin.
     *
     * @return array
     */
    public function pluginDetails()
    {
        return [
            'name'        => 'Blog Search',
            'description' => 'Adds a search function to the blog',
            'author'      => 'Pascal Kleindienst',
            'icon'        => 'icon-search'
        ];
    }

    /**
     * @return array
     */
    public function registerComponents()
    {
        return [
            'PKleindienst\BlogSearch\Components\SearchForm' => 'searchForm',
            'PKleindienst\BlogSearch\Components\SearchResult' => 'searchResult',
        ];
    }

    /**
     * Register new Twig variables
     * @return array
     */
    public function registerMarkupTags()
    {
        // Check the translate plugin is installed
        if (class_exists('RainLab\Translate\Behaviors\TranslatableModel')) {
            return [];
        }

        return [
            'filters' => [
                '_'  => ['Lang', 'get'],
                '__' => ['Lang', 'choice'],
            ]
        ];
    }
}

<?php namespace PKleindienst\BlogSearch;

use System\Classes\PluginBase;

/**
 * blogSearch Plugin Information File
 */
class Plugin extends PluginBase
{
    /**
     * @var array Plugin dependencies
     */
    public $require = ['RainLab.Blog'];

    /**
     * Returns information about this plugin.
     *
     * @return array
     */
    public function pluginDetails()
    {
        return [
            'name'        => 'Blog Search',
            'description' => 'Adds a search function to the blog',
            'author'      => 'Pascal Kleindienst',
            'icon'        => 'icon-search',
            'homepage'    => 'https://github.com/PascalKleindienst/october-blogsearch-extension'
        ];
    }

    /**
     * @return array
     */
    public function registerComponents()
    {
        return [
            'PKleindienst\BlogSearch\Components\SearchForm'   => 'searchForm',
            'PKleindienst\BlogSearch\Components\SearchResult' => 'searchResult'
        ];
    }

    /**
     * Register new Twig variables
     * @return array
     */
    public function registerMarkupTags()
    {
        // Check the translate plugin is installed
        if (class_exists('RainLab\Translate\Behaviors\TranslatableModel')) {
            return [];
        }

        return [
            'filters' => [
                '_'  => ['Lang', 'get'],
                '__' => ['Lang', 'choice']
            ]
        ];
    }
}

Add homepage to plugin details

Add homepage to plugin details


<?php

declare(strict_types=1);

/*
 * This file is part of Laravel Commentable.
 *
 * (c) Brian Faust <hello@brianfaust.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

return [

    /*
    |--------------------------------------------------------------------------
    | Custom model
    |--------------------------------------------------------------------------
    |
    | This option allows for the extension of the commentable model, by pointing it to a model
    |
    */
    'model' => \BrianFaust\Commentable\Comment::class,

];

<?php

declare(strict_types=1);

/*
 * This file is part of Laravel Commentable.
 *
 * (c) Brian Faust <hello@brianfaust.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

return [

    /*
    |--------------------------------------------------------------------------
    | Custom model
    |--------------------------------------------------------------------------
    |
    | This option allows for the extension of the commentable model, by pointing it to a model
    |
    */
    'model' => \BrianFaust\Commentable\Models\Comment::class,

];

Fix configuration file referencing the wrong model namespace


<?php

namespace LaravelDoctrine\ORM\Serializers;

use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
use Symfony\Component\Serializer\Serializer;

class ArraySerializer
{
    /**
     * @var Serializer
     */
    protected $serializer;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->serializer = new Serializer([$this->getNormalizer()], [
            'array' => $this->getEncoder(),
        ]);
    }

    /**
     * @param $entity
     *
     * @return string
     */
    public function serialize($entity)
    {
        return $this->serializer->serialize($entity, 'array');
    }

    /**
     * @return GetSetMethodNormalizer
     */
    protected function getNormalizer()
    {
        return new GetSetMethodNormalizer;
    }

    /**
     * @return JsonEncoder
     */
    protected function getEncoder()
    {
        return new ArrayEncoder;
    }
}

<?php

namespace LaravelDoctrine\ORM\Serializers;

use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
use Symfony\Component\Serializer\Serializer;

class ArraySerializer
{
    /**
     * @var Serializer
     */
    protected $serializer;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->serializer = new Serializer([$this->getNormalizer()], [
            'array' => $this->getEncoder(),
        ]);
    }

    /**
     * @param $entity
     *
     * @return string
     */
    public function serialize($entity)
    {
        return $this->serializer->serialize($entity, 'array');
    }

    /**
     * @return GetSetMethodNormalizer
     */
    protected function getNormalizer()
    {
        return new GetSetMethodNormalizer;
    }

    /**
     * @return ArrayEncoder
     */
    protected function getEncoder()
    {
        return new ArrayEncoder;
    }
}

Fix incorrect docblock (replaced JsonEncoder w/ ArrayEncoder)


<?php

namespace Notimatica\ApiExceptions;

use Exception;

class TooManyRequestsApiException extends ApiException
{
    /**
     * @param int|null $retryAfter
     * @param array $headers
     * @param string $message
     * @param Exception $previous
     */
    public function __construct($retryAfter = null, $headers = [],  $message = '', Exception $previous = null)
    {
        if (empty($message)) {
            $message = 'Rate limit exceed.';
        }

        if ($retryAfter) {
            $headers['Retry-After'] = $retryAfter;
        }

        parent::__construct(429, 'too_many_requests', $message, $previous, $headers);
    }
}

<?php

namespace Notimatica\ApiExceptions;

use Exception;

class TooManyRequestsApiException extends ApiException
{
    /**
     * @var int|null
     */
    protected $retryAfter = null;

    /**
     * @param int|null $retryAfter
     * @param array $headers
     * @param string $message
     * @param Exception $previous
     */
    public function __construct($retryAfter = null, $headers = [],  $message = '', Exception $previous = null)
    {
        $this->retryAfter = $retryAfter;

        if (empty($message)) {
            $message = 'Rate limit exceed.';
        }

        if ($retryAfter) {
            $headers['Retry-After'] = $retryAfter;
        }

        parent::__construct(429, 'too_many_requests', $message, $previous, $headers);
    }

    /**
     * Add extra info to the output.
     *
     * @return mixed
     */
    public function getMeta()
    {
        if ($this->retryAfter) {
            return [
                'retry_after' => $this->retryAfter
            ];
        }
    }
}

Add retry_after to meta of too many requests exception


<?php

use UltraPress\App;

/**
 * Load the classmap.
 */
require_once(FULL_PATH . 'vendor/autoload.php');

/**
 * Load helper functions.
 */
foreach (glob(FULL_PATH . 'app/helpers/*.php') as $filename)
{
    include $filename;
}

/**
* Initialize the configuration.
*/
Config::init();

/**
 * Bind instances of each post type to the app so we can call them easily.
 * Simply add more by creating a new custom post-type class and
 * adding the full class path to the array below.
 */
App::bind([
    'pages' => new UltraPress\PostTypes\Page()),
    'posts' => new UltraPress\PostTypes\Post())
]);

<?php

use UltraPress\App;
use UltraPress\Config;

/**
 * Load the classmap.
 */
require_once(FULL_PATH . 'vendor/autoload.php');

/**
 * Load helper functions.
 */
foreach (glob(FULL_PATH . 'app/helpers/*.php') as $filename)
{
    include $filename;
}

/**
* Initialize the configuration.
*/
Config::init();

/**
 * Bind instances of each post type to the app so we can call them easily.
 * Simply add more by creating a new custom post-type class and
 * adding the full class path to the array below.
 */
App::bind([
    'pages' => new UltraPress\PostTypes\Page(),
    'posts' => new UltraPress\PostTypes\Post()
]);

Fix missing use statement and some syntax errors


<?php

  // cleanup requested file path
  $filePath = isset($_GET['f']) ? $_GET['f'] : 'lodash';
  $filePath = preg_replace('#(\.*[\/])+#', '', $filePath);
  $filePath .= preg_match('/\.[a-z]+$/', $filePath) ? '' : '.js';

  // output filename
  if (isset($_GET['o'])) {
    $outputName = $_GET['o'];
  } else if (isset($_SERVER['argv'][1])) {
    $outputName = $_SERVER['argv'][1];
  } else {
    $outputName = basename($filePath);
  }

  /*--------------------------------------------------------------------------*/

  require('../vendor/docdown/docdown.php');

  // get package version
  $version = json_decode(file_get_contents('../package.json'))->version;

  // generate Markdown
  $markdown = docdown(array(
    'path'  => '../' . $filePath,
    'title' => 'Lo-Dash v' . $version . '',
    'toc'   => 'categories',
    'url'   => 'https://github.com/lodash/lodash/blob/master/lodash.js'
  ));

  // save to a `.md` file
  file_put_contents($outputName . '.md', $markdown);

  // print
  header('Content-Type: text/plain;charset=utf-8');
  echo $markdown . PHP_EOL;
?>

Add home link in docs.

Add home link in docs. [ci skip]


<?php

namespace Laravel\Scout;

use Illuminate\Support\Manager;
use AlgoliaSearch\Client as Algolia;
use Laravel\Scout\Engines\NullEngine;
use Laravel\Scout\Engines\AlgoliaEngine;
use AlgoliaSearch\Version as AlgoliaUserAgent;

class EngineManager extends Manager
{
    /**
     * Get a driver instance.
     *
     * @param  string|null  $name
     * @return mixed
     */
    public function engine($name = null)
    {
        return $this->driver($name);
    }

    /**
     * Create an Algolia engine instance.
     *
     * @return \Laravel\Scout\Engines\AlgoliaEngine
     */
    public function createAlgoliaDriver()
    {
        AlgoliaUserAgent::addSuffixUserAgentSegment('Laravel Scout', '3.0.7');

        return new AlgoliaEngine(new Algolia(
            config('scout.algolia.id'), config('scout.algolia.secret')
        ));
    }

    /**
     * Create a Null engine instance.
     *
     * @return \Laravel\Scout\Engines\NullEngine
     */
    public function createNullDriver()
    {
        return new NullEngine;
    }

    /**
     * Get the default session driver name.
     *
     * @return string
     */
    public function getDefaultDriver()
    {
        return $this->app['config']['scout.driver'] ?? 'null';
    }
}

<?php

namespace Laravel\Scout;

use Illuminate\Support\Manager;
use AlgoliaSearch\Client as Algolia;
use Laravel\Scout\Engines\NullEngine;
use Laravel\Scout\Engines\AlgoliaEngine;
use AlgoliaSearch\Version as AlgoliaUserAgent;

class EngineManager extends Manager
{
    /**
     * Get a driver instance.
     *
     * @param  string|null  $name
     * @return mixed
     */
    public function engine($name = null)
    {
        return $this->driver($name);
    }

    /**
     * Create an Algolia engine instance.
     *
     * @return \Laravel\Scout\Engines\AlgoliaEngine
     */
    public function createAlgoliaDriver()
    {
        AlgoliaUserAgent::addSuffixUserAgentSegment('Laravel Scout', '3.0.7');

        return new AlgoliaEngine(new Algolia(
            config('scout.algolia.id'), config('scout.algolia.secret')
        ));
    }

    /**
     * Create a Null engine instance.
     *
     * @return \Laravel\Scout\Engines\NullEngine
     */
    public function createNullDriver()
    {
        return new NullEngine;
    }

    /**
     * Get the default session driver name.
     *
     * @return string
     */
    public function getDefaultDriver()
    {
        if (is_null($this->app['config']['scout.driver'])) {
            return 'null';
        }

        return $this->app['config']['scout.driver'];
    }
}

Fix PHP 5.6 compatibility for null driver

    See https://github.com/laravel/scout/pull/224


<?php

namespace Laravel\Scout;

use Illuminate\Support\Manager;
use AlgoliaSearch\Client as Algolia;
use Laravel\Scout\Engines\NullEngine;
use Laravel\Scout\Engines\AlgoliaEngine;

class EngineManager extends Manager
{
    /**
     * Get a driver instance.
     *
     * @param  string|null  $name
     * @return mixed
     */
    public function engine($name = null)
    {
        return $this->driver($name);
    }

    /**
     * Create an Algolia engine instance.
     *
     * @return \Laravel\Scout\Engines\AlgoliaEngine
     */
    public function createAlgoliaDriver()
    {
        return new AlgoliaEngine(new Algolia(
            config('scout.algolia.id'), config('scout.algolia.secret')
        ));
    }

    /**
     * Create a Null engine instance.
     *
     * @return \Laravel\Scout\Engines\NullEngine
     */
    public function createNullDriver()
    {
        return new NullEngine;
    }

    /**
     * Get the default session driver name.
     *
     * @return string
     */
    public function getDefaultDriver()
    {
        return $this->app['config']['scout.driver'];
    }
}

<?php

namespace Laravel\Scout;

use Illuminate\Support\Manager;
use AlgoliaSearch\Client as Algolia;
use AlgoliaSearch\Version as AlgoliaUserAgent;
use Laravel\Scout\Engines\NullEngine;
use Laravel\Scout\Engines\AlgoliaEngine;

class EngineManager extends Manager
{
    /**
     * Get a driver instance.
     *
     * @param  string|null  $name
     * @return mixed
     */
    public function engine($name = null)
    {
        return $this->driver($name);
    }

    /**
     * Create an Algolia engine instance.
     *
     * @return \Laravel\Scout\Engines\AlgoliaEngine
     */
    public function createAlgoliaDriver()
    {
        AlgoliaUserAgent::$custom_value = '; Laravel Scout integration';

        return new AlgoliaEngine(new Algolia(
            config('scout.algolia.id'), config('scout.algolia.secret')
        ));
    }

    /**
     * Create a Null engine instance.
     *
     * @return \Laravel\Scout\Engines\NullEngine
     */
    public function createNullDriver()
    {
        return new NullEngine;
    }

    /**
     * Get the default session driver name.
     *
     * @return string
     */
    public function getDefaultDriver()
    {
        return $this->app['config']['scout.driver'];
    }
}

Add Laravel Scout user agent to Algolia queries


<?
/**
 * @package     Nooku_Server
 * @subpackage  Contacts
 * @copyright	Copyright (C) 2011 - 2012 Timble CVBA and Contributors. (http://www.timble.net)
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link		http://www.nooku.org
 */
?>

Hide email form by default

Hide email form by default


<?php
/**
 * @file
 */

namespace CultuurNet\UDB3\EventHandling;

use Broadway\Domain\DomainMessage;

trait DelegateEventHandlingToSpecificMethodTrait
{
    /**
     * {@inheritDoc}
     */
    public function handle(DomainMessage $domainMessage)
    {
        $event  = $domainMessage->getPayload();
        $method = $this->getHandleMethod($event);

        if (!method_exists($this, $method)) {
            return;
        }

        try {
            $parameter = new \ReflectionParameter(array($this, $method), 0);
        } catch (\ReflectionException $e) {
            // No parameter for the method, so we ignore it.
            return;
        }
        $expectedClass = $parameter->getClass();

        if ($expectedClass->getName() == get_class($event)) {
            $this->$method($event, $domainMessage);
        }
    }

    private function getHandleMethod($event)
    {
        $classParts = explode('\\', get_class($event));

        return 'apply' . end($classParts);
    }
}

<?php
/**
 * @file
 */

namespace CultuurNet\UDB3\EventHandling;

use Broadway\Domain\DomainMessage;

trait DelegateEventHandlingToSpecificMethodTrait
{
    /**
     * {@inheritDoc}
     */
    public function handle(DomainMessage $domainMessage)
    {
        $event  = $domainMessage->getPayload();
        $method = $this->getHandleMethod($event);

        if (!method_exists($this, $method)) {
            return;
        }

        try {
            $parameter = new \ReflectionParameter(array($this, $method), 0);
        } catch (\ReflectionException $e) {
            // No parameter for the method, so we ignore it.
            return;
        }
        $expectedClass = $parameter->getClass();

        if (is_a($event, $expectedClass->getName())) {
            $this->$method($event, $domainMessage);
        }
    }

    private function getHandleMethod($event)
    {
        $classParts = explode('\\', get_class($event));

        return 'apply' . end($classParts);
    }
}

III-758: Apply events when parameter parent class matches


<?php

namespace Emergence\People;

use HandleBehavior;

class Invitation extends \ActiveRecord
{
    public static $tableName = 'invitations';
    public static $singularNoun = 'invitation';
    public static $pluralNoun = 'invitations';

    public static $fields = [
        'RecipientID' => [
            'type' => 'uint',
            'index' => true
        ],
        'Handle' => [
            'unique' => true
        ],
        'Status' => [
            'type' => 'enum',
            'values' => ['Pending', 'Used', 'Revoked'],
            'default' => 'Pending'
        ],
        'Expires' => [
            'type' => 'timestamp',
            'default' => null
        ],
        'Used' => [
            'type' => 'timestamp',
            'default' => null
        ],
        'UserClass' => [
            'default' => User::class
        ]
    ];

    public static $relationships = [
        'Recipient' => [
            'type' => 'one-one',
            'class' => Person::class
        ]
    ];

    public static $validators = [
        'UserClass' => [
            'validator' => 'selection',
            'choices' => [],
            'required' => false
        ]
    ];

    public static function __classLoaded()
    {
        $fieldCls = User::getStackedConfig('fields', 'Class');
        static::$validators['UserClass']['choices'] = $fieldCls['values'];
        parent::__classLoaded();
    }

    public function save($deep = true)
    {
        // set handle
        if (!$this->Handle) {
            $this->Handle = HandleBehavior::generateRandomHandle($this);
        }

        // call parent
        parent::save($deep);
    }
}

<?php

namespace Emergence\People;

use HandleBehavior;

class Invitation extends \ActiveRecord
{
    public static $tableName = 'invitations';
    public static $singularNoun = 'invitation';
    public static $pluralNoun = 'invitations';

    public static $fields = [
        'RecipientID' => [
            'type' => 'uint',
            'index' => true
        ],
        'Handle' => [
            'unique' => true
        ],
        'Status' => [
            'type' => 'enum',
            'values' => ['Pending', 'Used', 'Revoked'],
            'default' => 'Pending'
        ],
        'Expires' => [
            'type' => 'timestamp',
            'default' => null
        ],
        'Used' => [
            'type' => 'timestamp',
            'default' => null
        ],
        'UserClass' => [
            'default' => null
        ]
    ];

    public static $relationships = [
        'Recipient' => [
            'type' => 'one-one',
            'class' => Person::class
        ]
    ];

    public static $validators = [
        'UserClass' => [
            'validator' => 'selection',
            'choices' => [],
            'required' => false
        ]
    ];

    public static function __classLoaded()
    {
        static::$fields['UserClass']['default'] = User::getDefaultClass();
        static::$validators['UserClass']['choices'] = User::getSubClasses();
    }

    public function save($deep = true)
    {
        // set handle
        if (!$this->Handle) {
            $this->Handle = HandleBehavior::generateRandomHandle($this);
        }

        // call parent
        parent::save($deep);
    }
}

Configure `UserClass` field and validator


<?php

// Require Composer's autoloading file
// if it's present in theme directory.
if (file_exists($composer = __DIR__ . '/vendor/autoload.php')) {
    require $composer;
}

// Before running we need to check if everything is in place.
// If something went wrong, we will display friendly alert.
$ok = require_once __DIR__ . '/bootstrap/compatibility.php';

if ($ok) {
    // Now, we can bootstrap our theme.
    $theme = require_once __DIR__ . '/bootstrap/theme.php';

    // Autoload theme. Uses localize_template() and
    // supports child theme overriding. However,
    // they must be under the same dir path.
    (new Tonik\Gin\Foundation\Autoloader($theme->get('config')))->register();
}

<?php

/*
|------------------------------------------------------------------
| Bootstraping a Theme
|------------------------------------------------------------------
|
| This file is responsible for bootstrapping your theme. Autoloads
| composer packages, checks compatibility and loads theme files.
| Most likely, you don't need to change anything in this file.
| Your theme custom logic should be distributed across a
| separated components in the `/src` directory.
|
*/

// Require Composer's autoloading file
// if it's present in theme directory.
if (file_exists($composer = __DIR__ . '/vendor/autoload.php')) {
    require $composer;
}

// Before running we need to check if everything is in place.
// If something went wrong, we will display friendly alert.
$ok = require_once __DIR__ . '/bootstrap/compatibility.php';

if ($ok) {
    // Now, we can bootstrap our theme.
    $theme = require_once __DIR__ . '/bootstrap/theme.php';

    // Autoload theme. Uses localize_template() and
    // supports child theme overriding. However,
    // they must be under the same dir path.
    (new Tonik\Gin\Foundation\Autoloader($theme->get('config')))->register();
}

Add description comment to the founctions.php file


<?php

$this->data['header'] = 'Cron information page';
$this->includeAtTemplateBase('includes/header.php');

?>

Cron is a way to run things regularly on unix systems.

Here is a suggestion for a crontab file:

<?php

		foreach ($this->data['urls'] AS $url ) {
			echo "# " . $url['title'] . "\n";
			echo "" . $url['int'] . " curl --silent --compressed " . $url['href'] . " > /dev/null 2>&1\n";
		}

		?>

Click here to run the cron jobs:

		<?php

		foreach ($this->data['urls'] AS $url ) {
			echo '
' . $url['title'] . '
';
		}

		?>

<?php
$this->includeAtTemplateBase('includes/footer.php');
?>

<?php

$this->data['header'] = 'Cron information page';
$this->includeAtTemplateBase('includes/header.php');

?>

Cron is a way to run things regularly on unix systems.

Here is a suggestion for a crontab file:

<?php

		foreach ($this->data['urls'] AS $url ) {
			echo "# " . $url['title'] . "\n";
			echo "" . $url['int'] . " curl --silent \"" . $url['href'] . "\" > /dev/null 2>&1\n";
		}

		?>

Click here to run the cron jobs:

		<?php

		foreach ($this->data['urls'] AS $url ) {
			echo '
' . $url['title'] . '
';
		}

		?>

<?php
$this->includeAtTemplateBase('includes/footer.php');
?>

Add quotes to cron information page, for the example crontab file


<?php

namespace RadDB\Providers;

use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Laravel\Dusk\DuskServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        // Work around for MariaDB/MySQL key too long errors
        // Not required as long as MySQL > 5.7 or Mariadb > 10.2.2
        // and InnoDB tables are being used.
        // Schema::defaultStringLength(191);

        /*
         * Blade directive to dump a variable/object inside a template.
         * This is similar to dd(), except that it doesn't interrupt the
         * execution of the app. It does NOT support multiple arguments
         * however, you have to use one directive per variable.
         *
         * From https://gist.github.com/victorloux/0c073afa5d4784d2b8e9
         *
         * @example @dump($posts->comments)
         */
        Blade::directive('dump', function ($param) {
            return "
<?php (new \Illuminate\Support\Debug\Dumper)->dump($param); ?>
";
        });
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        if ($this->app->environment('local', 'testing')) {
            $this->app->register(DuskServiceProvider::class);
            $this->app->register(TelescopeServiceProvider::class);
        }
    }
}

<?php

namespace RadDB\Providers;

use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Laravel\Dusk\DuskServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        // Work around for MariaDB/MySQL key too long errors
        // Not required as long as MySQL > 5.7 or Mariadb > 10.2.2
        // and InnoDB tables are being used.
        // Schema::defaultStringLength(191);

        /*
         * Blade directive to dump a variable/object inside a template.
         * This is similar to dd(), except that it doesn't interrupt the
         * execution of the app. It does NOT support multiple arguments
         * however, you have to use one directive per variable.
         *
         * From https://gist.github.com/victorloux/0c073afa5d4784d2b8e9
         *
         * @example @dump($posts->comments)
         */
        Blade::directive('dump', function ($param) {
            return "
<?php (new \Illuminate\Support\Debug\Dumper)->dump($param); ?>
";
        });
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        if ($this->app->environment('local', 'testing')) {
            $this->app->register(DuskServiceProvider::class);
        }
    }
}

Remove Telescope service provider registration


<?php namespace G2R\Gitlab;

use G2R\Exception\Exception;
use G2R\Gitlab\Hook\Build;
use G2R\Gitlab\Hook\Push;
use G2R\Gitlab\Hook\Tag;

class HookResolver
{
    /**
     * Load a gitlab or gitlab CI webhook handler
     *
     * @param $data
     *
     * @return GitlabCiHook|GitlabHook
     */
    public static function load($data)
    {
        $data = static::objectValidation($data);

        if ($data->object_kind === 'push') {
            return new Push($data);
        }

        if ($data->tag) {
            return new Tag($data);
        }

        return new Build($data);
    }

    /**
     * Check if the hook content has a valid object kind
     */
    private static function objectValidation($data)
    {
        $data = json_decode($data);

        if (!isset($data->object_kind)) {
            throw new Exception('Object kind not found in the hook data');
        }

        if (!in_array($data->object_kind, ['push', 'build'])) {
            throw new Exception('Unknown Object kind from the hook');
        }

        return $data;
    }
}

<?php namespace G2R\Gitlab;

use G2R\Exception\Exception;
use G2R\Gitlab\Hook\Build;
use G2R\Gitlab\Hook\Push;
use G2R\Gitlab\Hook\Tag;

class HookResolver
{
    /**
     * Load a gitlab or gitlab CI webhook handler
     *
     * @param $data
     *
     * @return GitlabCiHook|GitlabHook
     */
    public static function load($data)
    {
        $data = self::objectValidation($data);

        if ($data->object_kind === 'push') {
            return new Push($data);
        }

        if ($data->tag) {
            return new Tag($data);
        }

        return new Build($data);
    }

    /**
     * Check if the hook content has a valid object kind
     */
    private static function objectValidation($data)
    {
        $data = json_decode($data);

        if (!isset($data->object_kind)) {
            throw new Exception('Object kind not found in the hook data');
        }

        if (!in_array($data->object_kind, ['push', 'build'])) {
            throw new Exception('Unknown Object kind from the hook');
        }

        return $data;
    }
}

Replace static call by self

Replace static call by self


<?php

namespace Oro\Bundle\InstallerBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

use Oro\Bundle\InstallerBundle\CommandExecutor;

class PlatformUpdateCommand extends ContainerAwareCommand
{
    /**
     * @inheritdoc
     */
    protected function configure()
    {
        $this->setName('oro:platform:update')
            ->setDescription('Execute platform update commands.');
    }

    /**
     * @inheritdoc
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $commandExecutor = new CommandExecutor(
            $input->hasOption('env') ? $input->getOption('env') : null,
            $output,
            $this->getApplication()
        );
        $commandExecutor
            ->runCommand('oro:entity-config:update')
            ->runCommand('oro:entity-extend:init')
            ->runCommand(
                'oro:entity-extend:update-config',
                array('--process-isolation' => true)
            )
            ->runCommand(
                'doctrine:schema:update',
                array('--process-isolation' => true, '--force' => true, '--no-interaction' => true)
            )
            ->runCommand('oro:search:create-index')
            ->runCommand('oro:navigation:init')
            ->runCommand('assets:install')
            ->runCommand('assetic:dump')
            ->runCommand('fos:js-routing:dump', array('--target' => 'js/routes.js'))
            ->runCommand('oro:localization:dump')
            ->runCommand('oro:translation:dump')
            ->runCommand('oro:requirejs:build');
    }
}

<?php

namespace Oro\Bundle\InstallerBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

use Oro\Bundle\InstallerBundle\CommandExecutor;

class PlatformUpdateCommand extends ContainerAwareCommand
{
    /**
     * @inheritdoc
     */
    protected function configure()
    {
        $this->setName('oro:platform:update')
            ->setDescription('Execute platform update commands.');
    }

    /**
     * @inheritdoc
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $commandExecutor = new CommandExecutor(
            $input->hasOption('env') ? $input->getOption('env') : null,
            $output,
            $this->getApplication()
        );
        $commandExecutor
            ->runCommand('oro:entity-config:update')
            ->runCommand('oro:entity-extend:update')
            ->runCommand('oro:navigation:init')
            ->runCommand('assets:install')
            ->runCommand('assetic:dump')
            ->runCommand('fos:js-routing:dump', array('--target' => 'js/routes.js'))
            ->runCommand('oro:localization:dump')
            ->runCommand('oro:translation:dump')
            ->runCommand('oro:requirejs:build');
    }
}

BAP-2667: Modify CLI installer to allow run common commands from Package Manager[


<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAnimalTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('animal', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->string("name", 255);
            $table->integer("dob")->nullable();
            $table->enum("gender", ["male", "female"]);
            $table->integer("father")->unsigned()->nullable();
            $table->integer("mother")->unsigned()->nullable();
            $table->boolean("active")->default(false);
            $table->boolean("own")->default(false);
            $table->dateTime('created_at');
            $table->dateTime('updated_at');
        });

        Schema::table('animal', function($table) {
            $table->foreign("father")->references("id")->on("animal");
            $table->foreign("mother")->references("id")->on("animal");
            $table->unique(["name", "dob"]);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('animal');
    }
}

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAnimalTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('animal', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->string("name", 255);
            $table->integer("dob")->nullable();
            $table->enum("gender", ["male", "female"]);
            $table->integer("father")->unsigned()->nullable();
            $table->integer("mother")->unsigned()->nullable();
            $table->boolean("active")->default(false);
            $table->boolean("own")->default(false);
            $table->dateTime('created_at');
            $table->dateTime('updated_at');
        });

        Schema::table('animal', function (Blueprint $table) {
            $table->foreign("father")->references("id")->on("animal");
            $table->foreign("mother")->references("id")->on("animal");
            $table->unique(["name", "dob"]);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('animal');
    }
}

Add bluepring to table definition

Add bluepring to table definition


<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Zip Address Util</title>
    <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap-theme.min.css">

Zip Address Util

<form name="search_form" method="get" action="/address/result">
    <button>検索</button>
</form>

    <?php if (isset($results)) {
        foreach ($results as $addr) {
            /** @var App\Models\Address $addr */
            echo '
' . $addr->getWholeAddress() . '
';
        }
    } ?>
    <input type="text" name="search" title="search" id="search" cols="30" rows="10"
                   value=<?php
                   /** @var string $searchWord */
                   if (isset($searchWord)) {
                       echo $searchWord;
                   } ?>
            >

<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Zip Address Util</title>
    <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap-theme.min.css">

Zip Address Util

<form name="search_form" method="get" action="/address/result">
    <button>検索</button>
</form>

    <?php if (isset($results)) {
        foreach ($results as $addr) {
            /** @var App\Models\Address $addr */
            echo '
' . $addr->getWholeAddress() . '
';
        }
    } ?>
    <input type="text" name="search" title="search" id="search"
                   value=<?php
                   /** @var string $searchWord */
                   if (isset($searchWord)) {
                       echo $searchWord;
                   } ?>
            >

Delete wrong attributes of 'cols' and 'rows' (these are for texture).


<?php
namespace Koala\ContentBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;

class SecuredController extends Controller
{
    protected function can_edit()
    {
        try {
            // Check if user has right to edit
            $editor_role = $this->container->getParameter('koala_content.editor_role');
            $can_edit = $this->get('security.context')->isGranted($editor_role);
        } catch (AuthenticationCredentialsNotFoundException $e) {
            // Security is not enabled so everyone can edit
            $can_edit = true;
        }

        return $can_edit;
    }
}

<?php
namespace Koala\ContentBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class SecuredController extends Controller
{
    protected function can_edit()
    {
        try {
            // Check if user has right to edit
            $editor_role = $this->container->getParameter('koala_content.editor_role');

            return $this->get('security.context')->isGranted($editor_role);
        } catch (\Exception $e) {
            switch (get_class($e)) {
                case 'Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException':
                case 'Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException':
                    // Security is not enabled so everyone can edit
                    return true;
                default:
                    throw $e;
            }
        }
    }
}

Rewrite SecureController and handle extra exception


<?php

namespace Bundle\DoctrineUserBundle\Form;

use Symfony\Component\Form\Form;
use Symfony\Component\Form\TextField;
use Symfony\Component\Form\RepeatedField;
use Symfony\Component\Form\PasswordField;

use Symfony\Component\Validator\ValidatorInterface;

class UserForm extends Form
{
    /**
     * Constructor.
     *
     * @param string $name
     * @param array|object $data
     * @param ValidatorInterface $validator
     * @param array $options
     */
    public function __construct($title, $data, ValidatorInterface $validator, array $options = array())
    {
        $this->addOption('theme');
        $this->addOption('categoryRepository');
        $this->addOption('columnRepository');
        $this->addOption('showPublishedAt');

        parent::__construct($title, $data, $validator, $options);
    }

    public function configure()
    {
        $this->add(new TextField('username'));
        $this->add(new TextField('email'));
        $this->add(new RepeatedField(new PasswordField('password')));
    }
}

<?php

namespace Bundle\DoctrineUserBundle\Form;

use Symfony\Component\Form\Form;
use Symfony\Component\Form\TextField;
use Symfony\Component\Form\RepeatedField;
use Symfony\Component\Form\PasswordField;

use Symfony\Component\Validator\ValidatorInterface;

class UserForm extends Form
{
    /**
     * Constructor.
     *
     * @param string $name
     * @param array|object $data
     * @param ValidatorInterface $validator
     * @param array $options
     */
    public function __construct($title, $data, ValidatorInterface $validator, array $options = array())
    {
        $this->addOption('theme');

        parent::__construct($title, $data, $validator, $options);
    }

    public function configure()
    {
        $this->add(new TextField('username'));
        $this->add(new TextField('email'));
        $this->add(new RepeatedField(new PasswordField('password')));
    }
}

Remove code that really should not be there


<?php

Configure::write('Wysiwyg.attachmentBrowseUrl', array(
	'plugin' => 'file_manager',
	'controller' => 'attachments',
	'action' => 'browse',
));

Croogo::mergeConfig('Wysiwyg.actions', array(
	'Attachments/admin_browse',
));

Configure::write('FileManager', array(
	'editablePaths' => array(
		APP,
	),
	'deletablePaths' => array(
		APP . 'View' . DS . 'Themed' . DS,
		WWW_ROOT,
	),
));

Make configurable editable and deletable paths.


<?php

use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class OrchestraAuthCreatePasswordRemindersTable extends Migration
{
    /**
     * Table name.
     *
     * @var string
     */
    protected $table;

    /**
     * Construct a new password reminder schema.
     */
    public function __construct()
    {
        $this->table = Config::get('auth.password.table');
    }

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->table, function (Blueprint $table) {
            $table->string('email')->index();
            $table->string('token')->index();
            $table->timestamp('created_at');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop($this->table);
    }
}

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class OrchestraAuthCreatePasswordRemindersTable extends Migration
{
    /**
     * Table name.
     *
     * @var string
     */
    protected $table;

    /**
     * Construct a new password reminder schema.
     */
    public function __construct()
    {
        $resetter = config('auth.default_resetter');

        $this->table = config("auth.resetters.{$resetter}.table");
    }

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->table, function (Blueprint $table) {
            $table->string('email')->index();
            $table->string('token')->index();
            $table->timestamp('created_at');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop($this->table);
    }
}

Update password reminders with new configuration.

Signed-off-by: crynobone <e1a543840a942eb68427510a8a483282a7bfeddf@gmail.com>


<?php
namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

class PlaylistController extends Controller
{
  /**
   * @Route("/recent", name="playlist_recent")
   */
  public function homeAction()
  {
    $em = $this->getDoctrine()->getManager();
    $playedRecently = $em->getRepository("AppBundle:VideoLog")->findRecent(10);

    return $this->render(":playlist:recent.html.twig", [
      "playedRecently" => $playedRecently
    ]);
  }
}

<?php
namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

class PlaylistController extends Controller
{
  /**
   * @Route("/recent", name="playlist_recent")
   */
  public function homeAction()
  {
    $em = $this->getDoctrine()->getManager();
    $playedRecently = $em->getRepository("AppBundle:VideoLog")->findRecent(100);

    return $this->render(":playlist:recent.html.twig", [
      "playedRecently" => $playedRecently
    ]);
  }
}

Change to limit in /recent

Change to limit in /recent


<?php

namespace AppBundle\Repository;

use Doctrine\ORM\EntityRepository;

/**
 * OrganismRepository
 *
 * This class was generated by the PhpStorm "Php Annotations" Plugin. Add your own custom
 * repository methods below.
 */
class OrganismRepository extends EntityRepository
{
    public function getNumber(): int {
        $query = $this->getEntityManager()->createQuery('SELECT COUNT(o.fennecId) FROM AppBundle\Entity\Organism o');
        return $query->getSingleScalarResult();
    }

    public function getOrganisms($query): array{
        $limit = 5;
        if ($query->has('limit')) {
            $limit = $query->get('limit');
        }
        $search = "%%";
        if ($query->has('search')) {
            $search = "%".$query->get('search')."%";
        }
        $query_get_organisms = <<<EOF
SELECT *
    FROM organism WHERE organism.scientific_name ILIKE :search LIMIT :limit
EOF;
        $stm_get_organisms = $this->getEntityManager()->createQuery($query_get_organisms);
        $stm_get_organisms->bindValue('search', $search);
        $stm_get_organisms->bindValue('limit', $limit);
        $stm_get_organisms->execute();

        $data = array();

        while ($row = $stm_get_organisms->fetch(PDO::FETCH_ASSOC)) {
            $result = array();
            $result['fennec_id'] = $row['fennec_id'];
            $result['scientific_name'] = $row['scientific_name'];
            $data[] = $result;
        }
        return $data;
    }
}

<?php

namespace AppBundle\Repository;

use Doctrine\ORM\EntityRepository;

/**
 * OrganismRepository
 *
 * This class was generated by the PhpStorm "Php Annotations" Plugin. Add your own custom
 * repository methods below.
 */
class OrganismRepository extends EntityRepository
{
    public function getNumber(): int {
        $query = $this->getEntityManager()->createQuery('SELECT COUNT(o.fennecId) FROM AppBundle\Entity\Organism o');
        return $query->getSingleScalarResult();
    }

    public function getOrganisms($limit, $search): array {
        $qb = $this->getEntityManager()->createQueryBuilder();
        $qb->select('organism')
            ->from('AppBundle\Entity\Organism', 'organism')
            ->where('LOWER(organism.scientificName) LIKE LOWER(:search)')
            ->setParameter('search', $search)
            ->setMaxResults($limit);
        $query = $qb->getQuery();
        $result = $query->getArrayResult();
        $data = array();

        while ($row = $stm_get_organisms->fetch(PDO::FETCH_ASSOC)) {
            $result = array();
            $result['fennec_id'] = $row['fennec_id'];
            $result['scientific_name'] = $row['scientific_name'];
            $data[] = $result;
        }
        return $data;
    }
}

Implement the sql query using querybuilder


<?php
/**
 * This script is intended to be run as the inbuilt webserver's "router" script.
 * Procedural code below is necessary when triggered from inbuilt webserver
 * as this script is the point-of-entry for the whole application.
 *
 * Uses Gateway class to decide whether to serve static content or begin
 * request / response within PHP.Gt.
 *
 * PHP.Gt (http://php.gt)
 * @copyright Copyright Ⓒ 2014 Bright Flair Ltd. (http://brightflair.com)
 * @license Apache Version 2.0, January 2004. http://www.apache.org/licenses
 */
namespace Gt\Cli;
require_once(__DIR__ . "/../../../vendor/autoload.php");

// Only allow this script to be invoked from inbuilt webserver.
if(php_sapi_name() === "cli-server") {
	return Gateway::serve($_SERVER["REQUEST_URI"]);
}
else {
	throw new InvalidContextException(php_sapi_name());
}

<?php
/**
 * This script is intended to be run as the inbuilt webserver's "router" script.
 * Procedural code below is necessary when triggered from inbuilt webserver
 * as this script is the point-of-entry for the whole application.
 *
 * Uses Gateway class to decide whether to serve static content or begin
 * request / response within PHP.Gt.
 *
 * PHP.Gt (http://php.gt)
 * @copyright Copyright Ⓒ 2014 Bright Flair Ltd. (http://brightflair.com)
 * @license Apache Version 2.0, January 2004. http://www.apache.org/licenses
 */
namespace Gt\Cli;
require(__DIR__ . "/../../../vendor/autoload.php");

// Only allow this script to be invoked from inbuilt webserver.
if(php_sapi_name() === "cli-server") {
	return Gateway::serve($_SERVER["REQUEST_URI"]);
}
else {
	throw new InvalidContextException(php_sapi_name());
}

Use require for composer autoloader

Use require for composer autoloader


<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\HttpKernel\Tests\Fixtures;

use Symfony\Component\HttpKernel\Client;

class TestClient extends Client
{
    protected function getScript($request)
    {
        $script = parent::getScript($request);

        $script = preg_replace('/(\->register\(\);)/', "$0\nrequire_once '".__DIR__."/../../vendor/autoload.php';", $script);

        return $script;
    }
}

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\HttpKernel\Tests\Fixtures;

use Symfony\Component\HttpKernel\Client;

class TestClient extends Client
{
    protected function getScript($request)
    {
        $script = parent::getScript($request);

        $autoload = file_exists(__DIR__.'/../../vendor/autoload.php')
            ? __DIR__.'/../../vendor/autoload.php'
            : __DIR__.'/../../../../../../../../autoload.php'
        ;

        $script = preg_replace('/(\->register\(\);)/', "$0\nrequire_once '$autoload';\n", $script);

        return $script;
    }
}

Fix Symfony2 full framework tests

[HttpKernel] Fix Symfony2 full framework tests


<?php namespace Config;

use CodeIgniter\Events\Events;

/*
 * --------------------------------------------------------------------
 * Application Events
 * --------------------------------------------------------------------
 * Events allow you to tap into the execution of the program without
 * modifying or extending core files. This file provides a central
 * location to define your events, though they can always be added
 * at run-time, also, if needed.
 *
 * You create code that can execute by subscribing to events with
 * the 'on()' method. This accepts any form of callable, including
 * Closures, that will be executed when the event is triggered.
 *
 * Example:
 *      Events::on('create', [$myInstance, 'myMethod']);
 */

/*
 * --------------------------------------------------------------------
 * Debug Toolbar Listeners.
 * --------------------------------------------------------------------
 * If you delete, they will no longer be collected.
 */
if (ENVIRONMENT != 'production')
{
	Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
}

<?php namespace Config;

use CodeIgniter\Events\Events;

/*
 * --------------------------------------------------------------------
 * Application Events
 * --------------------------------------------------------------------
 * Events allow you to tap into the execution of the program without
 * modifying or extending core files. This file provides a central
 * location to define your events, though they can always be added
 * at run-time, also, if needed.
 *
 * You create code that can execute by subscribing to events with
 * the 'on()' method. This accepts any form of callable, including
 * Closures, that will be executed when the event is triggered.
 *
 * Example:
 *      Events::on('create', [$myInstance, 'myMethod']);
 */

/*
 * --------------------------------------------------------------------
 * Debug Toolbar Listeners.
 * --------------------------------------------------------------------
 * If you delete, they will no longer be collected.
 */
if (ENVIRONMENT != 'production')
{
	Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');

	Events::on('pre_system', function()
	{
		$request = \Config\Services::request();

        if ($request->getGet('debugbar') !== null)
        {
        	ob_start();
	        include(BASEPATH . 'Debug/Toolbar/toolbarloader.js.php');
	        $output = ob_get_contents();
	        @ob_end_clean();
		    exit($output);
		}

		if ($request->getGet('debugbar_time'))
		{
			helper('security');

			$file = sanitize_filename('debugbar_' . $request->getGet('debugbar_time'));
		    $filename = WRITEPATH . sanitize_filename('debugbar_' . $request->getGet('debugbar_time'));

		    if (file_exists($filename))
		    {
		    	$contents = file_get_contents($filename);
		    	unlink($filename);
			    exit($contents);
		    }

			// File was not written or do not exists
		    exit('<script id="toolbar_js">console.log(\'CI DebugBar: File "WRITEPATH/' . $file . '" not found.\')</script>');
		}
	});
}

Add Event to handle the toolbar

Add Event to handle the toolbar


<?php

namespace DaMess\Http;

use Aura\Session\Session;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

final class SessionMiddleware
{
    /**
     * @var Session
     */
    protected $session;

    /**
     * @param Session $session
     */
    public function __construct(Session $session)
    {
        $this->session = $session;
    }

    /**
     * @param ServerRequestInterface $request
     * @param ResponseInterface $response
     * @param callable|null $next
     * @return ResponseInterface
     */
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
    {
        $this->session->start();
        $request = $request->withAttribute('session', $this->session);

        if ($next) {
            return $next($request, $response);
        }

        return $response;
    }
}

<?php

namespace DaMess\Http;

use Aura\Session\Session;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

final class SessionMiddleware
{
    /**
     * @var Session
     */
    protected $session;

    /**
     * @param Session $session
     */
    public function __construct(Session $session)
    {
        $this->session = $session;
    }

    /**
     * @param ServerRequestInterface $request
     * @param ResponseInterface $response
     * @param callable|null $next
     * @return ResponseInterface
     */
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
    {
        if (!$this->session->isStarted()) {
            $this->session->start();
        }

        $request = $request->withAttribute('session', $this->session);

        if ($next) {
            return $next($request, $response);
        }

        return $response;
    }
}

Check if the session is already started

Check if the session is already started


<?php

namespace Michaeljennings\Snapshot\Listeners;

use League\Event\EventInterface;
use Maknz\Slack\Client;
use Michaeljennings\Snapshot\Exceptions\EndPointNotSetException;

class SendToSlack extends Listener
{
    /**
     * Check if slack is enabled, if so send the snapshot to the relevant
     * channel.
     *
     * @param EventInterface $event
     * @throws EndPointNotSetException
     */
    public function handle(EventInterface $event)
    {
        if ($this->config['slack']['enabled']) {
            if (empty($this->config['slack']['endpoint'])) {
                throw new EndPointNotSetException("You must set the endpoint for your slack channel.");
            }

            $client = new Client($this->config['slack']['endpoint'], $this->config['slack']['settings']);
            $snapshot = $event->getSnapshot();

            $client->send('A new snapshot has been captured. #' . $snapshot->getId());
        }
    }
}

<?php

namespace Michaeljennings\Snapshot\Listeners;

use League\Event\EventInterface;
use Maknz\Slack\Client;
use Michaeljennings\Snapshot\Exceptions\EndPointNotSetException;

class SendToSlack extends Listener
{
    /**
     * Check if slack is enabled, if so send the snapshot to the relevant
     * channel.
     *
     * @param EventInterface $event
     * @throws EndPointNotSetException
     */
    public function handle(EventInterface $event)
    {
        if ($this->config['slack']['enabled']) {
            if (empty($this->config['slack']['endpoint'])) {
                throw new EndPointNotSetException("You must set the endpoint for your slack channel.");
            }

            $client = new Client($this->config['slack']['endpoint'], $this->config['slack']['settings']);

            $client->send($this->getMessage($event->getSnapshot()));
        }
    }

    /**
     * Get the slack message for the snapshot. If you wish to use markdown
     * then set the allow_markdown config option to true.
     *
     * @param mixed $snapshot
     * @return string
     */
    protected function getMessage($snapshot)
    {
        return 'A new snapshot has been captured. #' . $snapshot->getId();
    }
}

Update the send to slack listener to allow users to customise the message


<?php
require "Mail.php";
require "Mail_Mime.php";
require "Crypt/GPG.php";

define('BASE', dirname(__DIR__));
require BASE.'/config.php';

if (isset($_POST['from']) && isset($_POST['message'])) {
    $gpg = new Crypt_GPG([
        'homedir' => BASE
    ]);
    $fingerprint = $gpg->getFingerprint(
        OUR_EMAIL_ADDRESS
    );

    $ciphertext = $gpg->encrypt(
        "From: {$_POST['from']}\n\nMessage:\n{$_POST['message']}",
        $fingerprint
    );

    $email = Mail::factory('mail');
    $email->send(
        [OUR_EMAIL_ADDRESS], // Just for the lulz
        ['From' => 'Contact Form <contact@anonymo.us>'],
        $ciphertext
    );
    header("Location: contact_form.php?msg=success");
    exit;
}
header("Location: contact_form.php");
exit;

<?php
require "Mail.php";
require "Mail_Mime.php";
require "Crypt/GPG.php";

define('BASE', dirname(__DIR__));
require BASE.'/config.php';

if (isset($_POST['from']) && isset($_POST['message'])) {
    $gpg = new Crypt_GPG([
        'homedir' => BASE
    ]);
    $fingerprint = $gpg->getFingerprint(
        OUR_EMAIL_ADDRESS
    );

    $ciphertext = $gpg->encrypt(
        "From: {$_POST['from']}\n\nMessage:\n{$_POST['message']}",
        $fingerprint
    );

    $email = Mail::factory('mail');
    $email->send(
        [OUR_EMAIL_ADDRESS],
        ['From' => 'Contact Form <contact@anonymo.us>'],
        $ciphertext
    );
    header("Location: contact_form.php?msg=success");
    exit;
}
header("Location: contact_form.php");
exit;

Remove "// Just for the lulz" as we are not sending to NSA TAO


<?php

namespace ForkCMS\Bundle\InstallerBundle\Form\Handler;

use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;

/**
 * Validates and saves the data from the languages form
 *
 * @author Wouter Sioen <wouter.sioen@wijs.be>
 */
class LanguagesHandler
{
    public function process(Form $form, Request $request)
    {
        if (!$request->isMethod('POST')) {
            return false;
        }

        $form->handleRequest($request);

        if ($form->isValid()) {
            return $this->processValidForm($form, $request);
        }

        return false;
    }

    public function processValidForm(Form $form, $request)
    {
        $session = $request->getSession();
        $data = $form->getData();

        $session->set('default_language', $data['default_language']);
        $session->set('default_interface_language', $data['interface_language']);
        $session->set('multiple_languages', $data['language_type'] === 'multiple');
        $session->set('languages', $data['languages']);
        $session->set('interface_languages', $data['interface_languages']);

        return true;
    }
}

<?php

namespace ForkCMS\Bundle\InstallerBundle\Form\Handler;

use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;

/**
 * Validates and saves the data from the languages form
 *
 * @author Wouter Sioen <wouter.sioen@wijs.be>
 */
class LanguagesHandler
{
    public function process(Form $form, Request $request)
    {
        if (!$request->isMethod('POST')) {
            return false;
        }

        $form->handleRequest($request);

        if ($form->isValid()) {
            return $this->processValidForm($form, $request);
        }

        return false;
    }

    public function processValidForm(Form $form, $request)
    {
        $session = $request->getSession();
        $data = $form->getData();

        $session->set('default_language', $data['default_language']);
        $session->set('default_interface_language', $data['interface_language']);
        $session->set('multiple_languages', $data['language_type'] === 'multiple');

        // different fields for single and multiple language
        $session->set(
            'languages',
            ($data['language_type'] === 'multiple')
                ? $data['languages']
                : array($data['default_language'])
        );

        // take same_interface_language field into account
        $session->set(
            'interface_languages',
            ($data['same_interface_language'] === true)
                ? $session->get('languages')
                : $data['interface_languages']
        );

        return true;
    }
}

Make sure installingen single language sites works.

We didn't take the right values for single language sites.


<?php

final class PhabricatorApplicationDatasource
  extends PhabricatorTypeaheadDatasource {

  public function getBrowseTitle() {
    return pht('Browse Applications');
  }

  public function getPlaceholderText() {
    return pht('Type an application name...');
  }

  public function getDatasourceApplicationClass() {
    return 'PhabricatorApplicationsApplication';
  }

  public function loadResults() {
    $viewer = $this->getViewer();
    $raw_query = $this->getRawQuery();

    $results = array();

    $applications = PhabricatorApplication::getAllInstalledApplications();
    foreach ($applications as $application) {
      $uri = $application->getTypeaheadURI();
      if (!$uri) {
        continue;
      }
      $name = $application->getName().' '.$application->getShortDescription();
      $img = 'phui-font-fa phui-icon-view '.$application->getIcon();
      $results[] = id(new PhabricatorTypeaheadResult())
        ->setName($name)
        ->setURI($uri)
        ->setPHID($application->getPHID())
        ->setPriorityString($application->getName())
        ->setDisplayName($application->getName())
        ->setDisplayType($application->getShortDescription())
        ->setPriorityType('apps')
        ->setImageSprite('phabricator-search-icon '.$img)
        ->setIcon($application->getIcon())
        ->addAttribute($application->getShortDescription());
    }

    return $this->filterResultsAgainstTokens($results);
  }

}

<?php

final class PhabricatorApplicationDatasource
  extends PhabricatorTypeaheadDatasource {

  public function getBrowseTitle() {
    return pht('Browse Applications');
  }

  public function getPlaceholderText() {
    return pht('Type an application name...');
  }

  public function getDatasourceApplicationClass() {
    return 'PhabricatorApplicationsApplication';
  }

  public function loadResults() {
    $viewer = $this->getViewer();
    $raw_query = $this->getRawQuery();

    $results = array();

    $applications = PhabricatorApplication::getAllInstalledApplications();
    foreach ($applications as $application) {
      $uri = $application->getTypeaheadURI();
      if (!$uri) {
        continue;
      }
      $is_installed = PhabricatorApplication::isClassInstalledForViewer(
        get_class($application),
        $viewer);
      if (!$is_installed) {
        continue;
      }
      $name = $application->getName().' '.$application->getShortDescription();
      $img = 'phui-font-fa phui-icon-view '.$application->getIcon();
      $results[] = id(new PhabricatorTypeaheadResult())
        ->setName($name)
        ->setURI($uri)
        ->setPHID($application->getPHID())
        ->setPriorityString($application->getName())
        ->setDisplayName($application->getName())
        ->setDisplayType($application->getShortDescription())
        ->setPriorityType('apps')
        ->setImageSprite('phabricator-search-icon '.$img)
        ->setIcon($application->getIcon())
        ->addAttribute($application->getShortDescription());
    }

    return $this->filterResultsAgainstTokens($results);
  }

}

Check if app is installed for user before displying

Summary: Fixes T11595. Previously if a user didn't have permissions to view an application it would still appear in the application typeahead in various menus. This change will prevent that by checking if the app is installed for the viewer before displaying it as an option

Test Plan: I went to the "Pin Applications" menu and typed in "Conpherence" and saw it appear as an option. I then went to the "Edit Policies" menu as an admin and removed permissions for my user to use Conpherence. Once I did that, it no longer showed up in the typeahead menu

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley, yelirekim

Maniphest Tasks: T11595

Differential Revision: https://secure.phabricator.com/D16518


<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind(
            'Illuminate\Contracts\Auth\Registrar',
            'App\Services\Registrar'
        );

        if ($this->app->environment() == 'local') {
            $this->app->register('Laracasts\Generators\GeneratorsServiceProvider');
            $this->app->register('Barryvdh\Debugbar\ServiceProvider');
            $this->app->register('Potsky\LaravelLocalizationHelpers\LaravelLocalizationHelpersServiceProvider');
        }

        if ($this->app->environment() != 'testing') {
            $this->app->register(Jenssegers\Rollbar\RollbarServiceProvider::class);
        }
    }
}

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Jenssegers\Rollbar\RollbarServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind(
            'Illuminate\Contracts\Auth\Registrar',
            'App\Services\Registrar'
        );

        if ($this->app->environment() == 'local') {
            $this->app->register('Laracasts\Generators\GeneratorsServiceProvider');
            $this->app->register('Barryvdh\Debugbar\ServiceProvider');
            $this->app->register('Potsky\LaravelLocalizationHelpers\LaravelLocalizationHelpersServiceProvider');
        }

        if ($this->app->environment() != 'testing') {
            $this->app->register(RollbarServiceProvider::class);
        }
    }
}

Fix service provider import path

Fix service provider import path


<?php

namespace TeamTeaTime\Filer;

use Illuminate\Support\ServiceProvider;

class FilerServiceProvider extends ServiceProvider
{

    /**
    * Register the service provider.
    *
    * @return void
    */
    public function register()
    {
        $this->mergeConfigFrom(__DIR__.'/../config/filer.php', 'filer');
    }

    /**
    * Bootstrap the application events.
    *
    * @param  Router  $router
    * @return void
    */
    public function boot(Router $router)
    {
        // Publish migrations and config
        $this->publishes([
            __DIR__.'/../migrations/' => base_path('/database/migrations')
        ], 'migrations');

        $this->publishes([
            __DIR__.'/../config/filer.php' => config_path('filer.php')
        ], 'config');

        // Routes
        $router->group(['namespace' => 'TeamTeaTime\Filer\Controllers', 'prefix' => 'files'], function ($router) {
            $router->get('{id}/download', [
                'as'    => 'filer.file.download',
                'uses'  => 'LocalFileController@download'
            ]);
        });
    }

}

<?php

namespace TeamTeaTime\Filer;

use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;

class FilerServiceProvider extends ServiceProvider
{

    /**
    * Register the service provider.
    *
    * @return void
    */
    public function register()
    {
        $this->mergeConfigFrom(__DIR__.'/../config/filer.php', 'filer');
    }

    /**
    * Bootstrap the application events.
    *
    * @param  Router  $router
    * @return void
    */
    public function boot(Router $router)
    {
        // Publish migrations and config
        $this->publishes([
            __DIR__.'/../migrations/' => base_path('/database/migrations')
        ], 'migrations');

        $this->publishes([
            __DIR__.'/../config/filer.php' => config_path('filer.php')
        ], 'config');

        // Routes
        $router->group(['namespace' => 'TeamTeaTime\Filer\Controllers', 'prefix' => 'files'], function ($router) {
            $router->get('{id}/download', [
                'as'    => 'filer.file.download',
                'uses'  => 'LocalFileController@download'
            ]);
        });
    }

}

Add missing Router use statement

Add missing Router use statement


<?php

class KeysMatcherStub
{

    public function run()
    {
        return true;
    }
}

<?php

class KeysMatcherStub
{

    public function run()
    {
        return true;
    }

    public function getMessage()
    {
        return "foobar";
    }
}

Fix a problem with KeyMatcherStub.

Fix a problem with KeyMatcherStub.


<?php

namespace Wnx\LaravelStats;

use Illuminate\Support\ServiceProvider;

class StatsServiceProvider extends ServiceProvider
{
    public function boot()
    {
        if ($this->app->runningInConsole()) {
            $this->publishes([
                __DIR__.'/../config/stats.php' => config_path('stats.php'),
            ], 'config');
        }
    }

    public function register()
    {
        $this->mergeConfigFrom(__DIR__.'/../config/stats.php', 'stats');

        $this->commands([
            StatsListCommand::class,
        ]);
    }
}

<?php

namespace Wnx\LaravelStats;

use Illuminate\Support\ServiceProvider;

class StatsServiceProvider extends ServiceProvider
{
    /**
     * @var string
     */
    private $config = __DIR__.'/../config/stats.php';

    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {
        if ($this->app->runningInConsole()) {
            $this->publishes([
                $this->config => base_path('config/stats.php'),
            ], 'config');
        }
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->mergeConfigFrom($this->config, 'stats');

        $this->commands([
            StatsListCommand::class,
        ]);
    }
}

Use `base_path` instead of `config_path`

Latter one is not available for lumen


<?php

namespace Igorw\Ilias;

class Lexer
{
    private $whitespace = [' ', "\t", "\r", "\n"];
    private $nonAtom = ['(', ')', ' ', "\t", "\r", "\n"];

    public function tokenize($code)
    {
        $tokens = [];

        for ($i = 0, $length = strlen($code); $i < $length; $i++) {
            $char = $code[$i];

            // parens are single tokens
            if (in_array($char, ['(', ')'])) {
                $tokens[] = $char;
                continue;
            }

            // kill whitespace
            if (in_array($char, $this->whitespace)) {
                continue;
            }

            // quote token (just the quote character)
            if ("'" === $char) {
                $tokens[] = $char;
                continue;
            }

            // atom token
            $atom = '';
            $next = $char;
            do {
                $atom .= $next;
                $next = ($length > $i+1) ? $code[$i+1] : null;
            } while (null !== $next && !in_array($next, $this->nonAtom) && ++$i);
            $tokens[] = $atom;
        }

        return $tokens;
    }
}

<?php

namespace Igorw\Ilias;

class Lexer
{
    private $whitespace = [' ', "\t", "\r", "\n"];
    private $nonAtom = ['(', ')', ' ', "\t", "\r", "\n"];

    public function tokenize($code)
    {
        $tokens = [];

        for ($i = 0, $length = strlen($code); $i < $length; $i++) {
            $char = $code[$i];

            // kill whitespace
            if (in_array($char, $this->whitespace)) {
                continue;
            }

            // parens are single tokens
            if (in_array($char, ['(', ')'])) {
                $tokens[] = $char;
                continue;
            }

            // quote token (just the quote character)
            if ("'" === $char) {
                $tokens[] = $char;
                continue;
            }

            // atom token
            $atom = '';
            $next = $char;
            do {
                $atom .= $next;
                $next = ($length > $i+1) ? $code[$i+1] : null;
            } while (null !== $next && !in_array($next, $this->nonAtom) && ++$i);
            $tokens[] = $atom;
        }

        return $tokens;
    }
}

Move lexer whitespace check first

Move lexer whitespace check first


<?php

namespace App\Back\Http\Requests\System;

use App\Core\Http\Requests\Request;

class UserRequest extends Request
{

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required',
            'email' => 'required|email',
        ];
    }

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

}

<?php

namespace App\Back\Http\Requests\System;

use App\Core\Http\Requests\Request;

/**
 * @property mixed users
 */
class UserRequest extends Request
{

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->method()) {
            case 'POST': {
                return [
                    'email' => "required|email|unique:users,email",
                    'name' => "required",
                ];
            }

            case 'PUT':
            case 'PATCH': {
                return [
                    'email' => "required|email|unique:users,email,{$this->users}",
                    'name' => "required",
                ];
            }
        }
    }

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

}

Add validator unique email to request user


<?php

namespace Rogue\Http\Transformers;

use Rogue\Models\Reaction;
use League\Fractal\TransformerAbstract;

class ReactionTransformer extends TransformerAbstract
{
    /**
     * Transform the resource data.
     *
     * @param \Rogue\Models\Reaction $reaction
     * @return array
     */
    public function transform(Reaction $reaction)
    {
        return [
            'northstar_id' => $reaction->northstar_id,
            'post_id' => (string) $reaction->post_id,
            'created_at' => $reaction->created_at,
            'updated_at' => $reaction->updated_at,
            'deleted_at' => $reaction->deleted_at,
        ];
    }
}

<?php

namespace Rogue\Http\Transformers;

use Rogue\Models\Reaction;
use League\Fractal\TransformerAbstract;

class ReactionTransformer extends TransformerAbstract
{
    /**
     * Transform the resource data.
     *
     * @param \Rogue\Models\Reaction $reaction
     * @return array
     */
    public function transform(Reaction $reaction)
    {
        return [
            'northstar_id' => $reaction->northstar_id,
            'post_id' => (string) $reaction->post_id,
            'created_at' => $reaction->created_at->toIso8601String(),
            'updated_at' => $reaction->updated_at->toIso8601String(),
            'deleted_at' => is_null($reaction->deleted_at) ? null : $reaction->deleted_at->toIso8601String(),
        ];
    }
}

Update format of the timestamp properties in the reaction response


<?
	//Start of index.php
	require_once('engine/require.php');
	require_once('engine/includes/motor.php');
?>
<!DOCTYPE HTML>

	<meta charset="utf-8">
	<title>VPG Blog</title>
	<link rel="stylesheet" type="text/css" href="./assets/style/style.css" />

VPG szakkör blog

			<? require('engine/includes/loginform.php'); ?>

			<? require('engine/includes/tartalom.php'); ?>

			Copyright

Revert "added jquery 4 bence"

Revert "added jquery 4 bence"

This reverts commit 036c16bdaeac0d5c4dc3105dcff35f9e61857ca3.


<?php

/*
 * This file is part of the Sami utility.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Sami\RemoteRepository;

class GitHubRemoteRepository extends AbstractRemoteRepository
{
    public function getFileUrl($projectVersion, $relativePath, $line)
    {
        $url = 'https://github.com/'.$this->name.'/blob/'.$projectVersion.$relativePath;

        if (null !== $line) {
            $url .= '#L'.(int) $line;
        }

        return $url;
    }
}

<?php

/*
 * This file is part of the Sami utility.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Sami\RemoteRepository;

class GitHubRemoteRepository extends AbstractRemoteRepository
{
    public function getFileUrl($projectVersion, $relativePath, $line)
    {
        $url = 'https://github.com/'.$this->name.'/blob/'.str_replace('\\', '/', $projectVersion.$relativePath);

        if (null !== $line) {
            $url .= '#L'.(int) $line;
        }

        return $url;
    }
}

Fix for wrong slashes on Windows

Fix for wrong slashes on Windows


<?php

/*
 * This file is part of the Silex framework.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Silex\Tests\Provider\ValidatorServiceProviderTest\Constraint;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;

/**
 * @author Alex Kalyvitis <alex.kalyvitis@gmail.com>
 */
class CustomValidator extends ConstraintValidator
{
    public function isValid($value, Constraint $constraint)
    {
        // Validate...
        return true;
    }
}

<?php

/*
 * This file is part of the Silex framework.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Silex\Tests\Provider\ValidatorServiceProviderTest\Constraint;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;

/**
 * @author Alex Kalyvitis <alex.kalyvitis@gmail.com>
 */
class CustomValidator extends ConstraintValidator
{
    public function isValid($value, Constraint $constraint)
    {
        // Validate...
        return true;
    }

    public function validate($value, Constraint $constraint)
    {
        return $this->isValid($value, $constraint);
    }
}

Add alias method to conform with ConstraintValidatorInterface in 2.3


<?php

namespace wcf\system\language\preload\command;

use wcf\data\language\Language;

/**
 * Resets the preload cache for the requested language.
 *
 * @author Alexander Ebert
 * @copyright 2001-2022 WoltLab GmbH
 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package WoltLabSuite\Core\System\Language\Preload\Command
 * @since 6.0
 */
final class ResetPreloadCache
{
    private readonly Language $language;

    public function __construct(Language $language)
    {
        $this->language = $language;
    }

    public function __invoke(): void
    {
        // Try to remove the file if it exists.
        @\unlink(\WCF_DIR . $this->language->getPreloadCacheFilename());
    }
}

<?php

namespace wcf\system\language\preload\command;

use wcf\data\language\Language;

/**
 * Resets the preload cache for the requested language.
 *
 * @author Alexander Ebert
 * @copyright 2001-2022 WoltLab GmbH
 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package WoltLabSuite\Core\System\Language\Preload\Command
 * @since 6.0
 */
final class ResetPreloadCache
{
    private readonly Language $language;

    public function __construct(Language $language)
    {
        $this->language = $language;
    }

    public function __invoke(): void
    {
        // Try to remove the file if it exists.
        $filename = \WCF_DIR . $this->language->getPreloadCacheFilename();
        if (\file_exists($filename)) {
            \unlink($filename);
        }
    }
}

Replace `@\unlink()` with a check for file existence


<?php

namespace BrainMaestro\GitHooks\Commands;

use BrainMaestro\GitHooks\Hook;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class HookCommand extends Command
{
    private $hook;
    private $script;

    public function __construct($hook, $script)
    {
        $this->hook = $hook;
        $this->script = $script;
        parent::__construct();
    }

    protected function configure()
    {
        $this
            ->setName($this->hook)
            ->setDescription("Test your {$this->hook} hook")
            ->setHelp("This command allows you to test your {$this->hook} hook")
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln(shell_exec($this->script));
    }
}

<?php

namespace BrainMaestro\GitHooks\Commands;

use BrainMaestro\GitHooks\Hook;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class HookCommand extends Command
{
    private $hook;
    private $script;

    public function __construct($hook, $script)
    {
        $this->hook = $hook;
        $this->script = $script;
        parent::__construct();
    }

    protected function configure()
    {
        $this
            ->setName($this->hook)
            ->setDescription("Test your {$this->hook} hook")
            ->setHelp("This command allows you to test your {$this->hook} hook")
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $script = is_array($this->script) ? implode(PHP_EOL, $this->script) : $this->script;
        $output->writeln(shell_exec($script));
    }
}

Update hook command to support multiple commands


<?php

use Cake\Routing\Route\DashedRoute;
use Cake\Routing\RouteBuilder;
use Cake\Routing\Router;

Router::plugin('Captcha', ['path' => '/captcha'], function (RouteBuilder $routes) {
	$routes->setExtensions(['png', 'jpg']);
	$routes->fallbacks(DashedRoute::class);
});

<?php
/**
 * @var \Cake\Routing\RouteBuilder $routes
 */

use Cake\Routing\Route\DashedRoute;
use Cake\Routing\RouteBuilder;
use Cake\Routing\Router;

Router::plugin('Captcha', ['path' => '/captcha'], function (RouteBuilder $routes) {
	$routes->setExtensions(['png', 'jpg']);
	$routes->fallbacks(DashedRoute::class);
});

Add annotation through IdeHelper run

Add annotation through IdeHelper run


<?php

namespace Oro\Bundle\EntityBundle\Tests\Functional\DataFixtures;

use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\Persistence\ObjectManager;

use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

use Oro\Bundle\OrganizationBundle\Entity\BusinessUnit;

class LoadBusinessUnitData extends AbstractFixture implements ContainerAwareInterface
{
    /** @var ContainerInterface */
    protected $container;

    /**
     * {@inheritdoc}
     */
    public function setContainer(ContainerInterface $container = null)
    {
        $this->container = $container;
    }

    /**
     * {@inheritdoc}
     */
    public function load(ObjectManager $manager)
    {
        $organization = $manager->getRepository('OroOrganizationBundle:Organization')->getFirst();

        $businessUnit = new BusinessUnit();
        $businessUnit->setOrganization($organization);
        $businessUnit->setName('TestBusinessUnit');

        $manager->persist($businessUnit);
        $this->setReference('TestBusinessUnit', $businessUnit);
        $manager->flush();
    }
}

CRM-4573: Add ability to save multiple values for patch API