@if (!$hideTitle && !empty($post_title))
    @typography(['element' => 'h2'])
        {!! apply_filters('the_title', $post_title) !!}
    @endtypography
@endif

    @foreach ($items as $item)

            @card([
                'link'      => $item['permalink'],
                'classList' => ['u-height--100', 'u-height-100'],
                'context'   => 'index',
                'hasAction' => true,
            ])

                @if($item['thumbnail'][0])

                @endif

                    @if (!empty($item['title']))
                        @typography([
                            'element' => "h2",
                            'classList' => ['c-card__heading'],
                        ])
                            {{ $item['title'] }}
                        @endtypography
                    @endif

                    {!! $item['lead'] !!}

            @endcard

    @endforeach

@if (!$hideTitle && !empty($post_title))
    @typography([
        'id' => 'mod-posts-' . $ID . '-label',
        'element' => 'h4',
        'variant' => 'h2',
        'classList' => ['module-title']
    ])
        {!! apply_filters('the_title', $post_title) !!}
    @endtypography
@endif

    @foreach ($items as $item)

            @card([
                'link'      => $item['permalink'],
                'classList' => ['u-height--100', 'u-height-100'],
                'context'   => 'index',
                'hasAction' => true,
            ])

                @if($item['thumbnail'][0])

                @endif

                    @if (!empty($item['title']))
                        @typography([
                            'element' => "h2",
                            'classList' => ['c-card__heading'],
                        ])
                            {{ $item['title'] }}
                        @endtypography
                    @endif

                    {!! $item['lead'] !!}

            @endcard

    @endforeach

Fix margins on index titles

Fix margins on index titles


<?php

/*
* This file is part of the Integrated package.
*
* (c) e-Active B.V. <integrated@e-active.nl>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Integrated\Bundle\SolrBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;

/**
 * IntegratedContentExtension for loading configuration
 *
 * @author Jeroen van Leeuwen <jeroen@e-active.nl>
 */
class IntegratedSolrExtension extends Extension
{
    /**
     * Load the configuration
     *
     * @param array $configs
     * @param ContainerBuilder $container
     */
    public function load(array $configs, ContainerBuilder $container)
    {
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('services.xml');

        $configuration = new Configuration;

        $config = $this->processConfiguration($configuration, $configs);

        $directories = array();
        foreach ($config['mapping']['directories'] as $directory) {
            $directories[$directory['namespace_prefix']] = $directory['path'];
        }

        $container
            ->getDefinition('integrated_solr.mapping.file_locator')
            ->replaceArgument(0, $directories)
        ;
    }
}

<?php

/*
* This file is part of the Integrated package.
*
* (c) e-Active B.V. <integrated@e-active.nl>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Integrated\Bundle\SolrBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;

/**
 * IntegratedContentExtension for loading configuration
 *
 * @author Jeroen van Leeuwen <jeroen@e-active.nl>
 */
class IntegratedSolrExtension extends Extension
{
    /**
     * Load the configuration
     *
     * @param array $configs
     * @param ContainerBuilder $container
     */
    public function load(array $configs, ContainerBuilder $container)
    {
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('services.xml');

        $configuration = new Configuration;

        $config = $this->processConfiguration($configuration, $configs);

        if ((isset($config['mapping']['directories'])) && is_array($config['mapping']['directories'])) {
            $directories = array();
            foreach ($config['mapping']['directories'] as $directory) {
                $directories[$directory['namespace_prefix']] = $directory['path'];
            }

            $container
                ->getDefinition('integrated_solr.mapping.driver.file_locator')
                ->replaceArgument(0, $directories)
            ;
        }
    }
}

Use renamed driver and added if statement to check if directories are set


<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Milestone extends Model
{
  public function tickets()
  {
      return $this->hasMany('App\Ticket');
  }
}

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Milestone extends Model
{

  public $timestamps = false;

  protected $fillable = [
      'name','description','start_at','due_at','end_at',
  ];

  public function tickets()
  {
      return $this->hasMany('App\Ticket');
  }
}

Add fillable options to milestone

Add fillable options to milestone


<?php

$http = new swoole_http_server("0.0.0.0", 9501);

$http->addlistener("/run/php/swoole.sock", 0, SWOOLE_UNIX_STREAM);
$http->set([
    'user' => 'www-data',
    'group' => 'www-data',
]);
$http->on('request', function ($request, $response) {
    $response->header("Content-Type", "text/html; charset=utf-8");
    //$response->end("
Hello Swoole. #".rand(1000, 9999)."
");
    $response->end("Hello, world");
});

$http->start();

<?php

$http = new swoole_http_server("0.0.0.0", 9501);

$http->addlistener("/run/php/swoole.sock", 0, SWOOLE_UNIX_STREAM);

$http->on('request', function ($request, $response) {
    $response->header("Content-Type", "text/html; charset=utf-8");
    //$response->end("
Hello Swoole. #".rand(1000, 9999)."
");
    $response->end("Hello, world");
});

$http->start();

Remove unneeded user and group settings from Swoole app


<?php

namespace Nerd\Framework\Http\IO;

use Nerd\Framework\Http\Response\CookieContract;

interface OutputContract
{
    /**
     * Send cookie to client
     *
     * @param CookieContract $cookie
     * @return mixed
     */
    public function sendCookie(CookieContract $cookie);

    /**
     * Send header to client
     *
     * @param $header
     * @return mixed
     */
    public function sendHeader($header);

    /**
     * Send data to client.
     *
     * @param $data
     * @return mixed
     */
    public function sendData($data);

    /**
     * Return are headers was sent
     *
     * @return mixed
     */
    public function isHeadersSent();

    /**
     * Clear output buffer
     */
    public function flush();
}

<?php

namespace Nerd\Framework\Http\IO;

use Nerd\Framework\Http\Response\CookieContract;

interface OutputContract
{
    /**
     * Send cookie to client
     *
     * @param CookieContract $cookie
     * @return mixed
     */
    public function sendCookie(CookieContract $cookie);

    /**
     * Send header to client
     *
     * @param $header
     * @return mixed
     */
    public function sendHeader($header);

    /**
     * Send data to client.
     *
     * @param $data
     * @return mixed
     */
    public function sendData($data);

    /**
     * Return are headers was sent
     *
     * @return mixed
     */
    public function isHeadersSent();

    /**
     * Clear output buffer
     */
    public function flush();

    /**
     * Close output
     */
    public function close();
}

Add close() method to HttpOutput

Add close() method to HttpOutput


    If you have problems or questions, please contact grants@apogaea.com

    This project is 100% Free Open Source Software, available via GitHub.

    Made with love by nerds

Add contact info to the footer

Add contact info to the footer

Add the grants@apogaea email to the footer, so that it is on every page.
f someone has a problem the may not look on the home or about pages.

Signed-off-by: Marc Jones <bb1304e98184a66f7e15848bfbd0ff1c09583089@gmail.com>


<?php
require_once __DIR__ . '/vendor/autoload.php';

use Stichoza\GoogleTranslate\TranslateClient;

class translate extends Script
{
	public function run()
	{
		$tr = new TranslateClient($this->matches[1], $this->matches[2]);

		$translatedText = $tr->translate($this->matches[3]);

		if($this->matches[1] === 'AUTO') {
			$this->send('You are translating from ' . $tr->getLastDetectedSource());
		}

		return $this->send($translatedText);
	}
}

<?php
require_once __DIR__ . '/vendor/autoload.php';

use Stichoza\GoogleTranslate\TranslateClient;

class translate extends Script
{
	protected $helpMessage = "'translate from LANGUAGECODE to LANGUAGECODE STRING'\n"
							."'translate from LANGUAGECODE to LANGUAGECODE STRING'\n"
							."'tr LANGUAGECODE - LANGUAGECODE STRING'\n"
							."You can use 'AUTO' as LANGUAGECODE to detect the language of the given string.";
	protected $description = 'Translates a given string';

	public function run()
	{
		$tr = new TranslateClient($this->matches[1], $this->matches[2]);

		$translatedText = $tr->translate($this->matches[3]);

		if($this->matches[1] === 'AUTO') {
			$this->send('You are translating from ' . $tr->getLastDetectedSource());
		}

		return $this->send($translatedText);
	}
}

Complete the information for the help-plugin


<?php namespace Grcote7\Profile\Updates;

use Schema;
use October\Rain\Database\Updates\Migration;

class AddNewFields extends Migration {

  public function up() {
    Schema::table('users', function ($table) {
      $table->string('facebook')->nullable();
      $table->text('bio')->nullable();
    });
  }

  public function down() {
    $table->dropDown([
                       'facebook',
                       'bio'
                     ]);
  }

}

// php artisan plugin:refresh grcote7.profile

<?php namespace Grcote7\Profile\Updates;

use Schema;
use October\Rain\Database\Updates\Migration;

class AddNewFields extends Migration {

  public function up() {
    Schema::table('users', function ($table) {
      $table->string('facebook')->nullable();
      $table->text('bio')->nullable();
    });
  }

  public function down() {
    Schema::table('users', function ($table) {
      $table->dropColumn([
                           'facebook',
                           'bio'
                         ]);
    });
  }
}
// php artisan plugin:refresh grcote7.profile

Fix down() in db users update pour plugin profile


<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/{any}', function () {
    return view('welcome');
})->where('any', '.*');

Add handler for front end routing to server side router.


<?php
/**
 * Database controller. Search and select database connections
 */

namespace Dboss\Controller;

class DatabaseController extends DbossActionController
{
    public $require_login = true;
    public $require_connection = false;

    /**
     *
     **/
    public function indexAction()
    {
        $this->view_model->setVariable(
            'connection_info',
            $this->user->getConnectionInfo()
        );

        return $this->view_model;
    }
}

<?php
/**
 * Database controller. Search and select database connections
 */

namespace Dboss\Controller;

class DatabaseController extends DbossActionController
{
    public $require_login = true;
    public $require_connection = false;

    /**
     *
     **/
    public function indexAction()
    {
        $this->view_model->setVariable(
            'connection_info',
            $this->user->getConnectionInfo()
        );

        foreach ($this->user->getFailedConnections() as $display_name) {
            $this->flashMessenger()
                    ->setNamespace('error')
                    ->addMessage("Failed to connect to: " . $display_name);
        }

        return $this->view_model;
    }
}

Add error message
Ticket:
Purpose of Change:
Description of Change:
Tags:

Conflicts Resolved:


<?php foreach ($options as $index => $choice): ?>
    <?php if ($view['form']->isChoiceGroup($choice)): ?>
        <optgroup label="<?php echo $view->escape($view['translator']->trans($index, array(), $translation_domain)) ?>">
            <?php foreach ($choice as $nested_choice): ?>
                <option value="<?php echo $view->escape($nested_choice->getValue()) ?>"<?php if ($view['form']->isChoiceSelected($form, $nested_choice)): ?> selected="selected"<?php endif?>><?php echo $view->escape($view['translator']->trans($nested_choice->getLabel(), array(), $translation_domain)) ?></option>
            <?php endforeach ?>
        </optgroup>
    <?php else: ?>
        <option value="<?php echo $view->escape($choice->getValue()) ?>"<?php if ($view['form']->isChoiceSelected($form, $choice)): ?> selected="selected"<?php endif?>><?php echo $view->escape($view['translator']->trans($choice->getLabel(), array(), $translation_domain)) ?></option>
    <?php endif ?>
