<?php
namespace Drupal\ga_slide;

use Drupal\file\Entity\File;
use Drupal\image\Entity\ImageStyle;

class SlideUtils
{
  public static function getSlides()
  {
    $slideNids = \Drupal::entityQuery('slide')
      ->sort('weight', 'ASC')
      ->execute();
    $slideEntities = \Drupal::entityTypeManager()->getStorage("slide")->loadMultiple($slideNids);

    $slides = [];
    foreach ($slideEntities as $slideEntity) {
      $slides[] = array(
        "name" => $slideEntity->label(),
        "image" => isset($slideEntity->getImage()[0]) ? ImageStyle::load('slide')->buildUrl(File::load($slideEntity->getImage()[0])->getFileUri()) : null,
        "video" => isset($slideEntity->getVideo()[0]) ? File::load($slideEntity->getVideo()[0])->getFileUri() : null,
        "link" => $slideEntity->getLink()
      );
    }
    return $slides;
  }
}

<?php
namespace Drupal\ga_slide;

use Drupal\file\Entity\File;
use Drupal\image\Entity\ImageStyle;

class SlideUtils
{
  public static function getSlides()
  {
    $slideNids = \Drupal::entityQuery('slide')
      ->sort('weight', 'ASC')
      ->execute();
    $slideEntities = \Drupal::entityTypeManager()->getStorage("slide")->loadMultiple($slideNids);

    $slides = [];
    foreach ($slideEntities as $slideEntity) {
      $slides[] = array(
        "name" => $slideEntity->label(),
        "image" => File::load($slideEntity->getImage()[0]) ? ImageStyle::load('slide')->buildUrl(File::load($slideEntity->getImage()[0])->getFileUri()) : null,
        "video" => File::load($slideEntity->getVideo()[0]) ? File::load($slideEntity->getVideo()[0])->getFileUri() : null,
        "link" => $slideEntity->getLink()
      );
    }
    return $slides;
  }
}

Fix bug on frontpage with video

Fix bug on frontpage with video


<?php

namespace PicoFeed;

use DateTime;
use DateTimeZone;

/**
 * Logging class
 *
 * @author  Frederic Guillot
 * @package picofeed
 */
class Logging
{
    /**
     * List of messages
     *
     * @static
     * @access private
     * @var array
     */
    private static $messages = array();

    /**
     * Default timezone
     *
     * @static
     * @access private
     * @var array
     */
    private static $timezone = 'UTC';

    /**
     * Add a new message
     *
     * @static
     * @access public
     * @param  string   $message   Message
     */
    public static function setMessage($message)
    {
        $date = new DateTime('now', new DateTimeZone(self::$timezone));

        self::$messages[] = '['.$date->format('Y-m-d H:i:s').'] '.$message;
    }

    /**
     * Get all logged messages
     *
     * @static
     * @access public
     * @return array
     */
    public static function getMessages()
    {
        return self::$messages;
    }

    /**
     * Set a different timezone
     *
     * @static
     * @see    http://php.net/manual/en/timezones.php
     * @access public
     * @param  string   $timezone   Timezone
     */
    public static function setTimeZone($timezone)
    {
        self::$timezone = $timezone ?: self::$timezone;
    }
}

<?php

namespace PicoFeed;

use DateTime;
use DateTimeZone;

/**
 * Logging class
 *
 * @author  Frederic Guillot
 * @package picofeed
 */
class Logging
{
    /**
     * List of messages
     *
     * @static
     * @access private
     * @var array
     */
    private static $messages = array();

    /**
     * Default timezone
     *
     * @static
     * @access private
     * @var array
     */
    private static $timezone = 'UTC';

    /**
     * Add a new message
     *
     * @static
     * @access public
     * @param  string   $message   Message
     */
    public static function setMessage($message)
    {
        $date = new DateTime('now', new DateTimeZone(self::$timezone));

        self::$messages[] = '['.$date->format('Y-m-d H:i:s').'] '.$message;
    }

    /**
     * Get all logged messages
     *
     * @static
     * @access public
     * @return array
     */
    public static function getMessages()
    {
        return self::$messages;
    }

    /**
     * Remove all logged messages
     *
     * @static
     * @access public
     */
    public static function deleteMessages()
    {
        self::$messages = array();
    }

    /**
     * Set a different timezone
     *
     * @static
     * @see    http://php.net/manual/en/timezones.php
     * @access public
     * @param  string   $timezone   Timezone
     */
    public static function setTimeZone($timezone)
    {
        self::$timezone = $timezone ?: self::$timezone;
    }
}

Add method to remove logged messages

Add method to remove logged messages


<?php

namespace Orchestra\Support;

use Illuminate\Contracts\Pagination\Paginator;
use Illuminate\Support\Collection as BaseCollection;

abstract class Serializer
{
    /**
     * Data serializer key name.
     *
     * @var string
     */
    protected $key = 'data';

    /**
     * Invoke the serializer.
     *
     * @param mixed $parameters
     *
     * @return mixed
     */
    public function __invoke(...$parameters)
    {
        if (method_exists($this, 'serialize')) {
            return $this->serialize(...$parameters);
        }

        return $this->serializeBasicDataset($parameters[0]);
    }

    /**
     * Resolve paginated dataset.
     *
     * @param  mixed  $dataset
     *
     * @return array
     */
    final protected function serializeBasicDataset($dataset)
    {
        $key = $this->resolveSerializerKey($dataset);

        if ($dataset instanceof Paginator) {
            $collection = $dataset->toArray();

            $collection[$key] = $collection['data'];
            unset($collection['data']);

            return $collection;
        }

        return [
            $key => $dataset->toArray(),
        ];
    }

    /**
     * Resolve serializer key.
     *
     * @param  mixed  $dataset
     *
     * @return string
     */
    protected function resolveSerializerKey($dataset)
    {
        if ($dataset instanceof BaseCollection || $dataset instanceof Paginator) {
            return Str::plural($this->key);
        }

        return $this->key;
    }
}

<?php

namespace Orchestra\Support;

use Illuminate\Contracts\Pagination\Paginator;
use Illuminate\Support\Collection as BaseCollection;

abstract class Serializer
{
    /**
     * Data serializer key name.
     *
     * @var string
     */
    protected $key = 'data';

    /**
     * Invoke the serializer.
     *
     * @param mixed $parameters
     *
     * @return mixed
     */
    public function __invoke(...$parameters)
    {
        if (method_exists($this, 'serialize')) {
            return $this->serialize(...$parameters);
        }

        return $this->serializeBasicDataset($parameters[0]);
    }

    /**
     * Resolve paginated dataset.
     *
     * @param  mixed  $dataset
     *
     * @return array
     */
    final protected function serializeBasicDataset($dataset)
    {
        $key = $this->resolveSerializerKey($dataset);

        if ($dataset instanceof Paginator) {
            $collection = $dataset->toArray();

            $collection[$key] = $collection['data'];
            unset($collection['data']);

            return $collection;
        }

        return [
            $key => $dataset->toArray(),
        ];
    }

    /**
     * Get serializer key.
     *
     * @return string
     */
    final public function getKey(): string
    {
        return $this->key;
    }

    /**
     * Resolve serializer key.
     *
     * @param  mixed  $dataset
     *
     * @return string
     */
    protected function resolveSerializerKey($dataset)
    {
        if ($dataset instanceof BaseCollection || $dataset instanceof Paginator) {
            return Str::plural($this->getKey());
        }

        return $this->getKey();
    }
}

Allow to get key for serializer.

Allow to get key for serializer.

Signed-off-by: Mior Muhammad Zaki <e1a543840a942eb68427510a8a483282a7bfeddf@gmail.com>


<?php

/*
 * This file is part of the eluceo/iCal package.
 *
 * (c) Markus Poerschke <markus@eluceo.de>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Eluceo\iCal\Util;

class ComponentUtil
{
    /**
     * Folds a single line.
     *
     * According to RFC 5545, all lines longer than 75 characters should be folded
     *
     * @see https://tools.ietf.org/html/rfc5545#section-5
     * @see https://tools.ietf.org/html/rfc5545#section-3.1
     *
     * @param $string
     *
     * @return array
     */
    public static function fold($string)
    {
        $lines = [];
        $array = preg_split('/(?<!^)(?!$)/u', $string);

        $line = '';
        $lineNo = 0;
        foreach ($array as $char) {
            $charLen = strlen($char);
            $lineLen = strlen($line);
            if ($lineLen + $charLen > 75) {
                $line = ' ' . $char;
                ++$lineNo;
            } else {
                $line .= $char;
            }
            $lines[$lineNo] = $line;
        }

        return $lines;
    }
}

<?php

/*
 * This file is part of the eluceo/iCal package.
 *
 * (c) Markus Poerschke <markus@eluceo.de>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Eluceo\iCal\Util;

class ComponentUtil
{
    /**
     * Folds a single line.
     *
     * According to RFC 5545, all lines longer than 75 characters should be folded
     *
     * @see https://tools.ietf.org/html/rfc5545#section-5
     * @see https://tools.ietf.org/html/rfc5545#section-3.1
     *
     * @param $string
     *
     * @return array
     */
    public static function fold($string)
    {
        $lines = [];
        while (strlen($string) > 0) {
            if (strlen($string) > 75) {
                $lines[] = mb_strcut($string, 0, 75, 'utf-8') . "\r\n";
                $str = ' ' . mb_strcut($string, 75, strlen($string), 'utf-8');
            } else {
                $lines[] = $string;
                $str = '';
                break;
            }
        }
        return $lines;
    }
}

Optimize Performance for long lines (use mb_strcut() instead of pred_split())


<?php namespace Bkwld\Decoy\Observers;

/**
 * Trigger encoding or delete the encodings rows
 */
class Encoding {

	/**
	 * Start a new encode if a new encodable file was uploaded
	 *
	 * @param Bkwld\Decoy\Models\Base $model
	 * @return void
	 */
	public function onSaving($model) {
		if (!$this->isEncodable($model)) return;
		foreach($model->getDirtyEncodableAttributes() as $attribute) {

			// If the attribute has a value, encode the attribute
			if (isset($model->$attribute)) $model->encodeOnSave($attribute);

			// Otherwise delete encoding references
			else $model->encoding($attribute)->delete();
		}
	}

	/**
	 * Delete all encodes on the model
	 *
	 * @param Bkwld\Decoy\Models\Base $model
	 * @return void
	 */
	public function onDeleted($model) {
		if (!$this->isEncodable($model)) return;
		$model->deleteEncodings();
	}

	/**
	 * Check if a model should be encoded
	 *
	 * @param Bkwld\Decoy\Models\Base $model
	 * @return boolean
	 */
	public function isEncodable($model) {
		if (!method_exists($model, 'getDirtyEncodableAttributes')) return false;
		if (is_a($model, 'Bkwld\Decoy\Models\Element')
			&& $model->getAttribute('type') != 'video-encoder') return false;
		return true;
	}

}

<?php namespace Bkwld\Decoy\Observers;

