Skip to content

Instantly share code, notes, and snippets.

<?php
App::uses('AppModel', 'Model');
/**
* Article Model
*
* @property Comment $Comment
*/
class Article extends AppModel {
/**
<?php
namespace App\Controller;
use App\Controller\AppController;
use Cake\Event\Event;
use Cake\Mailer\MailerAwareTrait;
/**
* Bookmarks Controller
diff --git a/src/ORM/Association.php b/src/ORM/Association.php
index b863ed8..38ddc7a 100644
--- a/src/ORM/Association.php
+++ b/src/ORM/Association.php
@@ -839,8 +839,9 @@ abstract class Association
}
$newContain = [];
+ $aliasPrefix = isset($options['aliasPath']) ? $options['aliasPath'] . '.' : '';
foreach ($contain as $alias => $value) {
@markstory
markstory / Car.php
Created October 12, 2016 01:47
bake output for #9576
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* Car Entity
*
* @property string $id
* @property string $name
@markstory
markstory / routes.php
Created January 9, 2017 01:18
Routing test file
<?php
require './vendor/autoload.php';
use Cake\Core\Configure;
use Cake\Http\ServerRequest;
use Cake\Routing\Router;
// Setup
define('CONFIG', __DIR__ . '/tests/test_app/config/');
Configure::write('App', [
<?php
namespace App\Test\Fixture;
use Cake\TestSuite\Fixture\TestFixture;
/**
* TimeSheetsFixture
*
*/
class TimeSheetsFixture extends TestFixture
@markstory
markstory / TreeBehaviorNumberTest.php
Created January 17, 2017 03:13
cakephp issue 10005
<?php
// This test method was added to the bottom of lib/Cake/TestCase/Model/Behavior/TreeBehaviorNumberTest.php
public function testSaveRecursiveTree() {
extract($this->settings);
$this->Tree = new $modelClass();
$this->Tree->Behaviors->attach('Tree', array('level' => 'level'));
$this->completeTreeSave(array(
'app' => array(
'GroupPermissions' => array(
<?php
namespace App\Model\Behavior;
use Cake\ORM\Behavior;
class AlgoliaBehavior extends Behavior
{
protected $_defaultConfig = [
'index' => '',
// Other Algolia API key configuration
@markstory
markstory / Marshaller.php.diff
Created September 12, 2017 02:43
Should the Marshaller warn on 'extra' properties. We could log, but it will add a dependency to the ORM package.
diff --git a/src/ORM/Marshaller.php b/src/ORM/Marshaller.php
index e4a1894..f7c092b 100644
--- a/src/ORM/Marshaller.php
+++ b/src/ORM/Marshaller.php
@@ -16,6 +16,7 @@ namespace Cake\ORM;
use ArrayObject;
use Cake\Collection\Collection;
+use Cake\Core\Configure;
use Cake\Database\Expression\TupleComparison;
<?php
// In config/bootstrap.php
use Cake\I18n\I18n;
use Cake\I18n\ChainMessagesLoader;
use Cake\I18n\MessagesFileLoader;
// Turn off 'default' as a fallback
I18n::translators()->useFallback(false);
// Create a custom fallback.