<?php endforeach ?>

<?php foreach ($options as $index => $choice): ?>
    <?php if ($view['form']->isChoiceGroup($choice)): ?>
        <optgroup label="<?php echo $view->escape($view['translator']->trans($index, array(), $translation_domain)) ?>">
            <?php foreach ($choice as $nested_choice): ?>
                <option value="<?php echo $view->escape($nested_choice->value) ?>"<?php if ($view['form']->isChoiceSelected($form, $nested_choice)): ?> selected="selected"<?php endif?>><?php echo $view->escape($view['translator']->trans($nested_choice->label, array(), $translation_domain)) ?></option>
            <?php endforeach ?>
        </optgroup>
    <?php else: ?>
        <option value="<?php echo $view->escape($choice->value) ?>"<?php if ($view['form']->isChoiceSelected($form, $choice)): ?> selected="selected"<?php endif?>><?php echo $view->escape($view['translator']->trans($choice->label, array(), $translation_domain)) ?></option>
    <?php endif ?>
<?php endforeach ?>

[Form] Replace methods in ChoiceView by public properties (PHP +100ms, Twig +400ms)


<?php
namespace Loct\Pinger\Command;

use \Symfony\Component\Console\Application;
use \Symfony\Component\Console\Tester\CommandTester;
use \PHPUnit_Framework_TestCase;

class PingCommandTest extends PHPUnit_Framework_TestCase
{

    public function testExecuteIsSucces()
    {
        $hosts = [
            '127.0.0.1',
            'google.com'
        ];
        $notifier = $this->getMockBuilder('Loct\Pinger\Notifier\NotifierInterface')
            ->getMock();

        $notifier->expects($this->once())
            ->method('notify');

        $application = new Application();
        $application->add(new PingCommand($hosts, $notifier));

        $command = $application->find('ping');
        $commandTester = new CommandTester($command);
        $commandTester->execute(['command' => $command->getName()]);

        $display = $commandTester->getDisplay();
        $this->assertRegExp('/Finished ping-ing all hosts/', $display);
        foreach ($hosts as $host) {
            $this->assertRegExp("/{$hosts[0]}: /", $display);
        }
    }
}

<?php
namespace Loct\Pinger\Command;

use \Symfony\Component\Console\Application;
use \Symfony\Component\Console\Tester\CommandTester;
use \PHPUnit_Framework_TestCase;

class PingCommandTest extends PHPUnit_Framework_TestCase
{

    public function testExecuteIsSucces()
    {
        $hosts = [
            '127.0.0.1',
            'google.com',
            '192.168.0.123'
        ];
        $notifier = $this->getMockBuilder('Loct\Pinger\Notifier\NotifierInterface')
            ->getMock();

        $notifier->expects($this->once())
            ->method('notify');

        $application = new Application();
        $application->add(new PingCommand($hosts, $notifier));

        $command = $application->find('ping');
        $commandTester = new CommandTester($command);
        $commandTester->execute(['command' => $command->getName()]);

        $display = $commandTester->getDisplay();
        $this->assertRegExp('/Finished ping-ing all hosts/', $display);
        foreach ($hosts as $host) {
            $this->assertRegExp("/{$hosts[0]}/", $display);
        }
    }
}

Update ping command test case

Update ping command test case


<?php

if (!function_exists('cfg')) {
    /**
     * EasyCfg Helper.
     *
     * @param  mixed  $key
     * @param  mixed  $configurable
     * @param  mixed  $configurable_id
     * @return mixed
     */
    function cfg($key = null, $configurable = null, $configurable_id = null)
    {
        if ($key === null) {
            return Cfg::getFacadeRoot();
        } else {
            return Cfg::get($key, $configurable, $configurable_id);
        }
    }
}

<?php

if (!function_exists('cfg')) {
    /**
     * EasyCfg Helper.
     *
     * @param  mixed  $key
     * @param  mixed  $configurable
     * @param  mixed  $configurable_id
     * @return mixed
     */
    function cfg($key = null, $configurable = null, $configurable_id = null)
    {
        if ($key === null) {
            return app('CupOfTea\EasyCfg\Contracts\Provider');
        } else {
            return app('CupOfTea\EasyCfg\Contracts\Provider')->get($key, $configurable, $configurable_id);
        }
    }
}

Make helper independent from Facade

Make helper independent from Facade


    <?php echo $torrent->getFeed()->getTitle(); ?>

         Web
         <?php echo link_to($torrent->getUrl(false),$torrent->getUrl(false)); ?>

         Torrent
         <?php echo link_to($torrent->getUrl(true),$torrent->getUrl(true)) ?>

         Magnet
         <?php echo 'getMagnet(),'">',$torrent->getFileSha1(),''; ?>

    <?php if(@$delete): ?><?php echo delete_form_for_object($torrent); ?><?php endif; ?>

Fix float problem on episode page

Fix float problem on episode page


<?php

class Cache
{

	private function createCacheKey($key, $isUserValue, $userId = null) {

		$CC_CONFIG = Config::getConfig();
		$a = $CC_CONFIG["apiKey"][0];

		if ($isUserValue) {
			$cacheKey = "{$key}{$userId}{$a}";
		}
		else {
			$cacheKey = "{$key}{$a}";
		}

		return $cacheKey;
	}

	public function store($key, $value, $isUserValue, $userId = null) {

		$cacheKey = self::createCacheKey($key, $userId);
		return apc_store($cacheKey, $value);
	}

	public function fetch($key, $isUserValue, $userId = null) {

		$cacheKey = self::createCacheKey($key, $isUserValue, $userId);
		return apc_fetch($cacheKey);
	}
}

<?php

class Cache
{
	private function createCacheKey($key, $isUserValue, $userId = null) {

		$CC_CONFIG = Config::getConfig();
		$a = $CC_CONFIG["apiKey"][0];

		if ($isUserValue) {
			$cacheKey = "{$key}{$userId}{$a}";
		}
		else {
			$cacheKey = "{$key}{$a}";
		}

		return $cacheKey;
	}

	public function store($key, $value, $isUserValue, $userId = null) {

		//$cacheKey = self::createCacheKey($key, $userId);
		return false; ///apc_store($cacheKey, $value);
	}

	public function fetch($key, $isUserValue, $userId = null) {

		//$cacheKey = self::createCacheKey($key, $isUserValue, $userId);
		return false; //apc_fetch($cacheKey);
	}
}

Disable the APC cache for Ubuntu 14.04. APC is deprecated now so we need a better solution anyways.


<?php
/**
 * @copyright ©2014 Quicken Loans Inc. All rights reserved. Trade Secret,
 *    Confidential and Proprietary. Any dissemination outside of Quicken Loans
 *    is strictly prohibited.
 */

namespace MCP\Cache;

use MCP\DataType\Time\TimePoint;

/**
 * @internal
 */
class Memory implements CacheInterface
{
    use ValidationTrait;

    /**
     * @var array
     */
    private $cache;

    public function __construct()
    {
        $this->cache = [];
    }

    /**
     * {@inheritdoc}
     */
    public function get($key)
    {
        if (!isset($this->cache[$key])) {
            return null;
        }

        return $this->cache[$key];
    }

    /**
     * $ttl is ignored. If your data is living that long in memory, you got issues.
     *
     * {@inheritdoc}
     */
    public function set($key, $value, $ttl = 0)
    {
        $this->validateCacheability($value);

        $this->cache[$key] = $value;
        return true;
    }
}

<?php
/**
 * @copyright ©2014 Quicken Loans Inc. All rights reserved. Trade Secret,
 *    Confidential and Proprietary. Any dissemination outside of Quicken Loans
 *    is strictly prohibited.
 */

namespace MCP\Cache;

use MCP\DataType\Time\TimePoint;
use MCP\Cache\Item\Item;

/**
 * @internal
 */
class Memory implements CacheInterface
{
    /**
     * @var array
     */
    private $cache;

    public function __construct()
    {
        $this->cache = [];
    }

    /**
     * {@inheritdoc}
     */
    public function get($key)
    {
        if (!isset($this->cache[$key])) {
            return null;
        }

        $item = $this->cache[$key];
        if (!$item instanceof Item) {
            return null;
        }

        return $item->data();
    }

    /**
     * $ttl is ignored. If your data is living that long in memory, you got issues.
     *
     * {@inheritdoc}
     */
    public function set($key, $value, $ttl = 0)
    {
        $this->cache[$key] = new Item($value);
        return true;
    }
}

Use the cache item on the memory cache

Use the cache item on the memory cache


<?php

return [

    /*
     * Use this setting to enable the cookie consent dialog.
     */
    'enabled' => env('COOKIE_CONSENT_ENABLED', true),

    /*
     * The name of the cookie in which we store if the user
     * has agreed to accept the conditions.
     */
    'cookie_name' => 'laravel_cookie_consent',

    /*
     * Set the cookie duration in days.  Default is 365 * 20.
     */
    'cookie_lifetime' => 365 * 20,
];

<?php

return [

    /*
     * Use this setting to enable the cookie consent dialog.
     */
    'enabled' => env('COOKIE_CONSENT_ENABLED', false),

    /*
     * The name of the cookie in which we store if the user
     * has agreed to accept the conditions.
     */
    'cookie_name' => 'laravel_cookie_consent',

    /*
     * Set the cookie duration in days.  Default is 365 * 20.
     */
    'cookie_lifetime' => 365 * 20,
];

Revert "turn cookies on by default"

Revert "turn cookies on by default"

This reverts commit 65ac6a3d516d79b2fe157cd96a65c27205fa80be.


<?php

/**
 * Scheduler Home controller
 */
class SchedulerHomeManagerController extends SchedulerManagerController {
    /**
     * The pagetitle to put in the <title> attribute.
     * @return null|string
     */
    public function getPageTitle() {
        return $this->modx->lexicon('scheduler');
    }

    /**
     * Register all the needed javascript files.
     */
    public function loadCustomCssJs() {
        $this->addCss($this->scheduler->config['cssUrl'].'mgr.css');
        $this->addJavascript($this->scheduler->config['jsUrl'].'mgr/widgets/windows.tasks.js');
        $this->addJavascript($this->scheduler->config['jsUrl'].'mgr/widgets/grid.tasks.js');
        $this->addJavascript($this->scheduler->config['jsUrl'].'mgr/widgets/grid.history.js');
        $this->addJavascript($this->scheduler->config['jsUrl'].'mgr/widgets/grid.future.js');

        $this->addJavascript($this->scheduler->config['jsUrl'].'mgr/panels/home.js');
        $this->addLastJavascript($this->scheduler->config['jsUrl'].'mgr/sections/home.js');
    }
}