/**
 * Trigger encoding or delete the encodings rows
 */
class Encoding {

	/**
	 * Start a new encode if a new encodable file was uploaded
	 *
	 * @param Bkwld\Decoy\Models\Base $model
	 * @return void
	 */
	public function onSaving($model) {
		if (!$this->isEncodable($model)) return;
		foreach($model->getDirtyEncodableAttributes() as $attribute) {

			// If the attribute has a value, encode the attribute
			if ($model->getAttribute($attribute)) $model->encodeOnSave($attribute);

			// Otherwise delete encoding references
			else if ($encoding = $model->encoding($attribute)) $encoding->delete();
		}
	}

	/**
	 * Delete all encodes on the model
	 *
	 * @param Bkwld\Decoy\Models\Base $model
	 * @return void
	 */
	public function onDeleted($model) {
		if (!$this->isEncodable($model)) return;
		$model->deleteEncodings();
	}

	/**
	 * Check if a model should be encoded
	 *
	 * @param Bkwld\Decoy\Models\Base $model
	 * @return boolean
	 */
	public function isEncodable($model) {
		if (!method_exists($model, 'getDirtyEncodableAttributes')) return false;
		if (is_a($model, 'Bkwld\Decoy\Models\Element')
			&& $model->getAttribute('type') != 'video-encoder') return false;
		return true;
	}

}

Check if there are encodings before trying to delete them


<?php
namespace Scat;

class Note extends \Model implements \JsonSerializable {
  public function txn() {
    if ($this->kind == 'txn') {
      return $this->belongs_to('Txn', 'attach_id')->find_one();
    }
  }

  public function person() {
    return $this->belongs_to('Person');
  }

  public function parent() {
    return $this->belongs_to('Note', 'parent_id');
  }

  public function jsonSerialize() {
    return $this->as_array();
  }
}

<?php
namespace Scat;

class Note extends \Model implements \JsonSerializable {
  public function txn() {
    if ($this->kind == 'txn') {
      return $this->belongs_to('Txn', 'attach_id')->find_one();
    }
  }

  public function about() {
    if ($this->kind == 'txn') {
      return $this->belongs_to('Txn', 'attach_id')->find_one()->owner();
    }
    if ($this->kind == 'person') {
      return $this->belongs_to('Person', 'attach_id')->find_one();
    }
  }

  public function person() {
    return $this->belongs_to('Person');
  }

  public function parent() {
    return $this->belongs_to('Note', 'parent_id');
  }

  public function jsonSerialize() {
    return $this->as_array();
  }
}

Return person that note is about

Return person that note is about


        <script src="{{ asset('vendor/flare/plugins/jQuery/jQuery-2.1.4.min.js') }}" type="text/javascript"></script>
        <script src="{{ asset('vendor/flare/bootstrap/js/bootstrap.min.js') }}" type="text/javascript"></script>
        <script src="{{ asset('vendor/flare/js/app.min.js') }}" type="text/javascript"></script>
        <script src="{{ asset('vendor/flare/plugins/morris/morris.min.js') }}" type="text/javascript"></script>
        <script src="{{ asset('vendor/flare/plugins/select2/select2.full.min.js') }}" type="text/javascript"></script>
        <script src="{{ asset('vendor/flare/plugins/input-mask/jquery.inputmask.js') }}"></script>
        <script src="{{ asset('vendor/flare/plugins/input-mask/jquery.inputmask.date.extensions.js') }}"></script>
        <script src="{{ asset('vendor/flare/plugins/input-mask/jquery.inputmask.extensions.js') }}"></script>
        <script src="{{ asset('vendor/flare/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js') }}"></script>
        <script src="{{ asset('vendor/flare/plugins/pace/pace.js') }}"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js" type="text/javascript"></script>

        @yield('enqueued-js')
    </body>
</html>

        <script src="{{ asset('vendor/flare/plugins/jQuery/jQuery-2.2.0.min.js') }}" type="text/javascript"></script>
        <script src="{{ asset('vendor/flare/bootstrap/js/bootstrap.min.js') }}" type="text/javascript"></script>
        <script src="{{ asset('vendor/flare/js/app.min.js') }}" type="text/javascript"></script>
        <script src="{{ asset('vendor/flare/plugins/morris/morris.min.js') }}" type="text/javascript"></script>
        <script src="{{ asset('vendor/flare/plugins/select2/select2.full.min.js') }}" type="text/javascript"></script>
        <script src="{{ asset('vendor/flare/plugins/input-mask/jquery.inputmask.js') }}"></script>
        <script src="{{ asset('vendor/flare/plugins/input-mask/jquery.inputmask.date.extensions.js') }}"></script>
        <script src="{{ asset('vendor/flare/plugins/input-mask/jquery.inputmask.extensions.js') }}"></script>
        <script src="{{ asset('vendor/flare/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js') }}"></script>
        <script src="{{ asset('vendor/flare/plugins/pace/pace.js') }}"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js" type="text/javascript"></script>

        @yield('enqueued-js')
    </body>
</html>

Update footer for latest version of Jquery


Weather Underground is a registered trademark of The Weather Channel, LLC both in the United States and internationally. The Weather Underground Logo is a trademark of Weather Underground, LLC.

Add Weather Underground referral URL.

Add Weather Underground referral URL.


<?php
/**
 * @link https://github.com/brussens/yii2-maintenance-mode
 * @copyright Copyright (c) since 2015 Dmitry Brusensky
 * @license http://opensource.org/licenses/MIT MIT
 */

namespace brussens\maintenance\states;

use Yii;
use brussens\maintenance\StateInterface;
use yii\base\BaseObject;

/**
 * Class FileState
 * @package brussens\maintenance\states
 */
class FileState extends BaseObject implements StateInterface
{
    /**
     * @var string
     */
    public $fileName = '.enable';
    /**
     * @var string
     */
    public $directory = '@runtime';

    /**
     * Turn on mode.
     * @since 0.2.5
     */
    public function enable()
    {
        file_put_contents($this->getStatusFilePath(), ' ');
    }

    /**
     * Turn off mode.
     * @since 0.2.5
     */
    public function disable()
    {
        $path = $this->getStatusFilePath();
        if (file_exists($path)) {
            unlink($path);
        }
    }

    /**
     * @return bool
     */
    public function isEnabled()
    {
        return file_exists($this->getStatusFilePath());
    }

    /**
     * Return status file path.
     * @since 0.2.5
     * @return bool|string
     */
    protected function getStatusFilePath()
    {
        return Yii::getAlias($this->directory . '/' . $this->fileName);
    }
}

<?php
/**
 * @link      https://github.com/brussens/yii2-maintenance-mode
 * @copyright Copyright (c) since 2015 Dmitry Brusensky
 * @license   http://opensource.org/licenses/MIT MIT
 */

namespace brussens\maintenance\states;

use Yii;
use brussens\maintenance\StateInterface;
use yii\base\BaseObject;

/**
 * Class FileState
 *
 * @package brussens\maintenance\states
 */
class FileState extends BaseObject implements StateInterface
{
    /**
     * @var string
     */
    public $fileName = '.enable';
    /**
     * @var string
     */
    public $directory = '@runtime';

    /**
     * Turn on mode.
     *
     * @since 0.2.5
     */
    public function enable()
    {
        file_put_contents($this->getStatusFilePath(), ' ');
    }

    /**
     * Turn off mode.
     *
     * @since 0.2.5
     */
    public function disable()
    {
        $path = $this->getStatusFilePath();

        if (file_exists($path)) {
            if (! unlink($path)) {
                throw new \Exception(
                    "Attention: the maintenance mode could not be disabled because $path could not be removed."
                );
            };
        }
    }

    /**
     * @return bool will return true if the file exists
     */
    public function isEnabled()
    {
        return file_exists($this->getStatusFilePath());
    }

    /**
     * Return status file path.
     *
     * @return bool|string
     * @since 0.2.5
     */
    protected function getStatusFilePath()
    {
        return Yii::getAlias($this->directory . '/' . $this->fileName);
    }
}

Throw an critical Exception if maintenance mode could not be disabled


<?php
/**
 * Created by IntelliJ IDEA.
 * User: mduncan
 * Date: 9/29/15
 * Time: 12:49 PM
 */

namespace Fulfillment\Api\Utilities;

use GuzzleHttp\Exception\RequestException;

class RequestParser
{
    public static function parseError(RequestException $requestException)
    {

        $error = $error = json_decode($requestException->getResponse()->getBody(), true);

        if (!is_null($error)) {
            return $error;
        } else {
            return $requestException->getMessage();
        }
    }

    public static function getErrorCode(RequestException $requestException)
    {
        $error = $error = json_decode($requestException->getResponse()->getBody());

        if (!is_null($error) && isset($error->error_code)) {
            return $error->error_code;
        } else {
            return null;
        }
    }
}

<?php
/**
 * Created by IntelliJ IDEA.
 * User: mduncan
 * Date: 9/29/15
 * Time: 12:49 PM
 */

namespace Fulfillment\Api\Utilities;

use GuzzleHttp\Exception\RequestException;

class RequestParser
{
    /**
     * Returns an object or array of the FDC error parsed from the Guzzle Request exception
     * @param RequestException $requestException
     * @param bool             $isAssoc
     * @return string
     */
    public static function parseError(RequestException $requestException, $isAssoc = true)
    {

        $error = $error = json_decode($requestException->getResponse()->getBody(), $isAssoc);

        if (!is_null($error)) {
            return $error;
        } else {
            return $requestException->getMessage();
        }
    }

    public static function getErrorCode(RequestException $requestException)
    {
        $error = $error = json_decode($requestException->getResponse()->getBody());

        if (!is_null($error) && isset($error->error_code)) {
            return $error->error_code;
        } else {
            return null;
        }
    }
}

Add ability to change how request parser decodes json

Can choose between associative or object


<?php

namespace Distilleries\LayoutManager\Forms;

use App\Helpers\StaticLabel;
use Distilleries\FormBuilder\FormValidator;

class TemplatableForm extends FormValidator
{
    public static $rules = [];

    public static $rules_update = null;

    public function buildForm()
    {
        $options =  [
            'templatable' => $this->model,
            'categories' => [],
            'custom-tags' => [],
        ];
        if (array_get($this->formOptions, 'categories')) {
            $options['categories'] = (array_pull($this->formOptions, 'categories'));
        }
        if (array_get($this->formOptions, 'custom-tags')) {
            $options['custom-tags'] = (array_pull($this->formOptions, 'custom-tags'));
        }
        $this
            ->add('templates', 'template', $options);
    }
}

<?php

namespace Distilleries\LayoutManager\Forms;

use App\Helpers\StaticLabel;
use Distilleries\FormBuilder\FormValidator;

class TemplatableForm extends FormValidator
{
    public static $rules = [];

    public static $rules_update = null;

