This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Controller\Component; | |
use Cake\Controller\Component\PaginatorComponent; | |
use Cake\Datasource\RepositoryInterface; | |
use Cake\Network\Exception\NotFoundException; | |
use Cake\ElasticSearch\Query; | |
class ElasticPaginatorComponent extends PaginatorComponent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div class="form-group"> | |
<?= $this->Form->create($assessmentForm) ?> | |
<fieldset> | |
<legend><?= __($assessmentForm->title) ?></legend> | |
<?php foreach ($questions as $k => $question): ?> | |
<?php echo $this->Form->hidden("$k.qid", ['value'=> $question->qid]) ?> | |
<?php echo $this->Form->input("$k.answer_text", ['label' => $question['text']]) ?> | |
<?php endforeach; ?> | |
</fieldset> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$date = new DateTime(); | |
$someClass->findTimeFrame($date); | |
$otherClass->doStuff($date); | |
function findTimeFrame($fromDate) { | |
$this->conditions('from_date', '>=', $date); | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Controller\Component; | |
use Cake\Controller\Component\PaginatorComponent; | |
use Cake\Datasource\RepositoryInterface; | |
use Cake\Network\Exception\NotFoundException; | |
use Cake\ElasticSearch\Query; | |
class ElasticPaginatorComponent extends PaginatorComponent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$this->Html->link($artist->name, ['action' => 'view', $artis->id, 'name' => $artist->name]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Table | |
public function validationDefault(Validator $validator) | |
{ | |
$validator | |
->requirePresence('device_id', 'create') | |
->notEmpty('device_id'); | |
return $validator; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
collection($items) | |
// I only care about elements having the id = a or id = b | |
->filter(function ($value, $key) use ($array) { | |
return isset($array[$value['id']]); // If the key is in the array, the it should be kept in the collection | |
}) | |
/// Let's now index the collection by the id | |
->groupBy('id') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$query = $this->Articles->find('all') | |
->leftJoinWith('ArticlesAuthors') | |
->leftJoinWith('Authors') | |
->where(['Authors.id' => 1]) | |
->orWhere(['ArticlesAuthors.author_id' => 1]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Database\Type; | |
use Cake\Database\Type\DateTimeType; | |
/** | |
* Datetime type converter. | |
* | |
* Use to convert datetime instances to strings & back. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Configures authentication and the basic fields to show on each screen | |
* | |
* @param Event $event The given event | |
* @return void | |
*/ | |
public function beforeFilter(Event $event) | |
{ | |
if ($this->request->public) { |