<?php

/**
 * Scheduler Home controller
 */
class SchedulerHomeManagerController extends SchedulerManagerController {
    /**
     * The pagetitle to put in the <title> attribute.
     * @return null|string
     */
    public function getPageTitle() {
        return $this->modx->lexicon('scheduler');
    }

    /**
     * Register all the needed javascript files.
     */
    public function loadCustomCssJs() {
        $this->addCss($this->scheduler->config['cssUrl'].'mgr.css');
        $this->addJavascript($this->scheduler->config['jsUrl'].'mgr/widgets/windows.tasks.js');
        $this->addJavascript($this->scheduler->config['jsUrl'].'mgr/widgets/grid.tasks.js');
        $this->addJavascript($this->scheduler->config['jsUrl'].'mgr/widgets/windows.future.js');
        $this->addJavascript($this->scheduler->config['jsUrl'].'mgr/widgets/grid.future.js');
        $this->addJavascript($this->scheduler->config['jsUrl'].'mgr/widgets/grid.history.js');

        $this->addJavascript($this->scheduler->config['jsUrl'].'mgr/panels/home.js');
        $this->addLastJavascript($this->scheduler->config['jsUrl'].'mgr/sections/home.js');
    }
}

Make home controller loading future grid window(s)


<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;

use App\Roles;

class RolesController extends Controller
{
    /**
     * Get the role overview.
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
    	$data['roles'] = Roles::all();
    	return view('roles.index', $data);
    }

    /**
     * Search for a specific role.
     *
     * @param  Request $request
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function search(Request $request)
    {
        $term = $request->get('term');
        $data['roles'] = Roles::where('name', 'LIKE', "$term");
        return view('roles.index', $data);
    }

    /**
     * Create a role in the database.
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function store()
    {

    }
}

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;

use App\Roles;

class RolesController extends Controller
{
    /**
     * Get the role overview.
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
    	$data['roles'] = Roles::all();
    	return view('roles.index', $data);
    }

    /**
     * Search for a specific role.
     *
     * @param  Request $request
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function search(Request $request)
    {
        $term = $request->get('term');
        $data['roles'] = Roles::where('name', 'LIKE', "$term")->get();
        return view('roles.index', $data);
    }

    /**
     * Create a role in the database.
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function store()
    {

    }

    /**
     * Destroy a role out off the database.
     *
     * @param  int $id The id in the database for the role.
     * @return \Illuminate\Http\RedirectResponse
     */
    public function destroy($id)
    {
        Roles::destroy($id);
        session()->flash('message', 'Role deleted');
        return redirect()->back(302);
    }
}

Add destroy method -> role

Add destroy method -> role


<?php
require_once "../../config.php";
require_once $CFG->dirroot."/pdo.php";
require_once $CFG->dirroot."/lib/lms_lib.php";
require_once "lib.php";

session_start();

// Sanity checks
$LTI = requireData(array('user_id', 'link_id', 'role','context_id', "result_id"));
$instructor = isInstructor($LTI);
if ( ! $instructor ) die("Requires instructor role");
$p = $CFG->dbprefix;

// Get basic grade data
$stmt = loadGrades($pdo);

// View
headerContent();
startBody();
flashMessages();
welcomeUserCourse($LTI);

if ( isset($GRADE_DETAIL_CLASS) && is_object($GRADE_DETAIL_CLASS) ) {
    showGrades($stmt, $GRADE_DETAIL_CLASS);
} else {
    showGrades($stmt, false);
}

footerContent();

<?php
require_once "../../config.php";
require_once $CFG->dirroot."/pdo.php";
require_once $CFG->dirroot."/lib/lms_lib.php";
require_once "lib.php";

session_start();

// Sanity checks
$LTI = requireData(array('user_id', 'link_id', 'role','context_id', "result_id"));
$instructor = isInstructor($LTI);
if ( ! $instructor ) die("Requires instructor role");
$p = $CFG->dbprefix;

// Get basic grade data
$query_parms = array(":LID" => $LTI['link_id']);
$orderfields =  array("R.updated_at", "displayname", "email", "grade");
$searchfields = $orderfields;
$sql =
    "SELECT R.user_id AS user_id, displayname, email,
        grade, note, R.updated_at AS updated_at
    FROM {$p}lti_result AS R
    JOIN {$p}lti_user AS U ON R.user_id = U.user_id
    WHERE R.link_id = :LID";

// View
headerContent();
startBody();
flashMessages();
welcomeUserCourse($LTI);

if ( isset($GRADE_DETAIL_CLASS) && is_object($GRADE_DETAIL_CLASS) ) {
    $detail = $GRADE_DETAIL_CLASS;
} else {
    $detail = false;
}

pagedPDO($pdo, $sql, $query_parms, $searchfields, $orderfields, "grade-detail.php");

footerContent();

Make pythonauto use the paged grader

Make pythonauto use the paged grader


<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', 'PagesController@index')->name('home');

Route::get('doc', 'DocumentsController@index')->name('doc');

Route::get('doc/upload', 'DocumentsController@upload')->name('doc_upload')
                                                      ->middleware('auth');

Route::post('doc/upload', 'DocumentsController@store')->name('doc_upload_post')
                                                      ->middleware('auth');

Route::get('doc/show/{title}', 'DocumentsController@show')->name('doc_show');

Route::get('doc/{id}/download', 'DocumentsController@download')->name('doc_download');

Route::delete('doc/{id}/delete', 'DocumentsController@destroy')->name('doc_delete')
                                                               ->middleware('auth');

Route::get('search', 'SearchController@index')->name('search');
Route::post('search', 'SearchController@search')->name('search_post');

Auth::routes();

Route::get('/dashboard', 'DashboardController@index')->name('dashboard');

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', 'PagesController@index')->name('home');

Route::get('doc', 'DocumentsController@index')->name('doc');

Route::get('doc/upload', 'DocumentsController@upload')->name('doc_upload')
                                                      ->middleware('auth');

Route::post('doc/upload', 'DocumentsController@store')->name('doc_upload_post')
                                                      ->middleware('auth');

Route::get('doc/show/{title}', 'DocumentsController@show')->name('doc_show');

Route::get('doc/{id}/download', 'DocumentsController@download')->name('doc_download');

Route::delete('doc/{id}/delete', 'DocumentsController@destroy')->name('doc_delete')
                                                               ->middleware('auth');

Route::get('search', 'SearchController@index')->name('search');

Auth::routes();

Route::get('/dashboard', 'DashboardController@index')->name('dashboard');

Remove broken search POST route

Remove broken search POST route


<?php
/**
 * @author    Igor Nikolaev <igor.sv.n@gmail.com>
 * @copyright Copyright (c) 2015, Darvin Studio
 * @link      https://www.darvin-studio.ru
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Darvin\UserBundle\Configuration;

use Darvin\ConfigBundle\Configuration\AbstractConfiguration;
use Darvin\ConfigBundle\Parameter\ParameterModel;

/**
 * Configuration
 *
 * @method array getNotificationEmails()
 */
class Configuration extends AbstractConfiguration
{
    /**
     * {@inheritdoc}
     */
    public function getModel()
    {
        return array(
            new ParameterModel('notification_emails', ParameterModel::TYPE_ARRAY, array(), array(
                'form' => array(
                    'options' => array(
                        'type'         => 'Symfony\Component\Form\Extension\Core\Type\EmailType',
                        'allow_add'    => true,
                        'allow_delete' => true,
                    ),
                ),
            )),
        );
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'darvin_user';
    }
}

<?php
/**
 * @author    Igor Nikolaev <igor.sv.n@gmail.com>
 * @copyright Copyright (c) 2015, Darvin Studio
 * @link      https://www.darvin-studio.ru
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Darvin\UserBundle\Configuration;

use Darvin\ConfigBundle\Configuration\AbstractConfiguration;
use Darvin\ConfigBundle\Parameter\ParameterModel;

/**
 * Configuration
 *
 * @method array getNotificationEmails()
 */
class Configuration extends AbstractConfiguration
{
    /**
     * {@inheritdoc}
     */
    public function getModel()
    {
        return array(
            new ParameterModel('notification_emails', ParameterModel::TYPE_ARRAY, array(), array(
                'form' => array(
                    'options' => array(
                        'entry_type'   => 'Symfony\Component\Form\Extension\Core\Type\EmailType',
                        'allow_add'    => true,
                        'allow_delete' => true,
                    ),
                ),
            )),
        );
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'darvin_user';
    }
}

Replace "type" form option with "entry_type".


<?php

final class ArcanistArcToolset extends ArcanistToolset {

  const TOOLSETKEY = 'arc';

  public function getToolsetArguments() {
    return array(
      array(
        'name' => 'conduit-uri',
        'param' => 'uri',
        'help' => pht('Connect to Phabricator install specified by __uri__.'),
      ),
      array(
        'name' => 'conduit-token',
        'param' => 'token',
        'help' => pht('Use a specific authentication token.'),
      ),
      array(
        'name' => 'anonymous',
        'help' => pht('Run workflow as a public user, without authenticating.'),
      ),
    );
  }

}

<?php

final class ArcanistArcToolset extends ArcanistToolset {

  const TOOLSETKEY = 'arc';

  public function getToolsetArguments() {
    return array(
      array(
        'name' => 'conduit-uri',
        'param' => 'uri',
        'help' => pht('Connect to Phabricator install specified by __uri__.'),
      ),
      array(
        'name' => 'conduit-token',
        'param' => 'token',
        'help' => pht('Use a specific authentication token.'),
      ),
    );
  }

}

Drop intended support for "--anonymous" from Arcanist Toolsets

Summary:
Currently, modern "arc" workflows accept and parse "--anonymous" but don't do anything with it.

I intend to move away from anonymous workflows, which only really supported a tiny subset of unusual workflows on open source installs but added significant complexity to login/auth behavior.

Drop support for this flag.

Test Plan: Grepped for "anonymous", didn't turn up any relevant hits.

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


<?php

namespace UWDOEM\Framework\FilterStatement;

use Propel\Runtime\ActiveQuery\ModelCriteria;

interface FilterStatementInterface {

    const COND_SORT_ASC = 1;
    const COND_SORT_DESC = 2;
    const COND_LESS_THAN = 3;
    const COND_GREATER_THAN = 4;
    const COND_EQUAL_TO = 5;
    const COND_NOT_EQUAL_TO = 6;
    const COND_CONTAINS = 7;
    const COND_PAGINATE_BY = 8;

    /**
     * @return string
     */
    public function getFieldName();

    /**
     * @return string
     */
    public function getCondition();

    /**
     * @return mixed
     */
    public function getCriterion();

    /**
     * @return mixed
     */
    public function getControl();