    public function buildForm()
    {
        $options =  [
            'templatable' => $this->model,
            'categories' => [],
            'custom-tags' => [],
        ];
        if (array_get($this->formOptions, 'categories')) {
            $options['categories'] = $this->formOptions['categories'];
        }
        if (array_get($this->formOptions, 'templates')) {
            $options['templates'] = $this->formOptions['templates'];
        }
        if (array_get($this->formOptions, 'custom-tags')) {
            $options['custom-tags'] = $this->formOptions['custom-tags'];
        }
        $this
            ->add('templates', 'template', $options);
    }
}

Add possibility to override available templates list


<?php
/**
 * CreateAction class file.
 * @author Christoffer Lindqvist <christoffer.lindqvist@nordsoftware.com>
 * @copyright Copyright © Nord Software 2014-
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @package nordsoftware.yii-rest.actions
 */

namespace nordsoftware\yii_rest\actions;

/**
 * CreateAction implements the REST API endpoint for creating a new model from the given data.
 */
class CreateAction extends Action
{
    /**
     * Creates a new model.
     */
    public function run()
    {
        /** @var \CActiveRecord $model */
        $model = new $this->modelClass();
        $model->attributes = \Yii::app()->getRequest()->getBodyParams();
        $model->save();
        $this->sendResponse($model);
    }
}

<?php
/**
 * CreateAction class file.
 * @author Christoffer Lindqvist <christoffer.lindqvist@nordsoftware.com>
 * @copyright Copyright © Nord Software 2014-
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @package nordsoftware.yii-rest.actions
 */

namespace nordsoftware\yii_rest\actions;

/**
 * CreateAction implements the REST API endpoint for creating a new model from the given data.
 */
class CreateAction extends Action
{
    /**
     * Creates a new model.
     */
    public function run()
    {
        /** @var \CActiveRecord $model */
        $model = new $this->modelClass();
        $model->attributes = \Yii::app()->getRequest()->getBodyParams();
        $model->save();
        $this->sendResponse($model, 201);
    }
}

Fix create action response code

Fix create action response code


<?php
namespace Dream89\MainBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use FOS\RestBundle\Controller\Annotations\View;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;

class FavoriteController extends Controller {

    /**
     * @return array
     * @View()
     */
    function getFavoritesAction()
    {
        $favorites = $this->get('doctrine_phpcr')->getManager()
            ->getRepository('Dream89\MainBundle\Document\FavoriteItem')
            ->findAll();
        return array('favorites' => $favorites );
    }
}

<?php
namespace Dream89\MainBundle\Controller;

use Dream89\MainBundle\Document\FavoriteItem;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use FOS\RestBundle\Controller\Annotations\View,
    FOS\RestBundle\Controller\Annotations\RouteResource;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;

class FavoriteController extends Controller {

    /**
     * @return array
     * @View()
     */
    function getFavoritesAction()
    {
        $favorites = $this->get('doctrine_phpcr')->getManager()
            ->getRepository('Dream89\MainBundle\Document\FavoriteItem')
            ->findAll();
        return array('favorites' => $favorites );
    }

    /**
     * @return array
     * @View()
     */
    function getFavoriteAction(FavoriteItem $favoriteItem)
    {
        $data = $this->get('doctrine_phpcr')->getManager()
            ->getRepository('Dream89\MainBundle\Document\FavoriteItem')
            ->find('Dream89\MainBundle\Document\FavoriteItem', $favoriteItem);
        return array('favorites' => $data );
    }
}

Create get favorite item route

Create get favorite item route


<?php

namespace SearchApi\Models;

/**
 * Class SearchRequest - This will be the class that defines the requests parameters to search on
 */
class SearchRequest {
  public $text;
}

<?php

namespace SearchApi\Models;

/**
 * Class SearchRequest - User-provided request parameters
 *
 * @var $document       string                Large body of text from a document to be used for NER
 * @var $text           string|null           Additional keywords
 * @var $coord          Models\GeoCoordinate  User-specified lat/long for reverse geocoding
 * @var $resultsPerPage int                   Number of results per page
 * @var $page           int                   Which page to retrieve
 */
class SearchRequest {
  public $document;
  public $text;
  public $coord;
  public $resultsPerPage;
  public $page;
}

Add more properties to SearchRequest

Add more properties to SearchRequest


<?php

namespace GeniusTS\Preferences\Controllers;

use GeniusTS\Preferences\Models\Domain;
use GeniusTS\Preferences\Models\Element;
use GeniusTS\Preferences\Models\Setting;
use GeniusTS\Preferences\PreferencesManager;
use Symfony\Component\HttpFoundation\Response;
use GeniusTS\Preferences\Requests\SettingsRequest;

/**
 * Class SettingsController
 *
 * @package GeniusTS\Preferences
 */
abstract class SettingsController
{

    /**
     * @var PreferencesManager
     */
    protected $preferences;

    /**
     * SettingsController constructor.
     */
    public function __construct()
    {
        $this->preferences = resolve('preferences');
    }

    /**
     * Handle update settings request
     *
     * @param \GeniusTS\Preferences\Requests\SettingsRequest $request
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function update(SettingsRequest $request)
    {
        /** @var Domain $domain */
        foreach ($this->preferences->domains as $domain)
        {
            /** @var Element $element */
            foreach ($domain->elements as $element)
            {
                $model = Setting::findBySlugOrNew($element->name, $domain->key);
                $model->value = $request->get($element->name, null);
                $model->save();
            }
        }

        return $this->handleSuccessResponse();
    }

    /**
     * @return Response
     */
    abstract protected function handleSuccessResponse();
}

<?php

namespace GeniusTS\Preferences\Controllers;

use GeniusTS\Preferences\Models\Domain;
use GeniusTS\Preferences\Models\Element;
use GeniusTS\Preferences\Models\Setting;
use GeniusTS\Preferences\PreferencesManager;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Symfony\Component\HttpFoundation\Response;
use GeniusTS\Preferences\Requests\SettingsRequest;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

/**
 * Class SettingsController
 *
 * @package GeniusTS\Preferences
 */
abstract class SettingsController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    /**
     * @var PreferencesManager
     */
    protected $preferences;

    /**
     * SettingsController constructor.
     */
    public function __construct()
    {
        $this->preferences = resolve('preferences');
    }

    /**
     * Handle update settings request
     *
     * @param \GeniusTS\Preferences\Requests\SettingsRequest $request
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function update(SettingsRequest $request)
    {
        /** @var Domain $domain */
        foreach ($this->preferences->domains as $domain)
        {
            /** @var Element $element */
            foreach ($domain->elements as $element)
            {
                $model = Setting::findBySlugOrNew($element->name, $domain->key);
                $model->value = $request->get($element->name, null);
                $model->save();
            }
        }

        return $this->handleSuccessResponse();
    }

    /**
     * @return Response
     */
    abstract protected function handleSuccessResponse();
}

Add missed traits for controller

Add missed traits for controller


@extends('layouts.app')

@section('content')
  @include('partials.page-header')

  @if (!have_posts())
    <div class="alert alert-warning">
      {{ __('Sorry, no results were found.', 'sage') }}
    </div>
    {!! get_search_form(false) !!}
  @endif

  @while (have_posts()) @php(the_post())
    @include ('partials.content-'.(get_post_type() !== 'post' ? get_post_type() : get_post_format()))
  @endwhile

  {!! get_the_posts_navigation() !!}
@endsection

@extends('layouts.app')

@section('content')
  @include('partials.page-header')

  @if (!have_posts())
    <div class="alert alert-warning">
      {{ __('Sorry, no results were found.', 'sage') }}
    </div>
    {!! get_search_form(false) !!}
  @endif

  @while (have_posts()) @php(the_post())
    @include ('partials.content-'.(get_post_type() !== 'post' ?: get_post_type()))
  @endwhile

  {!! get_the_posts_navigation() !!}
@endsection

Remove post format reference in template call


<time class="published" datetime="<?php echo get_the_time('c'); ?>"><?php echo get_the_date(); ?></time>

<?php echo __('By', 'roots'); ?> <a href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?>" rel="author" class="fn"><?php echo get_the_author(); ?>

Remove author from search results page

Remove author from search results page


    @foreach($comments as $comment)

                {{-- Comment owner --}}
                {{ $comment->user->name }}
                 - {{ $comment->created_at->diffForHumans() }}

                    {{-- Comment Body --}}

                        {{ $comment->body }}

                    {{-- Comment action buttons --}}
                    @if(Gate::check('update', $comment) || Gate::check('delete', $comment))

                            {{-- Edit comment button --}}
                            @can('update', $comment)
                                 $comment->id]) }}">Edit
                            @endcan

                            {{-- Delete comment button --}}
                            @can('delete', $comment)
                                 $comment->id]) }}"
                                   href="#">Delete
                            @endcan

                    @endif

    @endforeach

{{-- Comments pagination links --}}

    {{ $comments->links('vendor.pagination.simple-bootstrap-4') }}

    @foreach($comments as $comment)

                {{-- Comment owner --}}
                {{ $comment->user->name }}
                @if($comment->user->ownsArticle($comment->article))
                    author
                @endif
                 - {{ $comment->created_at->diffForHumans() }}

                    {{-- Comment Body --}}

                        {{ $comment->body }}

                    {{-- Comment action buttons --}}
                    @if(Gate::check('update', $comment) || Gate::check('delete', $comment))

                            {{-- Edit comment button --}}
                            @can('update', $comment)
                                 $comment->id]) }}">Edit
                            @endcan

                            {{-- Delete comment button --}}
                            @can('delete', $comment)
                                 $comment->id]) }}"
                                   href="#">Delete
                            @endcan

                    @endif

    @endforeach

{{-- Comments pagination links --}}

    {{ $comments->links('vendor.pagination.simple-bootstrap-4') }}

Add author badge to comments

Add author badge to comments


<?php
/**
 * This file is part of PMG\Queue
 *
 * Copyright (c) PMG <https://www.pmg.com>
 *
 * For full copyright information see the LICENSE file distributed
 * with this source code.
 *
 * @license     http://opensource.org/licenses/Apache-2.0 Apache-2.0
 */

namespace PMG\Queue\Driver;

use PMG\Queue\Envelope;
use PMG\Queue\Serializer\Serializer;
use PMG\Queue\Serializer\NativeSerializer;

/**
 * Base class for drivers that deal with persistent backends. This provides
 * some utilities for serialization.
 *
 * @since   2.0
 */
abstract class AbstractPersistanceDriver implements \PMG\Queue\Driver
{
    /**
     * @var Serializer
     */
    private $serializer;

    public function __construct(Serializer $serializer=null)
    {
        $this->serializer = $serializer ?: static::createDefaultSerializer();
    }

    protected function serialize(Envelope $env)
    {
        return $this->getSerializer()->serialize($env);
    }

    protected function unserialize($data)
    {
        return $this->getSerializer()->unserialize($data);
    }

    protected function getSerializer()
    {
        return $this->serializer;
    }

    protected static function createDefaultSerializer()
    {
        return new NativeSerializer();
    }
}

