Skip to content

Instantly share code, notes, and snippets.

View dereuromark's full-sized avatar
🕶️
Building cool web stuff

Mark Scherer dereuromark

🕶️
Building cool web stuff
View GitHub Profile
Overwrite completly:
public function setup(Model $Model, $config = array()) {
$this->settings[$Model->alias] = $config + $this->_defaultConfig;
}
Merge:
public function setup(Model $Model, $config = array()) {
array(
(int) 0 => array(
'ParentCategory' => array(
'id' => '1',
'name' => 'Lorem ipsum dolor sit amet',
'parent_id' => '1'
)
)
)
/**
* @param Event $event
* @param Query $query
* @return void
*/
public function beforeFind(Event $event, Query $query) {
$this->encodeBitmaskConditions($query);
$field = $this->_config['field'];
if (!($mappedField = $this->_config['mappedField'])) {
@dereuromark
dereuromark / gist:6080212
Created July 25, 2013 14:26
Try to get associated callbacks working for certain behaviors via AppModel hack
public function afterFind($results, $primary = false) {
if (!$primary && $this->attached('Translate')) {
$results = $Model->Behaviors->Translate->afterFind($this, $results, $primary);
}
...
}
@dereuromark
dereuromark / PaginatorComponent.php
Created August 17, 2017 12:35
App Paginator extension for out of bounds redirect instead of 404 exception
<?php
namespace App\Controller\Component;
use Cake\Controller\Component\PaginatorComponent as CorePaginatorComponent;
use Cake\Datasource\QueryInterface;
use Cake\Network\Exception\NotFoundException;
class PaginatorComponent extends CorePaginatorComponent
{
@dereuromark
dereuromark / JsonTypeUpgradeCommand.php
Created March 10, 2024 23:55
JsonTypeUpgradeCommand.php
<?php
declare(strict_types=1);
namespace App\Command;
use Cake\Command\Command;
use Cake\Console\Arguments;
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
@dereuromark
dereuromark / BlackholeMiddleware.php
Created March 11, 2024 17:01
BlackholeMiddleware.php
<?php
declare(strict_types=1);
namespace App\Http\Middleware;
use Cake\Core\Exception\CakeException;
use Cake\Core\InstanceConfigTrait;
use Cake\Http\Response;
use Cake\Log\Log;