    /**
     * @param ModelCriteria $query
     * @return ModelCriteria
     */
    public function applyToQuery(ModelCriteria $query);

    /**
     * @param \UWDOEM\Framework\Row\Row[] $rows
     * @return \UWDOEM\Framework\Row\Row[]
     */
    public function applyToRows(array $rows);

}

<?php

namespace UWDOEM\Framework\FilterStatement;

use Propel\Runtime\ActiveQuery\ModelCriteria;

interface FilterStatementInterface {

    const COND_SORT_ASC = "ascending";
    const COND_SORT_DESC = "descending";
    const COND_LESS_THAN = 3;
    const COND_GREATER_THAN = 4;
    const COND_EQUAL_TO = 5;
    const COND_NOT_EQUAL_TO = 6;
    const COND_CONTAINS = 7;
    const COND_PAGINATE_BY = 8;

    /**
     * @return string
     */
    public function getFieldName();

    /**
     * @return string
     */
    public function getCondition();

    /**
     * @return mixed
     */
    public function getCriterion();

    /**
     * @return mixed
     */
    public function getControl();

    /**
     * @param ModelCriteria $query
     * @return ModelCriteria
     */
    public function applyToQuery(ModelCriteria $query);

    /**
     * @param \UWDOEM\Framework\Row\Row[] $rows
     * @return \UWDOEM\Framework\Row\Row[]
     */
    public function applyToRows(array $rows);

}

Make more use-friendly constants for sort ascending, descending.


<?php declare(strict_types=1);
/**
 * @author    Igor Nikolaev <igor.sv.n@gmail.com>
 * @copyright Copyright (c) 2017-2019, Darvin Studio
 * @link      https://www.darvin-studio.ru
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Darvin\ImageBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
 * Add Imagine filter sets compiler pass
 */
class AddImagineFilterSetsPass implements CompilerPassInterface
{
    /**
     * {@inheritDoc}
     */
    public function process(ContainerBuilder $container): void
    {
        $filterSets = [];
        $config     = $container->getParameter('darvin_image.imagine');

        foreach ($config['filter_sets'] as $name => $filterSet) {
            $filterSets[$name] = array_merge_recursive($config['filter_defaults'], [
                'cache' => 'darvin_image_custom',
            ], $filterSet);
        }

        $container->setParameter(
            'liip_imagine.filter_sets',
            array_merge($filterSets, $container->getParameter('liip_imagine.filter_sets'))
        );
    }
}

<?php declare(strict_types=1);
/**
 * @author    Igor Nikolaev <igor.sv.n@gmail.com>
 * @copyright Copyright (c) 2017-2019, Darvin Studio
 * @link      https://www.darvin-studio.ru
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Darvin\ImageBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
 * Add Imagine filter sets compiler pass
 */
class AddImagineFilterSetsPass implements CompilerPassInterface
{
    /**
     * {@inheritDoc}
     */
    public function process(ContainerBuilder $container): void
    {
        $filterSets = [];
        $config     = $container->getParameter('darvin_image.imagine');
        $formats    = array_keys(array_filter($container->getParameter('darvin_image.output_formats'), function (array $format): bool {
            return $format['enabled'];
        }));

        foreach ($config['filter_sets'] as $name => $filterSet) {
            $filterSet = array_merge_recursive($config['filter_defaults'], [
                'cache' => 'darvin_image_custom',
            ], $filterSet);

            $filterSets[$name] = $filterSet;

            foreach ($formats as $format) {
                $filterSets[implode('__', [$name, $format])] = array_merge($filterSet, [
                    'format' => $format,
                ]);
            }
        }

        $container->setParameter(
            'liip_imagine.filter_sets',
            array_merge($filterSets, $container->getParameter('liip_imagine.filter_sets'))
        );
    }
}

Add Imagine filters for output formats.

Add Imagine filters for output formats.


<?php
/**
 * @author           Pierre-Henry Soria <hello@ph7cms.com>
 * @copyright        (c) 2017-2018, Pierre-Henry Soria. All Rights Reserved.
 * @license          GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
 * @package          PH7 / Test / Unit / Framework / Mvc/ Request
 */

namespace PH7\Test\Unit\Framework\Mvc\Request;

use PH7\Framework\Mvc\Request\Http as HttpRequest;
use PHPUnit_Framework_TestCase;

class HttpTest extends PHPUnit_Framework_TestCase
{
    /** @var HttpRequest */
    private $oHttpRequest;

    protected function setUp()
    {
        $this->oHttpRequest = new HttpRequest;
    }

    public function testGetRequestWithIntCast()
    {
        $_SERVER['REQUEST_METHOD'] = 'GET';
        $_GET['string_id'] = '123';

        $sActual = $this->oHttpRequest->get('string_id', 'int');

        $this->assertSame(123, $sActual);
    }

    public function testPostRequestWithIntCast()
    {
        $_SERVER['REQUEST_METHOD'] = 'POST';
        $_POST['string_id'] = '123';

        $sActual = $this->oHttpRequest->post('string_id', 'int');

        $this->assertSame(123, $sActual);
    }

    protected function tearDown()
    {
        unset($_GET, $_POST, $_SERVER);
    }
}

<?php
/**
 * @author           Pierre-Henry Soria <hello@ph7cms.com>
 * @copyright        (c) 2017-2018, Pierre-Henry Soria. All Rights Reserved.
 * @license          GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
 * @package          PH7 / Test / Unit / Framework / Mvc/ Request
 */

namespace PH7\Test\Unit\Framework\Mvc\Request;

use PH7\Framework\Mvc\Request\Http as HttpRequest;
use PHPUnit_Framework_TestCase;

class HttpTest extends PHPUnit_Framework_TestCase
{
    /** @var HttpRequest */
    private $oHttpRequest;

    protected function setUp()
    {
        $this->oHttpRequest = new HttpRequest;
    }

    public function testGetRequestCastedToInt()
    {
        $_SERVER['REQUEST_METHOD'] = 'GET';
        $_GET['string_id'] = '123';

        $sActual = $this->oHttpRequest->get('string_id', 'int');

        $this->assertSame(123, $sActual);
    }

    public function testPostRequestCastedToInt()
    {
        $_SERVER['REQUEST_METHOD'] = 'POST';
        $_POST['string_id'] = '123';

        $sActual = $this->oHttpRequest->post('string_id', 'int');

        $this->assertSame(123, $sActual);
    }

    protected function tearDown()
    {
        unset($_GET, $_POST, $_SERVER);
    }
}

Rename to better method names

Rename to better method names


<?php

namespace App\Transformers\Inbound\Collections;

use App\Transformers\Datum;
use App\Transformers\Inbound\CollectionsTransformer;

class Asset extends CollectionsTransformer
{

    protected function getIds(Datum $datum)
    {
        return  [
            'lake_guid' => $datum->lake_guid,
        ];
    }

    protected function getDates(Datum $datum)
    {
        $dates = parent::getDates($datum);

        return array_merge($dates, [
            'content_modified_at' => $datum->date('content_modified_at'),
        ]);
    }

    protected function getSync(Datum $datum, $test = false)
    {
        return [
            'imagedArtworks' => $this->getSyncAssetOf($datum, 'rep_of_artworks'),
            'imagedExhibitions' => $this->getSyncAssetOf($datum, 'rep_of_exhibitions'),
            'documentedArtworks' => $this->getSyncAssetOf($datum, 'doc_of_artworks'),
            'documentedExhibitions' => $this->getSyncAssetOf($datum, 'doc_of_exhibitions'),
        ];
    }

    private function getSyncAssetOf(Datum $datum, string $pivot_field)
    {
        return $this->getSyncPivots($datum, $pivot_field, 'related_id', function ($pivot) {
            return [
                $pivot->related_id => [
                    'preferred' => $pivot->is_preferred,
                    'is_doc' => $pivot->is_doc,
                ],
            ];
        });
    }
}

<?php

namespace App\Transformers\Inbound\Collections;

use App\Transformers\Datum;
use App\Transformers\Inbound\CollectionsTransformer;

class Asset extends CollectionsTransformer
{

    protected function getIds(Datum $datum)
    {
        return  [
            'lake_guid' => $datum->id,
        ];
    }

    protected function getDates(Datum $datum)
    {
        $dates = parent::getDates($datum);

        return array_merge($dates, [
            'content_modified_at' => $datum->date('content_modified_at'),
        ]);
    }

    protected function getSync(Datum $datum, $test = false)
    {
        return [
            'imagedArtworks' => $this->getSyncAssetOf($datum, 'rep_of_artworks'),
            'imagedExhibitions' => $this->getSyncAssetOf($datum, 'rep_of_exhibitions'),
            'documentedArtworks' => $this->getSyncAssetOf($datum, 'doc_of_artworks'),
            'documentedExhibitions' => $this->getSyncAssetOf($datum, 'doc_of_exhibitions'),
        ];
    }

    private function getSyncAssetOf(Datum $datum, string $pivot_field)
    {
        return $this->getSyncPivots($datum, $pivot_field, 'related_id', function ($pivot) {
            return [
                $pivot->related_id => [
                    'preferred' => $pivot->is_preferred,
                    'is_doc' => $pivot->is_doc,
                ],
            ];
        });
    }
}

Use `id` instead of `lake_guid` for asset import [WEB-1870]


<?php
/**
 * Register widget areas
 *
 * @package FoundationPress
 * @since FoundationPress 1.0.0
 */

if ( ! function_exists( 'foundationpress_sidebar_widgets' ) ) :
function foundationpress_sidebar_widgets() {
	register_sidebar(array(
	  'id' => 'sidebar-widgets',
	  'name' => __( 'Sidebar widgets', 'foundationpress' ),
	  'description' => __( 'Drag widgets to this sidebar container.', 'foundationpress' ),
	  'before_widget' => '
',
	  'after_widget' => '
',
	  'before_title' => '
',
	  'after_title' => '
',
	));

	register_sidebar(array(
	  'id' => 'footer-widgets',
	  'name' => __( 'Footer widgets', 'foundationpress' ),
	  'description' => __( 'Drag widgets to this footer container', 'foundationpress' ),
	  'before_widget' => '
',
	  'after_widget' => '
',
	  'before_title' => '
',
	  'after_title' => '
',
	));
}

add_action( 'widgets_init', 'foundationpress_sidebar_widgets' );
endif;

Add class to footer widget headings.

Add class to footer widget headings.


<?php

$games = new SQLite3('games.sqlite') or die('Unable to open database');

while(1) {
    // Every 10 seconds delete any game that hasn't been updated in 30 seconds

    $result = $games->query("SELECT * FROM games");

    while($game = $result->fetchArray(SQLITE3_ASSOC)) {
        if(time() - $game['Time'] > 30) {
            $query = $games->prepare("DELETE FROM games WHERE a = :val");
            $query->bindValue(':val', $game['a'], SQLITE3_TEXT);
            $query->execute();
        }
    }
    sleep(10);
}

?>