<?php
/**
 * This file is part of PMG\Queue
 *
 * Copyright (c) PMG <https://www.pmg.com>
 *
 * For full copyright information see the LICENSE file distributed
 * with this source code.
 *
 * @license     http://opensource.org/licenses/Apache-2.0 Apache-2.0
 */

namespace PMG\Queue\Driver;

use PMG\Queue\Envelope;
use PMG\Queue\Serializer\Serializer;
use PMG\Queue\Serializer\NativeSerializer;

/**
 * Base class for drivers that deal with persistent backends. This provides
 * some utilities for serialization.
 *
 * @since   2.0
 */
abstract class AbstractPersistanceDriver implements \PMG\Queue\Driver
{
    /**
     * @var Serializer
     */
    private $serializer;

    public function __construct(Serializer $serializer=null)
    {
        $this->serializer = $serializer;
    }

    protected function serialize(Envelope $env)
    {
        return $this->getSerializer()->serialize($env);
    }

    protected function unserialize($data)
    {
        return $this->getSerializer()->unserialize($data);
    }

    protected function getSerializer()
    {
        if (!$this->serializer) {
            $this->serializer = new NativeSerializer();
        }

        return $this->serializer;
    }
}

Revert "Create a Serializer in the Constructor of Persistent Drivers"

This reverts commit f7f1c77fdf40c1fafa69a80195a19ef932949f8b.


Make CC link secure (e.g. https)!

Make CC link secure (e.g. https)!


<?php

namespace Frozzare\Digster\Extensions;

class Global_Extensions extends \Twig_Extension {

    /**
     * Get global variable.
     *
     * @return array
     */
    public function getGlobals() {
        return [
            'post' => get_post( get_the_ID() )
        ];
    }

    /**
     * Get the extension name.
     *
     * @return string
     */
    public function getName() {
        return 'digster-globals';
    }

}

<?php

namespace Frozzare\Digster\Extensions;

class Global_Extensions extends \Twig_Extension implements \Twig_Extension_GlobalsInterface {

    /**
     * Get global variable.
     *
     * @return array
     */
    public function getGlobals() {
        return [
            'post' => get_post( get_the_ID() )
        ];
    }

    /**
     * Get the extension name.
     *
     * @return string
     */
    public function getName() {
        return 'digster-globals';
    }

}

Add globals extension interface to global extensions file


<?php

namespace Crell\ApiProblem;

/**
 * Tests for the ApiProblem object.
 *
 * @autor Larry Garfield
 */
class ApiProblemTest extends \PHPUnit_Framework_TestCase
{

    public function testConstructor()
    {
        $problem = new ApiProblem('Title', 'URI');
        $this->assertEquals("Title", $problem->getTitle());
        $this->assertEquals("URI", $problem->getProblemType());
    }

}

<?php

namespace Crell\ApiProblem;

/**
 * Tests for the ApiProblem object.
 *
 * @autor Larry Garfield
 */
class ApiProblemTest extends \PHPUnit_Framework_TestCase
{

    public function testConstructor()
    {
        $problem = new ApiProblem('Title', 'URI');
        $this->assertEquals("Title", $problem->getTitle());
        $this->assertEquals("URI", $problem->getProblemType());
    }

    public function testSimpleExtraProperty()
    {
        $problem = new ApiProblem('Title', 'URI');

        $problem['sir'] = 'Gir';
        $this->assertEquals('Gir', $problem['sir']);

        unset($problem['sir']);
        $this->assertNull($problem['sir']);
    }

    public function testComplexExtraProperty()
    {
        $problem = new ApiProblem('Title', 'URI');

        $problem['irken']['invader'] = 'Zim';
        $this->assertEquals('Zim', $problem['irken']['invader']);
    }

    public function testSimpleJsonCompile()
    {
        $problem = new ApiProblem('Title', 'URI');

        $json = $problem->asJson();
        $result = json_decode($json, true);

        $this->assertArrayHasKey('title', $result);
        $this->assertEquals('Title', $result['title']);
        $this->assertArrayHasKey('problemType', $result);
        $this->assertEquals('URI', $result['problemType']);
    }

    public function testExtraPropertyJsonCompile()
    {
        $problem = new ApiProblem('Title', 'URI');
        $problem['sir'] = 'Gir';
        $problem['irken']['invader'] = 'Zim';

        $json = $problem->asJson();
        $result = json_decode($json, true);

        $this->assertArrayHasKey('sir', $result);
        $this->assertEquals('Gir', $result['sir']);
        $this->assertArrayHasKey('irken', $result);
        $this->assertArrayHasKey('invader', $result['irken']);
        $this->assertEquals('Zim', $result['irken']['invader']);
    }

}

Add a lot more tests.

Add a lot more tests.


<?php

namespace duncan3dc\DateTests;

use duncan3dc\Dates\DateParser;

class DateParserTest extends \PHPUnit_Framework_TestCase
{
    protected $dates = [
        "Y-m-d"         =>  "2008-02-22",
        "d/m/Y"         =>  "28/02/2008",
        "d/m/y"         =>  "31/01/97",
        "Ymd"           =>  20080222,
        "d-m-Y"         =>  "04-07-2008",
        "d-m-y"         =>  "08-10-13",
        "1ymd"          =>  1070420,
    ];

    public function testFormats()
    {
        $parser = new DateParser;
        $parser->addDefaultParsers();

        foreach ($this->dates as $format => $test) {
            $result = $parser->parse($test)->format($format);
            $this->assertSame($test, $result);
        }
    }
}

<?php

namespace duncan3dc\DateTests;

use duncan3dc\Dates\DateParser;

class DateParserTest extends \PHPUnit_Framework_TestCase
{
    protected $dates = [
        "Y-m-d"         =>  "2008-02-22",
        "d/m/Y"         =>  "28/02/2008",
        "d/m/y"         =>  "31/01/97",
        "Ymd"           =>  20080222,
        "d-m-Y"         =>  "04-07-2008",
        "d-m-y"         =>  "08-10-13",
        "1ymd"          =>  1070420,
    ];

    public function testFormats()
    {
        $parser = new DateParser;
        $parser->addDefaultParsers();

        foreach ($this->dates as $format => $test) {
            $result = $parser->parse($test)->format($format);
            $this->assertSame($test, $result);
        }
    }

    public function testUnparsable()
    {
        $parser = new DateParser;

        error_reporting(\E_ALL ^ \E_WARNING);
        $this->setExpectedException("InvalidArgumentException", "An unparsable date was passed (/)");
        $parser->parse("/");
    }
}

Add a test for an unparsable date

Add a test for an unparsable date


<?php

trait Phuby {
    use Phuby\Core;

    static function initialized($self) {
        while ($superclass = $self->superclass())
            $self = $superclass;

        $self->__include(__TRAIT__.'\Object');
    }
}

<?php

function Phuby($object) {
    if (is_string($object) && class_exists($object))
        return Phuby\BasicObject::const_get($object);
}

trait Phuby {
    use Phuby\Core;

    static function initialized($self) {
        while ($superclass = $self->superclass())
            $self = $superclass;

        $self->__include(__TRAIT__.'\Object');
    }
}

Add global 'Phuby()' global function which calls BasicObject::const_get()


<?php

namespace rmatil\CmsBundle\Mapper;

use rmatil\CmsBundle\Entity\ArticleCategory;
use rmatil\CmsBundle\Exception\MapperException;
use rmatil\CmsBundle\Model\ArticleCategoryDTO;

class ArticleCategoryMapper extends AbstractMapper {

    public function entityToDto($articleCategory) {
        if (null === $articleCategory) {
            return null;
        }

        if ( ! ($articleCategory instanceof ArticleCategory)) {
            throw new MapperException(sprintf('Required object of type "%s" but got "%s"', ArticleCategory::class, get_class($articleCategory)));
        }

        $articleCategoryDto = new ArticleCategoryDTO();
        $articleCategoryDto->setId($articleCategory->getId());
        $articleCategoryDto->setName($articleCategoryDto->getName());

        return $articleCategoryDto;
    }

    public function dtoToEntity($articleCategoryDto) {
        if (null === $articleCategoryDto) {
            return null;
        }

        if ( ! ($articleCategoryDto instanceof ArticleCategoryDTO)) {
            throw new MapperException(sprintf('Required object of type "%s" but got "%s"', ArticleCategoryDTO::class, get_class($articleCategoryDto)));
        }

        $articleCategory = new ArticleCategory();
        $articleCategory->setId($articleCategoryDto->getId());
        $articleCategory->setName($articleCategoryDto->getName());

        return $articleCategory;
    }
}

<?php

namespace rmatil\CmsBundle\Mapper;

use rmatil\CmsBundle\Entity\ArticleCategory;
use rmatil\CmsBundle\Exception\MapperException;
use rmatil\CmsBundle\Model\ArticleCategoryDTO;

class ArticleCategoryMapper extends AbstractMapper {

    public function entityToDto($articleCategory) {
        if (null === $articleCategory) {
            return null;
        }

        if ( ! ($articleCategory instanceof ArticleCategory)) {
            throw new MapperException(sprintf('Required object of type "%s" but got "%s"', ArticleCategory::class, get_class($articleCategory)));
        }

        $articleCategoryDto = new ArticleCategoryDTO();
        $articleCategoryDto->setId($articleCategory->getId());
        $articleCategoryDto->setName($articleCategory->getName());

        return $articleCategoryDto;
    }

    public function dtoToEntity($articleCategoryDto) {
        if (null === $articleCategoryDto) {
            return null;
        }

        if ( ! ($articleCategoryDto instanceof ArticleCategoryDTO)) {
            throw new MapperException(sprintf('Required object of type "%s" but got "%s"', ArticleCategoryDTO::class, get_class($articleCategoryDto)));
        }

        $articleCategory = new ArticleCategory();
        $articleCategory->setId($articleCategoryDto->getId());
        $articleCategory->setName($articleCategoryDto->getName());

        return $articleCategory;
    }
}

Fix typo causing no name to be serialized for article categories


<?php

namespace Trafficgate\Transferer\Ssh;

use PHPUnit\Framework\TestCase;

class SshCommandTest extends TestCase
{
    public function testGetCommandString()
    {
        $sshCommand = new SshCommand();
        $sshCommand->host('127.0.0.1');
        $sshCommand->remoteCommand('echo Hello');
        $commandString = $sshCommand->getCommandString();

        $this->assertEquals(
            "'ssh' ".
            "'-q' ".
            "'-o' 'BatchMode yes' ".
            "'-o' 'StrictHostKeyChecking no' ".
            "'-o' 'UserKnownHostsFile /dev/null' ".
            "'127.0.0.1' ".
            "'echo Hello'",
            $commandString
        );
    }

    public function testRunOnce()
    {
        $sshCommand = new SshCommand();
        $sshCommand->host('127.0.0.1');
        $sshCommand->remoteCommand('echo Hello');

        $output = '';
        $sshCommand->runOnce(null, function ($type, $buffer) use (&$output) {
            $output .= $buffer;
        });

        $this->assertEquals("Hello\n", $output);
    }
}

<?php

namespace Trafficgate\Transferer\Ssh;

use PHPUnit\Framework\TestCase;

class SshCommandTest extends TestCase
{
    public function testGetCommandString()
    {
        $sshCommand = new SshCommand();
        $sshCommand->host('127.0.0.1');
        $sshCommand->remoteCommand('echo Hello');
        $commandString = $sshCommand->getCommandString();

        $this->assertEquals(
            "'ssh' ".
            "'-q' ".
            "'-o' 'BatchMode yes' ".
            "'-o' 'StrictHostKeyChecking no' ".
            "'-o' 'UserKnownHostsFile /dev/null' ".
            "'127.0.0.1' ".
            "'echo Hello'",
            $commandString
        );
    }

    public function testRunOnce()
    {
        $sshCommand = new SshCommand();
        $sshCommand->host('127.0.0.1');
        $sshCommand->remoteCommand('echo Hello');

        $output = '';
        $sshCommand->runOnce(null, function ($type, $buffer) use (&$output) {
            $output .= $buffer;
        });

        $lastError = $sshCommmand->lastError();
        if ($output === '' && $lastError instanceof Exception) {
            $this->fail($lastError->getMessage());
        }

        $this->assertEquals("Hello\n", $output);
    }
}

Add debug logic to test to see if any exceptions are thrown


<?php

namespace igorw\edn;

class LexerTest extends \PHPUnit_Framework_TestCase {
    /**
     * @test
     * @dataProvider provideInvalidEdn
     * @expectedException Phlexy\LexingException
     */
    function parseShouldRejectInvalidSyntax($edn) {
        $data = tokenize($edn);

        $this->fail(sprintf('Expected lexer to fail on %s, but got: %s', json_encode($edn), print_r($data, true)));
    }

    function provideInvalidEdn() {
        return [
            ['##'],
            ['#:foo'],
            [':#foo'],
            [':{'],
            [':}'],
            [':{}'],
            [':^'],
            ['^'],
            ['_:^'],
            ['.9'],
            ['/foo'],
            ['foo/'],
            [':/foo'],
            [':foo/'],
            ['#/foo'],
            ['#foo/'],
            ['foo/bar/baz'],
            ['foo/bar/baz/qux'],
            ['foo/bar/baz/qux/'],
            ['foo/bar/baz/qux/quux'],
            ['//'],
            ['///'],
            ['/foo//'],
            ['///foo'],
            ['\newline0.1'],
            ['\newline.'],
            ['.\newline'],
        ];
    }
}

<?php

namespace igorw\edn;

class LexerTest extends \PHPUnit_Framework_TestCase {
    /**
     * @test
     * @dataProvider provideInvalidEdn
     * @expectedException Phlexy\LexingException
     */
    function parseShouldRejectInvalidSyntax($edn) {
        $data = tokenize($edn);

        $this->fail(sprintf('Expected lexer to fail on %s, but got: %s', json_encode($edn), print_r($data, true)));
    }

    function provideInvalidEdn() {
        return [
            ['foo/bar/baz'],
            ['foo/bar/baz/qux'],
            ['foo/bar/baz/qux/'],
        ];
    }
}

Remove invalid test cases (they were submitted upstream)


<?php
// Set Logger Def
$defFile = '../../misc/loggerdefs/' . $_POST['Definition'];
if(!file_exists($defFile)) {
	header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
	echo "Invalid File: {$_POST['Definition']}";
	exit;
}
$LoggerDef = simplexml_load_file($defFile);

// Find our ECU IDs
$ecuArray = array();
$tmpArray = $LoggerDef->xpath('//ecuparam/ecu/@id');
foreach($tmpArray as $value) {
	$ecuArray = array_merge($ecuArray, explode(',', (string)$value));
}

// Get sorted, unique IDs
$ecuArray = array_unique($ecuArray);
sort($ecuArray);

// 500 on empty array
if(empty($ecuArray)) {
	header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
	echo "No ECU Parameters in Definition File";
	exit;
}

// Send it on back
echo json_encode($ecuArray);

<?php
// Set Logger Def
$defFile = '../../misc/loggerdefs/' . $_POST['Definition'];
if(!file_exists($defFile)) {
	header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
	echo "Invalid File: {$_POST['Definition']}";
	exit;
}
$LoggerDef = simplexml_load_file($defFile);

// Find our ECU IDs
$ecuArray = array();
$tmpArray = $LoggerDef->xpath('//ecuparam/ecu/@id');
foreach($tmpArray as $value) {
	$ecuArray = array_unique(array_merge($ecuArray, explode(',', (string)$value)));
}

// Get sorted, unique IDs
$ecuArray = array_unique($ecuArray);
sort($ecuArray);

// 500 on empty array
if(empty($ecuArray)) {
	header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
	echo "No ECU Parameters in Definition File";
	exit;
}

// Send it on back
echo json_encode($ecuArray);

Fix ecu id retrieval ??

Fix ecu id retrieval ??


<?php

class CM_Stream_Cli extends CM_Cli_Runnable_Abstract {

    /**
     * @synchronized
     */
    public function startMessageSynchronization() {
        CM_Stream_Message::getInstance()->startSynchronization();
    }

    /**
     * @param string  $streamName
     * @param CM_File $thumbnailSource
     * @throws CM_Exception_Invalid
     */
    public function wowzaImportThumbnail($streamName, CM_File $thumbnailSource) {
        $streamChannel = CM_Model_StreamChannel_Video::findByKey($streamName);
        if (!$streamChannel) {
            throw new CM_Exception_Invalid('Cannot find streamChannel with key `' . $streamName . '`.');
        }
        $thumbnailCount = $streamChannel->getThumbnailCount();
        $thumbnailDest = $streamChannel->getThumbnail($thumbnailCount + 1);
        if (0 == $thumbnailCount) {
            $thumbnailDest->ensureParentDirectory();
        }
        $thumbnailSource->copyToFile($thumbnailDest);
        $streamChannel->setThumbnailCount($thumbnailCount + 1);
    }

    public static function getPackageName() {
        return 'stream';
    }
}

<?php

class CM_Stream_Cli extends CM_Cli_Runnable_Abstract {

    /**
     * @synchronized
     */
    public function startMessageSynchronization() {
        CM_Stream_Message::getInstance()->startSynchronization();
    }

    /**
     * @param int     $streamChannelId
     * @param CM_File $thumbnailSource
     * @throws CM_Exception_Invalid
     */
    public function importVideoThumbnail($streamChannelId, CM_File $thumbnailSource) {
        $streamChannel = CM_Model_StreamChannel_Video::factory($streamChannelId);
        $thumbnailCount = $streamChannel->getThumbnailCount();
        $thumbnailDest = $streamChannel->getThumbnail($thumbnailCount + 1);
        if (0 == $thumbnailCount) {
            $thumbnailDest->ensureParentDirectory();
        }
        $thumbnailSource->copyToFile($thumbnailDest);
        $streamChannel->setThumbnailCount($thumbnailCount + 1);
    }

    /**
     * @param int     $streamChannelId
     * @param CM_File $archiveSource
     * @throws CM_Exception_Invalid
     */
    public function importVideoArchive($streamChannelId, CM_File $archiveSource) {
        $streamChannelArchive = new CM_Model_StreamChannelArchive_Video($streamChannelId);
        $archiveDest = $streamChannelArchive->getVideo();
        $archiveDest->ensureParentDirectory();
        $archiveSource->copyToFile($archiveDest);
    }

    public static function getPackageName() {
        return 'stream';
    }
}

Add video streamchannel archive CLI import task


<?php echo $context->year; ?>

<?php echo $savvy->render($context->monthwidgets[0]); ?>

<?php echo $savvy->render($context->monthwidgets[1]); ?>

<?php echo $savvy->render($context->monthwidgets[2]); ?>

<?php echo $savvy->render($context->monthwidgets[3]); ?>

<?php echo $savvy->render($context->monthwidgets[4]); ?>

<?php echo $savvy->render($context->monthwidgets[5]); ?>

<?php echo $savvy->render($context->monthwidgets[6]); ?>

<?php echo $savvy->render($context->monthwidgets[7]); ?>

<?php echo $savvy->render($context->monthwidgets[8]); ?>

<?php echo $savvy->render($context->monthwidgets[9]); ?>

<?php echo $savvy->render($context->monthwidgets[10]); ?>

<?php echo $savvy->render($context->monthwidgets[11]); ?>

Remove table markup for year view

Remove table markup for year view


<?php

namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;

use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Execute a SQL query and output the results.
 */
class RunSqlDoctrineCommand extends RunSqlCommand
{
    /**
     * {@inheritDoc}
     */
    protected function configure()
    {
        parent::configure();

        $this
            ->setName('doctrine:query:sql')
            ->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'The connection to use for this command')
            ->setHelp(<<<EOT
The <info>%command.name%</info> command executes the given SQL query and
outputs the results:

<info>php %command.full_name% "SELECT * FROM users"</info>
EOT
        );
    }

    /**
     * {@inheritDoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection'));

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

<?php

namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;

use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Execute a SQL query and output the results.
 */
class RunSqlDoctrineCommand extends RunSqlCommand
{
    /**
     * {@inheritDoc}
     */
    protected function configure()
    {
        parent::configure();

        $this
            ->setName('doctrine:query:sql')
            ->setHelp(<<<EOT
The <info>%command.name%</info> command executes the given SQL query and
outputs the results:

<info>php %command.full_name% "SELECT * FROM users"</info>
EOT
        );

        if ($this->getDefinition()->hasOption('connection')) {
            return;
        }

        $this->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'The connection to use for this command');
    }

    /**
     * {@inheritDoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection'));

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

Add minimal compatibility with changes in DBAL 2.11 RunSqlCommand

Proper fix would be more involved, relying on interfaces in DBAL to not change, which we cannot assume won't happen at this point. Full, proper fix needs to be done once DBAL 2.11 API is stable. Such fix will probably involve deprecating our current command class as well, since DBAL one has everything our command added on top in past.


	{!! Form::label('name', 'Name:') !!}
	{!! Form::text('name') !!}

	{!! Form::label('slug', 'Slug:') !!}
	{!! Form::text('slug') !!}

	{!! Form::label('completed', 'Completed:') !!}
	{!! Form::text('completed') !!}

	{!! Form::label('description', 'Description:') !!}
	{!! Form::text('description') !!}

	{!! Form::submit($submit_text, ['class'=>'btn primary']) !!}

	{!! Form::label('name', 'Name:') !!}
	{!! Form::text('name') !!}

	{!! Form::label('slug', 'Slug:') !!}
	{!! Form::text('slug') !!}

	{!! Form::label('completed', 'Completed:') !!}
	{!! Form::checkbox('completed') !!}

	{!! Form::label('description', 'Description:') !!}
	{!! Form::textarea('description') !!}

	{!! Form::submit($submit_text, ['class'=>'btn primary']) !!}

Add checkbox for tasks form

Add checkbox for tasks form


<?php

namespace FluxBB\Server;

class Request
{
    protected $handler;

    protected $parameters = [];

    public function __construct($handler, array $parameters)
    {
        $this->handler = $handler;
        $this->parameters = $parameters;
    }

    public function getHandler()
    {
        return $this->handler;
    }

    public function get($name, $default = null)
    {
        return array_get($this->parameters, $name, $default);
    }
}

<?php

namespace FluxBB\Server;

class Request
{
    protected $handler;

    protected $parameters;

    public function __construct($handler, array $parameters = [])
    {
        $this->handler = $handler;
        $this->parameters = $parameters;
    }

    public function getHandler()
    {
        return $this->handler;
    }

    public function get($name, $default = null)
    {
        return array_get($this->parameters, $name, $default);
    }
}

Allow creation of requests without parameters.


<?php

namespace Friendica\Object\Search;

interface IResult
{

}

<?php

namespace Friendica\Object\Search;

/**
 * The default interface for each search result
 */