<?php

$games = new SQLite3('games.sqlite') or die('Unable to open database');

while(1) {
    // Every 2 seconds delete any game that hasn't been updated in 30 seconds

    $result = $games->query("SELECT * FROM games");

    while($game = $result->fetchArray(SQLITE3_ASSOC)) {
        if(time() - $game['Time'] > 30) {
            $query = $games->prepare("DELETE FROM games WHERE a = :val");
            $query->bindValue(':val', $game['a'], SQLITE3_TEXT);
            $query->execute();
        }
    }
    sleep(2);
}

?>

Change check wait to 2 seconds

Change check wait to 2 seconds


<?php

namespace Test\Models;

class Post
{
    public $fillable = [
        'title', 'body', 'author_id'
    ];
}

<?php

namespace Test\Models;

class Post
{
    public $fillable = [
        'title', 'body', 'author_id'
    ];

    public function author()
    {
        return $this->belongsTo('Test\Models\User');
    }
}

Add a author eloquent relation (to the users table).


<?php namespace Tappleby\AuthToken;

use Illuminate\Support\ServiceProvider;

class AuthTokenServiceProvider extends ServiceProvider {

	/**
	 * Indicates if loading of the provider is deferred.
	 *
	 * @var bool
	 */
	protected $defer = false;

	/**
	 * Register the service provider.
	 *
	 * @return void
	 */
	public function register()
	{
    $this->app['tappleby.auth.token'] = $this->app->share(function($app) {
      return new AuthTokenManager($app);
    });

    $this->app['tappleby.auth.token.filter'] = $this->app->share(function($app) {
      $driver = $app['tappleby.auth.token']->driver();
      $events = $app['events'];

      return new AuthTokenFilter($driver, $events);
    });

    $this->app['tappleby.auth.token.controller'] = $this->app->share(function($app) {
      $driver = $app['tappleby.auth.token']->driver();

      return new AuthTokenController($driver);
    });

    $this->app['router']->addFilter('auth.token', 'tappleby.auth.token.filter');
	}

	/**
	 * Get the services provided by the provider.
	 *
	 * @return array
	 */
	public function provides()
	{
		return array('tappleby.auth.token', 'tappleby.auth.token.filter', 'tappleby.auth.token.controller');
	}

}

<?php namespace Tappleby\AuthToken;

use Illuminate\Support\ServiceProvider;

class AuthTokenServiceProvider extends ServiceProvider {

	/**
	 * Indicates if loading of the provider is deferred.
	 *
	 * @var bool
	 */
	protected $defer = false;

	/**
	 * Register the service provider.
	 *
	 * @return void
	 */
	public function register()
	{
    $this->app['tappleby.auth.token'] = $this->app->share(function($app) {
      return new AuthTokenManager($app);
    });

    $this->app['tappleby.auth.token.filter'] = $this->app->share(function($app) {
      $driver = $app['tappleby.auth.token']->driver();
      $events = $app['events'];

      return new AuthTokenFilter($driver, $events);
    });

    $this->app['tappleby.auth.token.controller'] = $this->app->share(function($app) {
      $driver = $app['tappleby.auth.token']->driver();

      return new AuthTokenController($driver);
    });

    $this->app['router']->filter('auth.token', 'tappleby.auth.token.filter');
	}

	/**
	 * Get the services provided by the provider.
	 *
	 * @return array
	 */
	public function provides()
	{
		return array('tappleby.auth.token', 'tappleby.auth.token.filter', 'tappleby.auth.token.controller');
	}

}

Fix l4 change addFilter to filter

Fix l4 change addFilter to filter


<?php

namespace Powermash\ComicVine;

use Buzz\Browser;
use Buzz\Exception\RequestException;

/**
*
*/
class Client
{
	protected $apiKey;
	protected $browser;

	public function __construct($key)
	{
		$this->apiKey = $key;

		$this->browser = new Browser();
	}

	public function randomCharacter()
	{
		$url = 'http://www.comicvine.com/api/characters?'.http_build_query([
				'offset' 		=> mt_rand(0, 87150),
				'limit' 		=> 1,
				'format' 		=> 'json',
				'field_list'	=> 'name,image,publisher,description',
				'api_key' 		=> $this->apiKey,
			]);

		$response = $this->browser->get($url);
		$characters = json_decode($response->getContent(), true);

		$character = reset($characters['results']);

		return [
			'name' => $character['name'],
			'description' => $character['description'],
			'thumbnail' => $character['image']['super_url']
		];
	}
}

<?php

namespace Powermash\ComicVine;

use Buzz\Browser;
use Buzz\Exception\RequestException;

/**
*
*/
class Client
{
	const DEFAULT_ENDPOINT = 'http://www.comicvine.com/api/characters';

	protected $apiKey;
	protected $endpoint;
	protected $browser;

	public function __construct($key, $endpoint = null)
	{
		$this->apiKey = $key;
		$this->endpoint = $endpoint ?: self::DEFAULT_ENDPOINT;
		$this->browser = new Browser();
	}

	public function randomCharacter()
	{
		$payload = $this->sendRequest('characters', ['offset' => mt_rand(0, 87150), 'limit' => 1]);
		$character = reset($payload['results']);

		return [
			'name' => $character['name'],
			'description' => $character['description'],
			'thumbnail' => $character['image']['super_url']
		];
	}

	public function sendRequest($ressource, array $parameters = array())
	{
		$url = sprintf('%s?%s', $this->endpoint, http_build_query([
			'format' => 'json',
			'api_key' => $this->apiKey
		]));

		$response = $this->browser->get($url);
		$payload = json_decode($response->getContent(), true);

		if ($error = json_last_error()) {
			throw new JSONException($error);
		}

		return $payload;
	}
}

/**
*
*/
class JSONException extends \RuntimeException
{

}

Add dedicated method to send request

Add dedicated method to send request


<?php

namespace Spark\Core\Command;

use Silex\Application;

use Spark\Core\ApplicationAware;

use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

use Kue\Worker;
use Kue\Queue;

class QueueWorker extends \Kue\Command\Worker
{
    protected $silexApplication;

    function setSilexApplication(Application $app)
    {
        $this->silexApplication = $app;
    }

    protected function configure()
    {
        parent::configure();

        $this->setName('queue:worker');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->silexApplication->boot();

        return parent::execute($input, $output);
    }

    protected function setupWorker(Worker $worker)
    {
        parent::setupWorker($worker);

        $app = $this->silexApplication;

        $worker->on('init', function($job) use ($app) {
            if ($job instanceof ApplicationAware) {
                $job->setApplication($app);
            }
        });
    }
}

<?php

namespace Spark\Core\Command;

use Silex\Application;

use Spark\Core\ApplicationAware;

use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

use Kue\Worker;
use Kue\Queue;

class QueueWorker extends \Kue\Command\WorkCommand
{
    protected $silexApplication;

    function setSilexApplication(Application $app)
    {
        $this->silexApplication = $app;
    }

    protected function configure()
    {
        parent::configure();

        $this->setName('queue:work');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->silexApplication->boot();

        return parent::execute($input, $output);
    }

    protected function setupWorker(Worker $worker)
    {
        parent::setupWorker($worker);

        $app = $this->silexApplication;

        $worker->on('init', function($job) use ($app) {
            if ($job instanceof ApplicationAware) {
                $job->setApplication($app);
            }
        });
    }
}

Rename command queue:worker -> queue:work


<?php

$root = realpath(__DIR__.'/../');
require_once $root.'/src/autoloader.php'; // Grafika
require_once $root.'/doc-src/classes/DocBlock.php';
require_once $root.'/doc-src/classes/Documentation.php';
$needle = 'doc-src/';
$haystack = $_SERVER['SCRIPT_NAME'];
$pos = strpos($haystack, $needle);
$doc_src = '';
if(false !== $pos ){
    $doc_src = substr($haystack, 0, $pos+strlen($needle));
}

function classDoc($classPath){
    $class = new ReflectionClass($classPath);
    $str = preg_replace(array('(\/\*\*[\s]+[*][\s])','([\s]\*\/)'), '', $class->getDocComment());
    $str = preg_split('/(\n)|(\r)/', $str);
    return $str[0];
}

<?php

$root = realpath(__DIR__.'/../');
require_once $root.'/src/autoloader.php'; // Grafika
require_once $root.'/doc-src/classes/DocBlock.php';
require_once $root.'/doc-src/classes/Documentation.php';
require_once $root.'/doc-src/classes/PhpDocParser.php';
$needle = 'doc-src/';
$haystack = $_SERVER['SCRIPT_NAME'];
$pos = strpos($haystack, $needle);
$doc_src = '';
if(false !== $pos ){
    $doc_src = substr($haystack, 0, $pos+strlen($needle));
}

function classDoc($classPath){
    $class = new ReflectionClass($classPath);
    $str = preg_replace(array('(\/\*\*[\s]+[*][\s])','([\s]\*\/)'), '', $class->getDocComment());
    $str = preg_split('/(\n)|(\r)/', $str);
    return $str[0];
}

Include new class in docs

Include new class in docs


<?php

namespace GenyBundle\Repository;

use Doctrine\ORM\Query;

/**
 * DataRepository
 */
class DataRepository extends \Doctrine\ORM\EntityRepository {

    public function dataSet($set_id) {

        $results = $this->_em->createQuery('SELECT IDENTITY(d.field_id), IDENTITY(d.data_text_id) as data_text_id, f.name, f.label, dt.text FROM GenyBundle:Data d LEFT JOIN d.field_id f LEFT JOIN d.data_text_id dt WHERE d.set_id = :set_id')
                ->setParameter('set_id', $set_id)
                ->getResult();

        return $results;
    }

    public function dataSetList($form_id){

                $results = $this->_em->createQuery('SELECT d FROM GenyBundle:Data d LEFT JOIN d.field_id f LEFT JOIN f.form form WHERE form.id = :id ORDER BY d.id ASC')
                ->setParameter('id', $form_id)
                ->getResult();

        return $results;

    }

}

<?php

namespace GenyBundle\Repository;

use Doctrine\ORM\Query;

/**
 * DataRepository
 */
class DataRepository extends \Doctrine\ORM\EntityRepository {

    public function dataSet($set_id) {

        $results = $this->_em->createQuery('SELECT IDENTITY(d.field_id), IDENTITY(d.data_text_id) as data_text_id, f.name, f.label, dt.text FROM GenyBundle:Data d LEFT JOIN d.field_id f LEFT JOIN d.data_text_id dt WHERE d.set_id = :set_id')
                ->setParameter('set_id', $set_id)
                ->getResult();

        return $results;
    }

    public function dataSetList($form_id){

                $results = $this->_em->createQuery('SELECT d FROM GenyBundle:Data d LEFT JOIN d.field_id f LEFT JOIN f.form form WHERE form.id = :id GROUP BY d.set_id')
                ->setParameter('id', $form_id)
                ->getResult();

        return $results;

    }

}