interface IResult
{

}

Add PhpDoc / Code Standards

Add PhpDoc / Code Standards


<?php
  $action = empty($post['id']) ? url_for('posts') : url_for('posts', $post['id']);
  $method = empty($post['id']) ? 'POST' : 'PUT';
?>
<form action="<?=$action?>" method="POST">
  <fieldset id="post_form">
    <legend>Post</legend>
    <?php if(!empty($post['id'])): ?>
    <input type="hidden" name="_method" value="PUT" id="_method">
    <?php endif; ?>

      Title
      <input type="text" name="post[title]" value="<?php echo h($post['title']);?>" id="post_title">

      Body
      <textarea name="post[body]" id="post_body"rows="8" cols="40"><?php echo h($post['body']);?></textarea>

      <input type="submit" value="<?php echo empty($post['id']) ? "Create" : "Update" ?> →">
      or <a href="<?php echo action?>">cancel

  </fieldset>
</form>

<?php
  $action = empty($post['id']) ? url_for('posts') : url_for('posts', $post['id']);
  $method = empty($post['id']) ? 'POST' : 'PUT';
?>
<form action="<?=$action?>" method="POST">
  <fieldset id="post_form">
    <legend>Post</legend>
    <?php if(!empty($post['id'])): ?>
    <input type="hidden" name="_method" value="PUT" id="_method">
    <?php endif; ?>

      Title
      <input type="text" name="post[title]" value="<?php echo h($post['title']);?>" id="post_title">

      Body
      <textarea name="post[body]" id="post_body"rows="8" cols="40"><?php echo h($post['body']);?></textarea>

      <input type="submit" value="<?php echo empty($post['id']) ? "Create" : "Update" ?> →">
      or <a href="<?php echo $action?>">cancel

  </fieldset>
</form>

Fix cancel action in post form

Fix cancel action in post form


<?php

namespace Hackzilla\Bundle\TicketBundle\TwigExtension;

use Symfony\Component\DependencyInjection\ContainerInterface;

class TicketGlobalExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
{

    /**
     * @var \Symfony\Component\DependencyInjection\ContainerInterface
     */
    protected $container;

    /**
     * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
     */
    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    /**
     * @return array
     */
    public function getGlobals()
    {
        return [
            'hackzilla_ticket' => [
                'templates' => [
                    'index'           => $this->container->getParameter('hackzilla_ticket.templates.index'),
                    'new'             => $this->container->getParameter('hackzilla_ticket.templates.new'),
                    'show'            => $this->container->getParameter('hackzilla_ticket.templates.show'),
                    'show_attachment' => $this->container->getParameter('hackzilla_ticket.templates.show_attachment'),
                    'prototype'       => $this->container->getParameter('hackzilla_ticket.templates.prototype'),
                    'macros'          => $this->container->getParameter('hackzilla_ticket.templates.macros'),
                ],
            ]
        ];
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'ticketGlobal';
    }

}

<?php

namespace Hackzilla\Bundle\TicketBundle\TwigExtension;

use Symfony\Component\DependencyInjection\ContainerInterface;

class TicketGlobalExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
{

    /**
     * @var \Symfony\Component\DependencyInjection\ContainerInterface
     */
    protected $container;

    /**
     * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
     */
    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    /**
     * @return array
     */
    public function getGlobals()
    {
        return [
            'hackzilla_ticket' => [
                'templates' => [
                    'index'           => $this->container->getParameter('hackzilla_ticket.templates.index'),
                    'new'             => $this->container->getParameter('hackzilla_ticket.templates.new'),
                    'show'            => $this->container->getParameter('hackzilla_ticket.templates.show'),
                    'show_attachment' => $this->container->getParameter('hackzilla_ticket.templates.show_attachment'),
                    'prototype'       => $this->container->getParameter('hackzilla_ticket.templates.prototype'),
                    'macros'          => $this->container->getParameter('hackzilla_ticket.templates.macros'),
                ],
            ],
        ];
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'ticketGlobal';
    }

}

Add comma after array item

Add comma after array item


<!DOCTYPE html>
<html class="no-js" <?php language_attributes(); ?>>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title><?php wp_title('|', true, 'right'); ?></title>
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <?php wp_head(); ?>

  <link rel="alternate" type="application/rss+xml" title="<?php echo get_bloginfo('name'); ?> Feed" href="<?php echo home_url(); ?>/feed/">
</head>

<!DOCTYPE html>
<html class="no-js" <?php language_attributes(); ?>>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title><?php wp_title('|', true, 'right'); ?></title>
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <?php wp_head(); ?>

  <link rel="alternate" type="application/rss+xml" title="<?php echo get_bloginfo('name'); ?> Feed" href="<?php echo esc_url(get_feed_link()); ?>">
</head>

Use get_feed_link for RSS URL

Use get_feed_link for RSS URL


<?php

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

namespace Symfony\Component\Translation;

/**
 * @author Nate Wiebe <nate@northern.co>
 */
function t(string $message, array $parameters = [], string $domain = null): TranslatableMessage
{
    return new TranslatableMessage($message, $parameters, $domain);
}

<?php

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

namespace Symfony\Component\Translation;

if (!\function_exists(t::class)) {
    /**
     * @author Nate Wiebe <nate@northern.co>
     */
    function t(string $message, array $parameters = [], string $domain = null): TranslatableMessage
    {
        return new TranslatableMessage($message, $parameters, $domain);
    }
}

[String] Check if function exists before declaring it


<?php

namespace OpenCFP\Provider;

use Silex\Application;
use Silex\ServiceProviderInterface;
use Spot\Config as SpotConfig;
use Spot\Locator as SpotLocator;

class SpotServiceProvider implements ServiceProviderInterface
{
    /**
     * {@inheritdoc}
     */
    public function register(Application $app)
    {
        $app['spot'] = $app->share(function ($app) {
            $config = new SpotConfig();

            $config->addConnection('mysql', [
                'dbname' => $app->config('database.database'),
                'user' => $app->config('database.user'),
                'password' => $app->config('database.password'),
                'host' => $app->config('database.host'),
                'driver' => 'pdo_mysql'
            ]);

            return new SpotLocator($config);
        });
    }

    /**
     * {@inheritdoc}
     */
    public function boot(Application $app)
    {
    }
}

<?php

namespace OpenCFP\Provider;

use Silex\Application;
use Silex\ServiceProviderInterface;
use Spot\Config as SpotConfig;
use Spot\Locator as SpotLocator;

class SpotServiceProvider implements ServiceProviderInterface
{
    /**
     * {@inheritdoc}
     */
    public function register(Application $app)
    {
        $app['spot'] = $app->share(function ($app) {
            $config = new SpotConfig();
            $dbConfig = [
                'dbname' => $app->config('database.database'),
                'user' => $app->config('database.user'),
                'password' => $app->config('database.password'),
                'host' => $app->config('database.host'),
                'driver' => 'pdo_mysql'
            ];

            if ($app->config('database.port') !== null) {
                $dbConfig['port'] = $app->config('database.port');
            }

            $config->addConnection('mysql', $dbConfig);

            return new SpotLocator($config);
        });
    }

    /**
     * {@inheritdoc}
     */
    public function boot(Application $app)
    {
    }
}

Allow port definition for spot2 config

Allow port definition for spot2 config


<?php

$server = proc_open(PHP_BINARY . " PocketMine-MP/PocketMine-MP.phar --no-wizard --disable-readline", [
	0 => ['pipe', 'r'],
	1 => ['pipe', 'w'],
	2 => ['pipe', 'w'],
], $pipes);

fwrite($pipes[0], "blocksniper\nmakeplugin BlockSniper\nstop\n\n");
while(!feof($pipes[1])) {
	echo fgets($pipes[1]);
}

fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);

echo "\n\nReturn value: " . proc_close($server) . "\n";
if(count(glob('PocketMine-MP/plugins/DevTools/BlockSniper*.phar')) === 0){
	echo "The BlockSniper Travis CI build failed.\n";
	exit(1);
}

echo "The BlockSniper Travis CI build succeeded.\n";
exit(0);

<?php

$server = proc_open(PHP_BINARY . " /home/travis/build/PocketMine-MP/PocketMine-MP.phar --no-wizard --disable-readline", [
	0 => ['pipe', 'r'],
	1 => ['pipe', 'w'],
	2 => ['pipe', 'w'],
], $pipes);

fwrite($pipes[0], "blocksniper\nmakeplugin BlockSniper\nstop\n\n");
while(!feof($pipes[1])) {
	echo fgets($pipes[1]);
}

fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);

echo "\n\nReturn value: " . proc_close($server) . "\n";
if(count(glob('PocketMine-MP/plugins/DevTools/BlockSniper*.phar')) === 0){
	echo "The BlockSniper Travis CI build failed.\n";
	exit(1);
}

echo "The BlockSniper Travis CI build succeeded.\n";
exit(0);

Use absolute path instead of relative.

Travis: Use absolute path instead of relative.


<?php
namespace Soflomo\Blog\Fixture;

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

use Faker;
use Soflomo\Blog\Entity\Article;

class ArticleData extends AbstractFixture
{
    protected $n = 10;

    public function load(ObjectManager $manager)
    {
        $blog  = $this->getReference('blog');
        $faker = Faker\Factory::create('nl_NL');

        for ($i=1; $i<=$this->n; $i++) {
            $article = new Article;

            $article->setTitle($faker->sentence(rand(3,6)));  // Words
            $article->setLead($faker->paragraph(rand(6,8)));  // Sentences
            $article->setBody($faker->paragraph(rand(6,10))); // Sentences

            if (!$faker->boolean(10)) {
                // For 9/10 cases post has publish date
                $article->setPublishDate($faker->dateTimeThisMonth);
            }
            $article->setBlog($blog);

            $manager->persist($article);
        }

        $manager->flush();
    }

    public function getDependencies()
    {
        return array(
            'Soflomo\Blog\Fixture\BlogData',
        );
    }
}

<?php
namespace Soflomo\Blog\Fixture;

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

use Faker;
use Soflomo\Blog\Entity\Article;

class ArticleData extends AbstractFixture implements DependentFixtureInterface
{
    protected $n = 10;

    public function load(ObjectManager $manager)
    {
        $blog  = $this->getReference('blog');
        $faker = Faker\Factory::create('nl_NL');

        for ($i=1; $i<=$this->n; $i++) {
            $article = new Article;

            $article->setTitle($faker->sentence(rand(3,6)));  // Words
            $article->setLead($faker->paragraph(rand(6,8)));  // Sentences
            $article->setBody($faker->paragraph(rand(6,10))); // Sentences

            if (!$faker->boolean(10)) {
                // For 9/10 cases post has publish date
                $article->setPublishDate($faker->dateTimeThisMonth);
            }
            $article->setBlog($blog);

            $manager->persist($article);
        }

        $manager->flush();
    }

    public function getDependencies()
    {
        return array(
            'Soflomo\Blog\Fixture\BlogData',
        );
    }
}

Add Dependent Fixture Interface to fix fixture loading


<?php namespace Orchestra\Memory;

use Illuminate\Support\ServiceProvider;
use Illuminate\Foundation\AliasLoader;

class MemoryServiceProvider extends ServiceProvider
{
    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app['orchestra.memory'] = $this->app->share(function ($app) {
            return new MemoryManager($app);
        });

        $this->app->booting(function () {
            $loader = AliasLoader::getInstance();
            $loader->alias('Orchestra\Memory', 'Orchestra\Support\Facades\Memory');
        });
    }

    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {
        $path = realpath(__DIR__.'/../../');

        $this->package('orchestra/memory', 'orchestra/memory', $path);

        $this->registerMemoryEvent();
    }

    /**
     * Register memory events during booting.
     *
     * @return void
     */
    protected function registerMemoryEvent()
    {
        $app = $this->app;

        $app->after(function () use ($app) {
            $app['orchestra.memory']->finish();
        });
    }
}

<?php namespace Orchestra\Memory;

use Illuminate\Support\ServiceProvider;
use Illuminate\Foundation\AliasLoader;

class MemoryServiceProvider extends ServiceProvider
{
    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bindShared('orchestra.memory', function ($app) {
            return new MemoryManager($app);
        });

        $this->app->booting(function () {
            $loader = AliasLoader::getInstance();
            $loader->alias('Orchestra\Memory', 'Orchestra\Support\Facades\Memory');
        });
    }

    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {
        $path = realpath(__DIR__.'/../../');

        $this->package('orchestra/memory', 'orchestra/memory', $path);

        $this->registerMemoryEvent();
    }

    /**
     * Register memory events during booting.
     *
     * @return void
     */
    protected function registerMemoryEvent()
    {
        $app = $this->app;

        $app->after(function () use ($app) {
            $app['orchestra.memory']->finish();
        });
    }
}

Update service provider to use bindShared.

Signed-off-by: Mior Muhammad Zaki <e1a543840a942eb68427510a8a483282a7bfeddf@gmail.com>


{{--
    Copyright (c) ppy Pty Ltd <contact@ppy.sh>.

    This file is part of osu!web. osu!web is distributed with the hope of
    attracting more community contributions to the core ecosystem of osu!.

    osu!web is free software: you can redistribute it and/or modify
    it under the terms of the Affero GNU General Public License version 3
    as published by the Free Software Foundation.

    osu!web is distributed 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 osu!web.  If not, see <http://www.gnu.org/licenses/>.
--}}
@extends('master')

@section('content')
    <div class="osu-layout__row osu-layout__row--page">
        @include(i18n_view('users._disabled_message'))
    </div>
@endsection

{{--
    Copyright (c) ppy Pty Ltd <contact@ppy.sh>.

    This file is part of osu!web. osu!web is distributed with the hope of
    attracting more community contributions to the core ecosystem of osu!.

    osu!web is free software: you can redistribute it and/or modify
    it under the terms of the Affero GNU General Public License version 3
    as published by the Free Software Foundation.

    osu!web is distributed 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 osu!web.  If not, see <http://www.gnu.org/licenses/>.
--}}
@extends('master')

@section('content')
    <div class="osu-page osu-page--generic">
        @include(i18n_view('users._disabled_message'))
    </div>
@endsection

Fix text color for account disabled page


<?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

class VerifyCsrfToken extends BaseVerifier
{

    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'api/*'
    ];
}

<?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

class VerifyCsrfToken extends BaseVerifier
{

    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'api/*',
        'auth/*'
    ];
}

Exclude auth from Csrf checks

Exclude auth from Csrf checks


@extends('panelViews::mainTemplate')
@section('page-wrapper')

@if (!empty($message))

{{ $message }}

@endif

{!!
 Form::model($admin, array( $admin->id))
!!}

{!! Form::label('first_name', \Lang::get('panel::fields.FirstName')) !!}
{!! Form::text('first_name', $admin->first_name, array('class' => 'form-control')) !!}

{!! Form::label('last_name', \Lang::get('panel::fields.LastName')) !!}
{!! Form::text('last_name', $admin->last_name, array('class' => 'form-control')) !!}

{!! Form::label('email', 'Email') !!}
{!! Form::email('email', $admin->email, array('class' => 'form-control')) !!}

{!! Form::submit(\Lang::get('panel::fields.updateProfile'), array('class' => 'btn btn-primary')) !!}

{!! Form::close() !!}

@stop

@extends('panelViews::mainTemplate')
@section('page-wrapper')

@if (!empty($message))

{{ $message }}

@endif

@if ($demo_status == true)

You are not allowed to edit the profile in demo version of panel.

@else

{!!
 Form::model($admin, array( $admin->id))
!!}

{!! Form::label('first_name', \Lang::get('panel::fields.FirstName')) !!}
{!! Form::text('first_name', $admin->first_name, array('class' => 'form-control')) !!}

{!! Form::label('last_name', \Lang::get('panel::fields.LastName')) !!}
{!! Form::text('last_name', $admin->last_name, array('class' => 'form-control')) !!}

{!! Form::label('email', 'Email') !!}
{!! Form::email('email', $admin->email, array('class' => 'form-control')) !!}

{!! Form::submit(\Lang::get('panel::fields.updateProfile'), array('class' => 'btn btn-primary')) !!}

{!! Form::close() !!}

@endif

@stop

Edit Profile feature is removed in demo status.


<?php

/**
 * The configuration options for the Maera Customizer
 */
function maera_customizer_config() {

	$args = array(

		// 'logo_image'    => get_template_directory_uri() . '/assets/images/customizer-logo.png',
		// 'color_active'  => '#2ECC71',
		// 'color_light'   => '#F1C40F',
		// 'color_select'  => '#3498DB',
		// 'color_accent'  => '#E74C3C',
		// 'color_back'    => '#444',
		'url_path'      => get_template_directory_uri() . '/lib/kirki/',
		'stylesheet_id' => 'maera',

	);

	return $args;

}
add_filter( 'kirki/config', 'maera_customizer_config' );

<?php

/**
 * The configuration options for the Maera Customizer
 */
function maera_customizer_config() {

	$args = array(

		// 'logo_image'    => get_template_directory_uri() . '/assets/images/customizer-logo.png',
		// 'color_active'  => '#2ECC71',
		// 'color_light'   => '#F1C40F',
		// 'color_select'  => '#3498DB',
		// 'color_accent'  => '#E74C3C',
		// 'color_back'    => '#444',
		// 'url_path'      => get_template_directory_uri() . '/lib/kirki/',
		'stylesheet_id' => 'maera',

	);

	return $args;

}
add_filter( 'kirki/config', 'maera_customizer_config' );

Use the plugin path already defined by Kirki


<?php

class DeviceDetector
{
    public static $isOldIOSDevice  = false;
    public static $isNewIOSDevice  = false;
    public static $isiPad4Device   = false;
    public static $isAndroidDevice = false;
    public static $category        = "";

    public static function detect()
    {
        $agent = $_SERVER['HTTP_USER_AGENT'];

        if (strpos($agent, 'iPad') !== false) {
            if (strpos($agent, 'OS 4') !== false) {
                self::$isiPad4Device = true;
            } else {
                self::$isOldIOSDevice = true;
            }
        } else if (strpos($agent, 'iPhone') !== false) {
            if (strpos($agent, 'iPhone OS 4') !== false) {
                self::$isNewIOSDevice = true;
            } else {
                self::$isOldIOSDevice = true;
            }
        } else if (strpos($agent, 'Android') !== false) {
            self::$isAndroidDevice = true;
        }

        if (self::$isNewIOSDevice) {
            self::$category = "browser-ios4";
        } else if (self::$isiPad4Device) {
            self::$category = "browser-ipad4";
        } else if (self::$isOldIOSDevice) {
            self::$category = "browser-old-ios";
        } else if (self::$isAndroidDevice) {
            self::$category = "browser-android";
        } else {
            self::$category = "browser-desktop";
        }
    }
}

?>

<?php

class DeviceDetector
{
    public static $isOldIOSDevice  = false;
    public static $isNewIOSDevice  = false;
    public static $isiPad4Device   = false;
    public static $isAndroidDevice = false;
    public static $category        = "";

    public static function detect()
    {
        $agent = $_SERVER['HTTP_USER_AGENT'];

        if (strpos($agent, 'iPad') !== false) {
            if (strpos($agent, 'OS 3') !== false) {
                self::$isOldIOSDevice = true;
            } else {
                self::$isiPad4Device = true;
            }
        } else if (strpos($agent, 'iPhone') !== false) {
            if (strpos($agent, 'iPhone OS 3') !== false) {
                self::$isOldIOSDevice = true;
            } else {
                self::$isNewIOSDevice = true;
            }
        } else if (strpos($agent, 'Android') !== false) {
            self::$isAndroidDevice = true;
        }

        if (self::$isNewIOSDevice) {
            self::$category = "browser-ios4";
        } else if (self::$isiPad4Device) {
            self::$category = "browser-ipad4";
        } else if (self::$isOldIOSDevice) {
            self::$category = "browser-old-ios";
        } else if (self::$isAndroidDevice) {
            self::$category = "browser-android";
        } else {
            self::$category = "browser-desktop";
        }
    }
}

?>

Make sure future iOS versions are handled correctly on the server component

We ignore the fact that there may be iOS 2.x devices out there trying to access the pages and thus be handled incorrectly


<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Response;

class DataController extends Controller
{
    public function resolvePath($dataPackName, $dir, $subDir, $filename) {
        $path = storage_path() . '/app/packs/' . $dataPackName . '/' . $dir . '/' . $subDir . '/' . $filename;

        $response = null;

        if(File::exists($path)) {

            $file = File::get($path);
            $type = File::mimeType($path);
            $response = Response::make($file, 200);
            $response->header("Content-Type", $type);
        }

        return $response;
    }
}

<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Response;

class DataController extends Controller
{
    public function resolvePath($filePath) {
        $path = storage_path() . '/app/' . $filePath;
        $response = null;

        if(File::exists($path)) {
            $file = File::get($path);
            $type = File::mimeType($path);
            $response = Response::make($file, 200);
            $response->header("Content-Type", $type);
        }

        return $response;
    }
}