Revert "DataRepo -> dataSetList -> order by d.id asc"

This reverts commit 2df17fba0f81de280de74d5854f01f52ade73cf3.


            Name
            Contact Methods
            Last Visited

        @forelse($users as $user)

            id]) }}">{{ $user->display_name }}

                {{ $user->email_preview }}
                @if ($user->email_preview && $user->mobile_preview)
                     and
                @endif
                {{ $user->mobile_preview }}

                {{ $user->last_accessed_at ? $user->last_accessed_at->diffForHumans() : 'more than 2 years ago' }}

        @empty
        @endforelse

            Name
            Contact Methods
            Last Visited

        @forelse($users as $user)

            id]) }}">{{ $user->display_name }}

                {{ $user->email_preview }}
                @if ($user->email_preview && $user->mobile_preview)
                     and
                @endif
                {{ $user->mobile_preview }}

                {{ $user->last_accessed_at ? $user->last_accessed_at->diffForHumans() : 'N/A' }}

        @empty
        @endforelse

Update 'last_accessed_at' fallback to be clearer.


Add footer text, link back to repo

Add footer text, link back to repo


<?php
/*
 * This file is part of Flarum.
 *
 * (c) Toby Zerner <toby.zerner@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Flarum\Core\Notifications\Commands;

use Flarum\Core\Notifications\Notification;
use Flarum\Core\Exceptions\PermissionDeniedException;
use Flarum\Core\Support\DispatchesEvents;

class ReadNotificationHandler
{
    /**
     * @param ReadNotification $command
     * @return Notification
     * @throws \Flarum\Core\Exceptions\PermissionDeniedException
     */
    public function handle(ReadNotification $command)
    {
        $actor = $command->actor;

        if ($actor->isGuest()) {
            throw new PermissionDeniedException;
        }

        $notification = Notification::where('user_id', $actor->id)->findOrFail($command->notificationId);

        Notification::where([
            'user_id' => $actor->id,
            'type' => $notification->type,
            'subject_id' => $notification->subject_id
        ])
            ->update(['is_read' => true]);

        return $notification;
    }
}

<?php
/*
 * This file is part of Flarum.
 *
 * (c) Toby Zerner <toby.zerner@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Flarum\Core\Notifications\Commands;

use Flarum\Core\Notifications\Notification;
use Flarum\Core\Exceptions\PermissionDeniedException;
use Flarum\Core\Support\DispatchesEvents;

class ReadNotificationHandler
{
    /**
     * @param ReadNotification $command
     * @return Notification
     * @throws \Flarum\Core\Exceptions\PermissionDeniedException
     */
    public function handle(ReadNotification $command)
    {
        $actor = $command->actor;

        if ($actor->isGuest()) {
            throw new PermissionDeniedException;
        }

        $notification = Notification::where('user_id', $actor->id)->findOrFail($command->notificationId);

        Notification::where([
            'user_id' => $actor->id,
            'type' => $notification->type,
            'subject_id' => $notification->subject_id
        ])
            ->update(['is_read' => true]);

        $notification->is_read = true;

        return $notification;
    }
}

Update local copy of notification when marking as read


<?php

namespace Jmikola\WildcardEventDispatcher;

class LazyListenerPattern extends ListenerPattern
{
    protected $listenerProvider;

    /**
     * Constructor.
     *
     * The $listenerProvider argument should be a callback which, when invoked,
     * returns the listener callback.
     *
     * @param string   $eventPattern
     * @param callback $listenerProvider
     * @param integer  $priority
     * @throws InvalidArgumentException if the listener provider is not a callback
     */
    public function __construct($eventPattern, $listenerProvider, $priority = 0)
    {
        if (!is_callable($listenerProvider)) {
            throw new \InvalidArgumentException('Listener provider argument must be a callback');
        }

        parent::__construct($eventPattern, null, $priority);

        $this->listenerProvider = $listenerProvider;
    }

    /**
     * Get the pattern listener, initializing it lazily from its provider.
     *
     * @return callback
     */
    public function getListener()
    {
        if (!isset($this->listener) && isset($this->listenerProvider)) {
            $this->listener = call_user_func($this->listenerProvider);
            unset($this->listenerProvider);
        }

        return $this->listener;
    }
}

<?php

namespace Jmikola\WildcardEventDispatcher;

class LazyListenerPattern extends ListenerPattern
{
    protected $listenerProvider;

    /**
     * Constructor.
     *
     * The $listenerProvider argument should be a callback which, when invoked,
     * returns the listener callback.
     *
     * @param string   $eventPattern
     * @param callback $listenerProvider
     * @param integer  $priority
     * @throws \InvalidArgumentException if the listener provider is not a callback
     */
    public function __construct($eventPattern, $listenerProvider, $priority = 0)
    {
        if (!is_callable($listenerProvider)) {
            throw new \InvalidArgumentException('Listener provider argument must be a callback');
        }

        parent::__construct($eventPattern, null, $priority);

        $this->listenerProvider = $listenerProvider;
    }

    /**
     * Get the pattern listener, initializing it lazily from its provider.
     *
     * @return callback
     */
    public function getListener()
    {
        if (!isset($this->listener) && isset($this->listenerProvider)) {
            $this->listener = call_user_func($this->listenerProvider);
            unset($this->listenerProvider);
        }

        return $this->listener;
    }
}

Use FQCN for InvalidArgumentException in doc block


<?php

require_once 'Doctrine/Common/ClassLoader.php';

$classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
$classLoader->register();

$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php';
$configuration = new \Doctrine\Common\Cli\Configuration();

if (file_exists($configFile)) {
    if ( ! is_readable($configFile)) {
        trigger_error(
            'Configuration file [' . $configFile . '] does not have read permission.', E_ERROR
        );
    }

    require $configFile;

    foreach ($GLOBALS as $configCandidate) {
        if ($configCandidate instanceof \Doctrine\Common\Cli\Configuration) {
            $configuration = $configCandidate;
            break;
        }
    }
}

$cli = new \Doctrine\Common\Cli\CliController($configuration);
$cli->run($_SERVER['argv']);

<?php

require_once 'Doctrine/Common/ClassLoader.php';

$classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
$classLoader->register();

$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php';

$configuration = null;
if (file_exists($configFile)) {
    if ( ! is_readable($configFile)) {
        trigger_error(
            'Configuration file [' . $configFile . '] does not have read permission.', E_ERROR
        );
    }

    require $configFile;

    foreach ($GLOBALS as $configCandidate) {
        if ($configCandidate instanceof \Doctrine\Common\Cli\Configuration) {
            $configuration = $configCandidate;
            break;
        }
    }
}

$configuration = ($configuration) ?: new \Doctrine\Common\Cli\Configuration();

$cli = new \Doctrine\Common\Cli\CliController($configuration);
$cli->run($_SERVER['argv']);

[2.0] Fix bug in detection of global Doctrine Cli Configuration finding the empty replacement configuration before the correct one.

git-svn-id: c8c49e1140e1cd2a8fb163f3c2b0f6eec231a71d@7322 625475ce-881a-0410-a577-b389adb331d8


<?php namespace Picqer\Financials\Exact\Persistance;

trait Storable
{
    public function save()
    {
        if ($this->exists())
            $this->fill($this->update());

        $this->fill($this->insert());

        return $this;
    }

    public function insert()
    {
        return $this->connection()->post($this->url, $this->json());
    }

    public function update()
    {
        return $this->connection()->put($this->url . "(guid'$this->primaryKey')", $this->json());
    }

    public function delete()
    {
        return $this->connection()->delete($this->url . "(guid'$this->primaryKey')");
    }
}

<?php namespace Picqer\Financials\Exact\Persistance;

trait Storable
{
    public function save()
    {
        if ($this->exists()) {
            $result = $this->update();
        } else {
            $result = $this->insert();
        }
        return $this->find($result[$this->primaryKey]);
    }

    public function insert()
    {
        return $this->connection()->post($this->url, $this->json());
    }

    public function update()
    {
        return $this->connection()->put($this->url . "(guid'$this->primaryKey')", $this->json());
    }

    public function delete()
    {
        return $this->connection()->delete($this->url . "(guid'$this->primaryKey')");
    }
}

Return filled model after saving

Return filled model after saving


<?php

namespace OpenDominion\Providers;

use Illuminate\Contracts\View\View;
use Illuminate\Support\ServiceProvider;
use OpenDominion\Calculators\NetworthCalculator;
use OpenDominion\Services\DominionSelectorService;