Refactor function to serve public data from storage directory


<?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Application\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class GroupController extends AbstractActionController
{
    public function indexAction()
    {
        return new ViewModel();
    }

    public function createAction()
    {
        $form = $this->getServiceLocator()->get('Application\Form\Group');

        return new ViewModel(['groupForm' => $form]);
    }
}

<?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Application\Controller;

use Application\Entity\Group;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class GroupController extends AbstractActionController
{
    public function indexAction()
    {
        return new ViewModel();
    }

    public function createAction()
    {
        /** @var \Zend\Form\Form $groupEntity */
        $groupForm = $this->getServiceLocator()->get('Application\Form\Group');
        $groupEntity = new Group();
        $groupForm->bind($groupEntity);

        if ($this->getRequest()->isPost()) {
            $groupForm->setData($this->getRequest()->getPost());
            if ($groupForm->isValid()) {
                $entityManager = $this->getServiceLocator()
                    ->get('Doctrine\ORM\EntityManager');
                $entityManager->persist($groupEntity);
                $entityManager->flush();
                return $this->redirect()->toRoute('group');
            }
        }

        return new ViewModel(['groupForm' => $groupForm]);
    }
}

Handle form in group controller

Handle form in group controller


<?php namespace Pingpong\Modules\Process;

class Updater extends Runner {

    /**
     * Update the dependencies for the specified module by given the module name.
     *
     * @param  string $module
     * @return void
     */
    public function update($module)
    {
        $module = $this->module->get($module);

        $packages = $module->get('require', []);

        chdir(base_path());

        foreach ($packages as $name => $version)
        {
            $package = "\"{$name}:{$version}\"";

            $this->run("composer require {$package}");
        }
    }

}

<?php namespace Pingpong\Modules\Process;

class Updater extends Runner {

    /**
     * Update the dependencies for the specified module by given the module name.
     *
     * @param  string $module
     * @return void
     */
    public function update($module)
    {
        $module = $this->module->findOrFail($module);

        $packages = $module->get('require', []);

        chdir(base_path());

        foreach ($packages as $name => $version)
        {
            $package = "\"{$name}:{$version}\"";

            $this->run("composer require {$package}");
        }
    }

}

Replace call to get method with findOrFail method


<?php

namespace Tests\AppBundle\API\Listing;

use Symfony\Component\HttpFoundation\ParameterBag;
use Tests\AppBundle\API\WebserviceTestCase;

class TraitsTest extends WebserviceTestCase
{

    public function testExecute()
    {
        $default_db = $this->default_db;
        $service = $this->webservice->factory('listing', 'traits');
        $results = $service->execute(
            new ParameterBag(array('dbversion' => $default_db, 'search' => '')),
            null
        );
        $expected = array(
            array(
                "name" => "Plant Habit",
                "trait_type_id" => 1,
                "frequency" => 48842
            ),
            array(
                "name" => "IUCN Threat Status",
                "trait_type_id" => 3,
                "frequency" => 23194
            ),
            array(
                "name" => "Plant Life Cycle Habit",
                "trait_type_id" => 2,
                "frequency" => 16819
            )
        );
        $this->assertEquals($expected, $results, 'Search without term and limit, result should be a list of all traits');

        $results = $service->execute(
            new ParameterBag(array('dbversion' => $default_db, 'search' => 'SomethingThatWillNeverBeATraitType')),
            null
        );
        $expected = array();
        $this->assertEquals($expected, $results, 'Search term does not hit, result should be an empty array');
    }
}

<?php

namespace Tests\AppBundle\API\Listing;

use Symfony\Component\HttpFoundation\ParameterBag;
use Tests\AppBundle\API\WebserviceTestCase;

class TraitsTest extends WebserviceTestCase
{

    public function testExecute()
    {
        $default_db = $this->default_db;
        $service = $this->webservice->factory('listing', 'traits');
        $results = $service->execute(
            new ParameterBag(array('dbversion' => $default_db, 'search' => '')),
            null
        );
        $expected = array(
            array(
                "name" => "Plant Habit",
                "trait_type_id" => 1,
                "frequency" => 48842
            ),
            array(
                "name" => "IUCN Threat Status",
                "trait_type_id" => 3,
                "frequency" => 23185
            ),
            array(
                "name" => "Plant Life Cycle Habit",
                "trait_type_id" => 2,
                "frequency" => 16819
            )
        );
        $this->assertEquals($expected, $results, 'Search without term and limit, result should be a list of all traits');

        $results = $service->execute(
            new ParameterBag(array('dbversion' => $default_db, 'search' => 'SomethingThatWillNeverBeATraitType')),
            null
        );
        $expected = array();
        $this->assertEquals($expected, $results, 'Search term does not hit, result should be an empty array');
    }
}

Update test case for new version of IUCN


<?php

namespace Orbt\ResourceMirror\Resource;
use Orbt\ResourceMirror\Exception\ReplicatorException;

/**
 * Basic replicator implementation using file operations to replicate.
 */
class FileReplicator implements Replicator
{
    /**
     * Base URL.
     * @var string
     */
    protected $baseUrl;

    /**
     * Target directory.
     * @var string
     */
    protected $directory;

    /**
     * Constructs a file replicator.
     */
    public function __construct($baseUrl, $directory)
    {
        $this->baseUrl = rtrim($baseUrl, '/').'/';
        $this->directory = rtrim($directory, '\\/').'/';
    }

    /**
     * {@inheritdoc}
     */
    public function replicate($resource)
    {
        $url = $this->baseUrl.$resource->getPath();
        if (!$source = @fopen($url, 'rb')) {
            throw new ReplicatorException('Cannot open URL for reading.');
        }
        $file = $this->directory.$resource->getPath();
        @mkdir(dirname($file), 0777, true);
        if (!$target = @fopen($file, 'wb')) {
            fclose($source);
            throw new ReplicatorException('Cannot open local file for writing.');
        }
        stream_copy_to_stream($source, $target);
        fclose($source);
        fclose($target);
    }
}

<?php

namespace Orbt\ResourceMirror\Resource;
use Orbt\ResourceMirror\Exception\ReplicatorException;

/**
 * Basic replicator implementation using file operations to replicate.
 */
class FileReplicator implements Replicator
{
    /**
     * Base URL.
     * @var string
     */
    protected $baseUrl;

    /**
     * Target directory.
     * @var string
     */
    protected $directory;

    /**
     * Constructs a file replicator.
     */
    public function __construct($baseUrl, $directory)
    {
        $this->baseUrl = rtrim($baseUrl, '/').'/';
        $this->directory = rtrim($directory, '\\/').'/';
    }

    /**
     * {@inheritdoc}
     */
    public function replicate($resource)
    {
        $url = $this->baseUrl.$resource->getPath();
        if (!$source = @fopen($url, 'rb')) {
            throw new ReplicatorException(sprintf('Cannot open URL "%s" for reading.', $url));
        }
        $file = $this->directory.$resource->getPath();
        @mkdir(dirname($file), 0777, true);
        if (!$target = @fopen($file, 'wb')) {
            fclose($source);
            throw new ReplicatorException(sprintf('Cannot open local file "%s" for writing.', $file));
        }
        stream_copy_to_stream($source, $target);
        fclose($source);
        fclose($target);
    }
}

Include more information in file replicator exception.


<?php

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

class CreateInvitationUserTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_invitations', function (Blueprint $table) {
            $table->BigIncrements('id');
            $table->string('code')->index();
            $table->string('email');
            $table->BigInteger('user_id')->unsigned();
            $table->enum('status', ['pending', 'successful','canceled','expired']);
            $table->datetime('valid_till');
            $table->timestamps();
        });
    }

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

<?php

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

class CreateInvitationUserTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_invitations', function (Blueprint $table) {
            $table->BigIncrements('id');
            $table->string('code')->index();
            $table->string('email');
            $table->BigInteger('user_id')->unsigned();
            $table->enum('status', ['pending', 'successful','canceled','expired'])->default('pending');
            $table->datetime('valid_till');
            $table->timestamps();
        });
    }

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

Add default value to status enum

Add default value to status enum

Fix https://github.com/junaidnasir/larainvite/issues/6


<?php

namespace MetricsMonitor\Service\Storage;

use Doctrine\DBAL\Connection;

abstract class AbstractStorage
{
    /**
     * @var Connection
     */
    protected $connection;

    public function __construct(Connection $connection)
    {
        $this->connection = $connection;
    }
}

<?php

namespace MetricsMonitor\Service\Storage;

use Doctrine\DBAL\Connection;

/**
 * @package MetricsMonitor\Service\Storage
 */
abstract class AbstractStorage
{
    /**
     * @var Connection
     */
    protected $connection;

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

Add missing doc-blocks to keep consistent


<?php
use Roots\Sage\Setup;

/**
 * Timber
 */

class TwigSageTheme extends TimberSite {
    function __construct() {
        add_filter( 'timber_context', array( $this, 'add_to_context' ) );
        parent::__construct();
    }
    function add_to_context( $context ) {

        /* Add extra data */
        $context['foo'] = 'I am some other typical value set in your functions.php file, unrelated to the menu';

        /* Menu */
        $context['menu'] = new TimberMenu('primary_navigation');

        /* Site info */
        $context['site'] = $this;

        /* Site info */
        $context['display_sidebar'] = Setup\display_sidebar();

        $context['sidebar_primary'] = Timber::get_widgets('sidebar-primary');

        return $context;

    }
}
new TwigSageTheme();

/**
 * Timber
 *
 * Check if Timber is activated
 */

if ( ! class_exists( 'Timber' ) ) {

    add_action( 'admin_notices', function() {
        echo '

Timber not activated. Make sure you activate the plugin in ' . esc_url( admin_url( 'plugins.php' ) ) . '

';
    } );
    return;

}

<?php
use Roots\Sage\Setup;

/**
 * Check if Timber is activated
 */

if ( ! class_exists( 'Timber' ) ) {

    add_action( 'admin_notices', function() {
        echo '

Timber not activated. Make sure you activate the plugin in ' . esc_url( admin_url( 'plugins.php' ) ) . '

';
    } );
    return;

}

/**
 * Timber
 */

class TwigSageTheme extends TimberSite {
    function __construct() {
        add_filter( 'timber_context', array( $this, 'add_to_context' ) );
        parent::__construct();
    }
    function add_to_context( $context ) {

        /* Add extra data */
        $context['foo'] = 'I am some other typical value set in your functions.php file, unrelated to the menu';

        /* Menu */
        $context['menu'] = new TimberMenu('primary_navigation');

        /* Site info */
        $context['site'] = $this;

        /* Site info */
        $context['display_sidebar'] = Setup\display_sidebar();

        $context['sidebar_primary'] = Timber::get_widgets('sidebar-primary');

        return $context;

    }
}
new TwigSageTheme();

Move Timber class check to the top of the file

The check is supossed to happen before the attempt to use. Also this
way the error message displays as it should.