class ComposerServiceProvider extends ServiceProvider
{
    /**
     * Register bindings in the container.
     *
     * @return void
     */
    public function boot()
    {
        view()->composer('partials.main-footer', function (View $view) {
            $branch = shell_exec('git branch | grep \' * \'');
            $branch = str_replace('* ', '', trim($branch));

            $shortHash = shell_exec('git log --pretty="%h" -n1 HEAD');
            $longHash = shell_exec('git log --pretty="%H" -n1 HEAD');

            $url = "https://github.com/WaveHack/OpenDominion/commit/{$longHash}";

            $view->with('version', "revision #{$shortHash} on branch {$branch}");
        });

        view()->composer('partials.resources-overview', function (View $view) {
            $dominionSelectorService = app()->make(DominionSelectorService::class);
            $dominion = $dominionSelectorService->getUserSelectedDominion();

            $networthCalculator = app()->make(NetworthCalculator::class, [$dominion]);

            $view->with('networthCalculator', $networthCalculator);
        });
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

<?php

namespace OpenDominion\Providers;

use Illuminate\Contracts\View\View;
use Illuminate\Support\ServiceProvider;
use OpenDominion\Calculators\NetworthCalculator;
use OpenDominion\Services\DominionSelectorService;

class ComposerServiceProvider extends ServiceProvider
{
    /**
     * Register bindings in the container.
     *
     * @return void
     */
    public function boot()
    {
        view()->composer('partials.main-footer', function (View $view) {
            $env = getenv('APP_ENV');

            $shortHash = shell_exec('git log --pretty="%h" -n1 HEAD');
            $longHash = shell_exec('git log --pretty="%H" -n1 HEAD');

            $branch = shell_exec('git branch | grep \' * \'');
            $branch = str_replace('* ', '', trim($branch));

            $url = "https://github.com/WaveHack/OpenDominion/commit/{$longHash}";

            $view->with('version', "{$env} @ #{$shortHash} ({$branch})");
        });

        view()->composer('partials.resources-overview', function (View $view) {
            $dominionSelectorService = app()->make(DominionSelectorService::class);
            $dominion = $dominionSelectorService->getUserSelectedDominion();

            $networthCalculator = app()->make(NetworthCalculator::class, [$dominion]);

            $view->with('networthCalculator', $networthCalculator);
        });
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

Update footer version with env

Update footer version with env


    {!! Form::label($elementName, $options['label']) !!}
    {!! Form::select($elementName, [null => 'Select '.$options['label']] + $record->{$options['selectOptions']}(), $record->{$fieldName}, ['class' => 'form-control']) !!}

        {{ join($errors->get($fieldName), '
') }}

has($fieldName) ? 'has-error' : '' }}">
    {!! Form::label($fieldName, $options['label']) !!}
    {!! Form::select($fieldName, [null => 'Select '.$options['label']] + $record->{$options['selectOptions']}(), $record->{$fieldName}, ['class' => 'form-control '.array_get($options, 'additionalClass')]) !!}

        {{ join($errors->get($fieldName), '
') }}

Update select field to allow additional classes.


<?php

namespace Backend\Modules\Blog\Tests\Action;

use Backend\Modules\Tags\DataFixtures\LoadTagsModulesTags;
use Backend\Modules\Tags\DataFixtures\LoadTagsTags;
use Common\WebTestCase;

class MassActionTest extends WebTestCase
{
    public function setUp(): void
    {
        parent::setUp();

        if (!defined('APPLICATION')) {
            define('APPLICATION', 'Backend');
        }

        $client = self::createClient();
        $this->loadFixtures(
            $client,
            [
                LoadTagsTags::class,
                LoadTagsModulesTags::class,
            ]
        );
    }

    public function testAuthenticationIsNeeded(): void
    {
        $client = static::createClient();
        $this->logout($client);

        $client->setMaxRedirects(1);
        $client->request('GET', '/private/en/tags/mass_action');

        // we should get redirected to authentication with a reference to the wanted page
        $this->assertStringEndsWith(
            '/private/en/authentication?querystring=%2Fprivate%2Fen%2Ftags%2Fmass_action',
            $client->getHistory()->current()->getUri()
        );
    }
}

<?php

namespace Backend\Modules\Blog\Tests\Action;

use Backend\Modules\Tags\DataFixtures\LoadTagsModulesTags;
use Backend\Modules\Tags\DataFixtures\LoadTagsTags;
use Common\WebTestCase;

class MassActionTest extends WebTestCase
{
    public function setUp(): void
    {
        parent::setUp();

        if (!defined('APPLICATION')) {
            define('APPLICATION', 'Backend');
        }

        $client = self::createClient();
        $this->loadFixtures(
            $client,
            [
                LoadTagsTags::class,
                LoadTagsModulesTags::class,
            ]
        );
    }

    public function testAuthenticationIsNeeded(): void
    {
        $client = static::createClient();
        $this->logout($client);

        $client->setMaxRedirects(1);
        $client->request('GET', '/private/en/tags/mass_action');

        // we should get redirected to authentication with a reference to the wanted page
        $this->assertStringEndsWith(
            '/private/en/authentication?querystring=%2Fprivate%2Fen%2Ftags%2Fmass_action',
            $client->getHistory()->current()->getUri()
        );
    }

    public function testActionIsRequired(): void
    {
        $client = static::createClient();
        $this->login($client);

        $client->setMaxRedirects(1);
        $client->request('GET', '/private/en/tags/mass_action');

        $this->assertStringEndsWith(
            '&error=no-action-selected',
            $client->getHistory()->current()->getUri()
        );
    }
}

Test that the action is required

Test that the action is required


<?php

// Can be used by plugins/themes to check if WP-CLI is running or not
define( 'WP_CLI', true );
define( 'WP_CLI_VERSION', trim( file_get_contents( WP_CLI_ROOT . '/VERSION' ) ) );
define( 'WP_CLI_START_MICROTIME', microtime( true ) );

if ( file_exists( WP_CLI_ROOT . '/vendor/autoload.php' ) ) {
	define( 'WP_CLI_VENDOR_DIR' , WP_CLI_ROOT . '/vendor' );
} elseif ( file_exists( dirname( dirname( WP_CLI_ROOT ) ) . '/autoload.php' ) ) {
	define( 'WP_CLI_VENDOR_DIR' , dirname( dirname( WP_CLI_ROOT ) ) );
}

// Set common headers, to prevent warnings from plugins
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.0';
$_SERVER['HTTP_USER_AGENT'] = '';
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';

require_once WP_CLI_ROOT . '/php/bootstrap.php';
\WP_CLI\bootstrap();

<?php

// Can be used by plugins/themes to check if WP-CLI is running or not
define( 'WP_CLI', true );
define( 'WP_CLI_VERSION', trim( file_get_contents( WP_CLI_ROOT . '/VERSION' ) ) );
define( 'WP_CLI_START_MICROTIME', microtime( true ) );

if ( file_exists( WP_CLI_ROOT . '/vendor/autoload.php' ) ) {
	define( 'WP_CLI_VENDOR_DIR', WP_CLI_ROOT . '/vendor' );
} elseif ( file_exists( dirname( dirname( WP_CLI_ROOT ) ) . '/autoload.php' ) ) {
	define( 'WP_CLI_VENDOR_DIR', dirname( dirname( WP_CLI_ROOT ) ) );
} else {
	define( 'WP_CLI_VENDOR_DIR', WP_CLI_ROOT . '/vendor' );
}

// Set common headers, to prevent warnings from plugins
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.0';
$_SERVER['HTTP_USER_AGENT'] = '';
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';

require_once WP_CLI_ROOT . '/php/bootstrap.php';
\WP_CLI\bootstrap();

Make sure `WP_CLI_VENDOR_DIR` is always defined.

As a last resort, the folder is guessed.


<?php namespace Limoncello\Application\Contracts;

/**
 * Copyright 2015-2017 info@neomerx.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

use Closure;
use Limoncello\Contracts\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

/**
 * @package Limoncello\Application
 */
interface MiddlewareInterface
{
    /**
     * Configurator's method name.
     */
    const METHOD_NAME = 'handle';

    /**
     * @param ServerRequestInterface $request
     * @param Closure                $next
     * @param ContainerInterface     $container
     *
     * @return ResponseInterface
     */
    public static function handle(
        ServerRequestInterface $request,
        Closure $next,
        ContainerInterface $container
    ): ResponseInterface;
}

<?php namespace Limoncello\Application\Contracts;

/**
 * Copyright 2015-2017 info@neomerx.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

use Closure;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

/**
 * @package Limoncello\Application
 */
interface MiddlewareInterface
{
    /**
     * Configurator's method name.
     */
    const METHOD_NAME = 'handle';

    /**
     * @param ServerRequestInterface $request
     * @param Closure                $next
     * @param ContainerInterface     $container
     *
     * @return ResponseInterface
     */
    public static function handle(
        ServerRequestInterface $request,
        Closure $next,
        ContainerInterface $container
    ): ResponseInterface;
}

Replace dependency to PSR container.

Replace dependency to PSR container.


<?php namespace Modules\Blog\Tests;

class EloquentTagRepositoryTest extends BaseBlogTestCase
{

}

<?php namespace Modules\Blog\Tests;

class EloquentTagRepositoryTest extends BaseBlogTestCase
{
    /** @test */
    public function it_finds_a_tag_by_name()
    {
        // Prepare
        $this->createTag();
        $this->createTag();
        $tag = $this->createTag();

        // Run
        $foundTag = $this->tag->findByName($tag->name);

        // Assert
        $this->assertEquals($tag->name, $foundTag[0]['name']);
    }
}

Test the find by tag name method

Test the find by tag name method


<?php

require_once(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'utils.php');
require_once(ROOT.DS.'config'.DS.'config.php');
require_once(ROOT.DS.'lib'.DS.'I18n.php');

<?php

require_once(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'utils.php');
require_once(ROOT.DS.'config'.DS.'config.sample.php');
require_once(ROOT.DS.'lib'.DS.'I18n.php');

Fix unit test config path

Fix unit test config path


<?php namespace StudioIgnis\Evt\Laravel;

use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;

class ServiceProvider extends IlluminateServiceProvider
{
    public function boot()
    {
        $this->package('studioignis/evt', 'evt');
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bindShared('StudioIgnis\Evt\Support\Container', function ($app)
        {
            return new Container($app);
        });

        $this->app->bindShared('StudioIgnis\Evt\Dispatcher', function ($app)
        {
            return $app->make($app['config']['evt::dispatcher'], [
                $app['StudioIgnis\Evt\Support\Container']
            ]);
        });
    }
}

<?php namespace StudioIgnis\Evt\Laravel;

use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;

class ServiceProvider extends IlluminateServiceProvider
{
    public function boot()
    {
        $this->package('studioignis/evt', 'evt', realpath(__DIR__.'/../../'));
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bindShared('StudioIgnis\Evt\Support\Container', function ($app)
        {
            return new Container($app);
        });

        $this->app->bindShared('StudioIgnis\Evt\Dispatcher', function ($app)
        {
            return $app->make($app['config']['evt::dispatcher'], [
                $app['StudioIgnis\Evt\Support\Container']
            ]);
        });
    }
}

Add package path to correctly resolve the config


<?php

namespace Michaeljennings\Snapshot;

class Laravel4ServiceProvider extends SnapshotServiceProvider
{
    /**
     * {@inheritdoc}
     */
    public function boot()
    {
        $this->package('michaeljennings/snapshot', 'snapshot', __DIR__ . '/../');
    }

    /**
     * Get the package config.
     *
     * @return array
     */
    protected function getConfig()
    {
        \Config::addNamespace('snapshot', realpath(__DIR__ . '/../config'));

        return $this->app['config']['snapshot::snapshot'];
    }
}

<?php

namespace Michaeljennings\Snapshot;

use League\Event\Emitter;
use ReflectionClass;

class Laravel4ServiceProvider extends SnapshotServiceProvider
{
    /**
     * {@inheritdoc}
     */
    public function boot()
    {
        $this->package('michaeljennings/snapshot', 'snapshot', __DIR__ . '/../');
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->registerStore();
        $this->registerRenderer();
        $this->registerDispatcher();

        $this->app->singleton('Michaeljennings\Snapshot\Contracts\Snapshot', function ($app) {
            return new Snapshot(
                $app['Michaeljennings\Snapshot\Contracts\Store'],
                $app['Michaeljennings\Snapshot\Contracts\Renderer'],
                $app['Michaeljennings\Snapshot\Contracts\Dispatcher'],
                $app['config']['snapshot::snapshot']
            );
        });

        $this->app->alias('Michaeljennings\Snapshot\Contracts\Snapshot', 'snapshot');
    }

    /**
     * Register the snapshot store.
     */
    protected function registerStore()
    {
        $this->app->bind('Michaeljennings\Snapshot\Contracts\Store', function ($app) {
            return (new ReflectionClass($app['config']['snapshot::snapshot']['store']['class']))
                ->newInstanceArgs([$app['config']['snapshot::snapshot']]);
        });
    }

    /**
     * Register the snapshot renderer.
     */
    protected function registerRenderer()
    {
        $this->app->bind('Michaeljennings\Snapshot\Contracts\Renderer', function ($app) {
            return (new ReflectionClass($app['config']['snapshot::snapshot']['renderer']))
                ->newInstanceArgs([$app['view']]);
        });
    }

    /**
     * Register the snapshot event dispatcher.
     */
    protected function registerDispatcher()
    {
        $this->app->singleton('Michaeljennings\Snapshot\Contracts\Dispatcher', function() {
            return new Dispatcher(new Emitter());
        });
    }
}

Fix laravel 4 service provider config issues


<?php
header('Content-type: text/plain');
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
$formID = isset($_POST['form_id']) ? $_POST['form_id'] : '';
$response = Jojo_Plugin_Jojo_contact::sendEnquiry($formID);
$res = json_encode($response);
echo $res;
exit;

<?php
header('Content-type: application/json');
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
$formID = isset($_POST['form_id']) ? $_POST['form_id'] : '';
$response = Jojo_Plugin_Jojo_contact::sendEnquiry($formID);
$res = json_encode($response);
echo $res;
exit;

Change header content type to json specific one


<?php

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

class CreateTagTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('tag', function (Blueprint $table) {
            $table->increments('id');

            // Name in URL, lowercase, e.g. "chair", "solid-wood"
            $table->string('slug')->unique();

            // Timestamps
            $table->timestamps();
        });

        Schema::create('tag_translation', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('tag_id')->unsigned();
            $table->string('locale');

            // Translated content
            $table->string('name');
            $table->string('alias')->nullable(); // For better search matches

            $table->timestamps();

            // Unique
            $table->unique(['tag_id','locale']);
            // Foreign key
            $table->foreign('tag_id')->references('id')->on('tag')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('tag_translation');

        Schema::drop('tag');
    }
}

<?php

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

class CreateTagTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('tag', function (Blueprint $table) {
            $table->increments('id');

            // Name in URL, lowercase, e.g. "chair", "solid-wood"
            $table->string('slug')->unique();

            // Icon/cover image
            $table->integer('image_id')->unsigned();

            // Timestamps
            $table->timestamps();

            // Foreign key
            $table->foreign('image_id')->references('id')->on('image')->onDelete('set null');
        });

        Schema::create('tag_translation', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('tag_id')->unsigned();
            $table->string('locale');

            // Translated content
            $table->string('name');
            $table->string('alias')->nullable(); // For better search matches

            $table->timestamps();

            // Unique
            $table->unique(['tag_id','locale']);
            // Foreign key
            $table->foreign('tag_id')->references('id')->on('tag')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('tag_translation');

        Schema::drop('tag');
    }
}

Add image relation to tag table.

Add image relation to tag table.


<?php

class FaqSegment extends DataObject
{

    private static $db = [
        'Title'     => 'Varchar(255)',
        'Answer'   => 'HTMLText',
        'SortOrder' => 'Int'
    ];

    private static $has_one = [
        'Page' => 'Page'
    ];

    private static $default_sort = 'SortOrder';

    private static $field_labels = [
        'Title'   => 'Question',
        'Answer' => 'Answer'
    ];

    public function getCMSFields()
    {
        $this->beforeUpdateCMSFields(function (FieldList $fields) {

            $fields->addFieldsToTab('Root.Main', [
                TextField::create('Title', 'Question'),
                HtmlEditorField::create('Answer', 'Answer')->setRows(20)
            ]);

            $fields->removeByName('SortOrder');
            $fields->removeByName('PageID');
        });

        $fields = parent::getCMSFields();

        return $fields;
    }

    public function canView($member = null)
    {
        return true;
    }

    public function canEdit($member = null)
    {
        return true;
    }

    public function canDelete($member = null)
    {
        return true;
    }

    public function canCreate($member = null)
    {
        return true;
    }
}

<?php

class FaqSegment extends DataObject
{

    private static $db = [
        'Title'     => 'Varchar(255)',
        'Answer'   => 'HTMLText',
        'SortOrder' => 'Int'
    ];

    private static $has_one = [
        'OwnerObject' => 'DataObject'
    ];

    private static $default_sort = 'SortOrder';

    private static $field_labels = [
        'Title'   => 'Question',
        'Answer' => 'Answer'
    ];

    public function getCMSFields()
    {
        $this->beforeUpdateCMSFields(function (FieldList $fields) {

            $fields->addFieldsToTab('Root.Main', [
                TextField::create('Title', 'Question'),
                HtmlEditorField::create('Answer', 'Answer')->setRows(20)
            ]);

            $fields->removeByName('SortOrder');
            $fields->removeByName('PageID');
        });

        $fields = parent::getCMSFields();

        return $fields;
    }

    public function canView($member = null)
    {
        return true;
    }

    public function canEdit($member = null)
    {
        return true;
    }

    public function canDelete($member = null)
    {
        return true;
    }

    public function canCreate($member = null)
    {
        return true;
    }
}

Make generic (can now be applied to pages and dataobjects)


<?php
/*
	Florrie core - autoload and bootstrap
	Copyright © 2021 Jacob Hume

	This file is part of Florrie.

	Florrie is free software: you can redistribute it and/or modify it
	under the terms of the GNU Affero General Public License as published
	by the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	Florrie is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Affero General Public License for more details.

	You should have received a copy of the GNU Affero General Public License
	along with Florrie.  If not, see <http://www.gnu.org/licenses/>.
*/

// Register our autoloader for core classes
spl_autoload_register('FlorrieAutoloader');

/**
 * Core autoloader
 *
 * @property string $class - Class name to be autoloaded
 */
function FlorrieAutoloader(string $class): void
{
	// Get the first namespace of this class
	if(($firstSlash = strpos($class, '/')) === false)
		return;
	}

	$namespace = substr($class, 0, $firstSlash);

	if($namespace === 'Florrie') {
		require __DIR__ . substr($class, $firstSlash + 1) . '.php';
	}
}

<?php
/*
	Florrie core - autoload and bootstrap
	Copyright © 2021 Jacob Hume

	This file is part of Florrie.

	Florrie is free software: you can redistribute it and/or modify it
	under the terms of the GNU Affero General Public License as published
	by the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	Florrie is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Affero General Public License for more details.

	You should have received a copy of the GNU Affero General Public License
	along with Florrie.  If not, see <http://www.gnu.org/licenses/>.
*/

// Register our autoloader for core classes
spl_autoload_register('FlorrieAutoloader');

/**
 * Core autoloader
 *
 * @property string $class - Class name to be autoloaded
 */
function FlorrieAutoloader(string $class): void
{
	// Get the first namespace of this class
	if(($firstSlash = strpos($class, '/')) === false)
		return;
	}

	$namespace = substr($class, 0, $firstSlash);

	if($namespace === 'Florrie') {
		require __DIR__ . '/lib/' . substr($class, $firstSlash + 1) . '.php';
	}
}

Add lib folder to autoloader path

Add lib folder to autoloader path


  <?php if (ENVIRONMENT == 'demo') : ?>

    View on GitHub

  <?php endif; ?>
  <?php $this->load->view('components/confirm_box') ?>
  <?php $this->load->view('base/footer_scripts') ?>

Fix error reported in comment

Fix error reported in comment


<?php

declare(strict_types=1);

namespace spec\SitemapPlugin\Renderer;

use PhpSpec\ObjectBehavior;
use SitemapPlugin\Model\SitemapInterface;
use SitemapPlugin\Model\SitemapUrlInterface;
use SitemapPlugin\Renderer\RendererAdapterInterface;
use SitemapPlugin\Renderer\TwigAdapter;
use Symfony\Component\Templating\EngineInterface;

final class TwigAdapterSpec extends ObjectBehavior
{
    function let(EngineInterface $twig): void
    {
        $this->beConstructedWith($twig, '@SyliusCore/Sitemap/url_set.xml.twig', false);
    }

    function it_is_initializable(): void
    {
        $this->shouldHaveType(TwigAdapter::class);
    }

    function it_implements_renderer_adapter_interface(): void
    {
        $this->shouldImplement(RendererAdapterInterface::class);
    }

    function it_renders_sitemap($twig, SitemapInterface $sitemap, SitemapUrlInterface $productUrl): void
    {
        $sitemap->getUrls()->willReturn([$productUrl]);

        $twig->render('@SyliusCore/Sitemap/url_set.xml.twig', [
            'url_set' => [$productUrl],
            'absolute_url' => false,
            'hreflang' => true,
        ])->shouldBeCalled()->willReturn('');

        $this->render($sitemap);
    }
}

<?php

declare(strict_types=1);

namespace spec\SitemapPlugin\Renderer;

use PhpSpec\ObjectBehavior;
use SitemapPlugin\Model\SitemapInterface;
use SitemapPlugin\Model\SitemapUrlInterface;
use SitemapPlugin\Renderer\RendererAdapterInterface;
use SitemapPlugin\Renderer\TwigAdapter;
use Symfony\Component\Templating\EngineInterface;

final class TwigAdapterSpec extends ObjectBehavior
{
    function let(EngineInterface $twig): void
    {
        $this->beConstructedWith($twig, '@SyliusCore/Sitemap/url_set.xml.twig', false);
    }

    function it_is_initializable(): void
    {
        $this->shouldHaveType(TwigAdapter::class);
    }

    function it_implements_renderer_adapter_interface(): void
    {
        $this->shouldImplement(RendererAdapterInterface::class);
    }

    function it_renders_sitemap($twig, SitemapInterface $sitemap, SitemapUrlInterface $productUrl): void
    {
        $sitemap->getUrls()->willReturn([$productUrl]);

        $twig->render('@SyliusCore/Sitemap/url_set.xml.twig', [
            'url_set' => [$productUrl],
            'absolute_url' => false,
            'hreflang' => true,
            'images' => true,
        ])->shouldBeCalled()->willReturn('');

        $this->render($sitemap);
    }
}

Fix missing images boolean setting in spec


<?php
/**
 * @file
 */

namespace CultuurNet\UDB3\Event\ReadModel;

use Doctrine\Common\Cache\Cache;

class DoctrineCacheRepository implements DocumentRepositoryInterface
{
    protected $cache;

    public function __construct(Cache $cache)
    {
        $this->cache = $cache;
    }

    public function get($id)
    {
        $value = $this->cache->fetch($id);
        return new JsonDocument($id, $value);
    }

    public function save(JsonDocument $document)
    {
        $this->cache->save($document->getId(), $document->getRawBody(), 0);
    }
}

<?php
/**
 * @file
 */

namespace CultuurNet\UDB3\Event\ReadModel;

use Doctrine\Common\Cache\Cache;

class DoctrineCacheRepository implements DocumentRepositoryInterface
{
    protected $cache;

    public function __construct(Cache $cache)
    {
        $this->cache = $cache;
    }

    public function get($id)
    {
        $value = $this->cache->fetch($id);

        if (false === $value) {
            return NULL;
        }

        return new JsonDocument($id, $value);
    }

    public function save(JsonDocument $document)
    {
        $this->cache->save($document->getId(), $document->getRawBody(), 0);
    }
}

iii-78: Return false if event really does not exist