Skip to content

Instantly share code, notes, and snippets.

View cpierce's full-sized avatar

Chris Pierce cpierce

View GitHub Profile
Router::prefix('admin', function ($routes) {
$routes->connect('/:controller');
});
$hasManys = [
];
foreach ($hasManys as $hasMany) {
$this->hasMany($hasMany);
}
<?php
App::uses('AppModel', 'Model');
/**
* Sponsor.php Model
*
* @author Chris Pierce <cpierce@csdurant.com>
*/
class Sponsor extends AppModel {
<?php
/* Model/Sponsor.php */
class Sponsor extends AppModel {
public $name = 'Sponsor';
public $useTable = 'Sponsors';
public $displayField = 'Sponsor';
public $primaryKey = 'SponsorID';
public $hasMany = array(
'SponsorDivision' => array(
'className' => 'SponsorDivision',
class SponsorDivisionsController extends AppController {
public function index() {
$this->SponsorDivision->Behaviors->load('Containable');
$sponsordivisions = $this->SponsorDivision->find('all', array(
'contain' => array(
'Sponsor',
),
'order' => array(
'SponsorDivision.SponsorDivision' => 'asc'),
),
<?php
echo 'hello world';
public function storeAdvancedCSS($cssID)
{
global $site;
$file = new TextFile($site->userFiles, 'css'.$cssID.'.css');
if ($site->S3_ON) {
S3New::getInstance()->deleteFile($site->S3_SITE_FOLDER.'/css'.$cssID.'.css');
//TODO: This would be a prime place to invalidate our cache because we know that we are about to delete the file.
//However it shouldn't be needed because the code attempts, to re-create the same file that we just deleted. Placing here for the future.
if (constant('ENVIRONMENT') != 'production') {
<?php
namespace App\Model\Table;
use App\Model\Entity\Calendar;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
$data['feeds']['_ids'] = $this->request->data['feeds'];
$calendars = TableRegistry::get('Calendars');
$calendar = $calendars->newEntity($data, [
'associated' => [
'Feeds',
],
]);
debug($calendar);
$calendars->save($calendar);
$data['feeds']['_ids'] = $this->request->data['feeds'];
$calendars = TableRegistry::get('Calendars');
$calendar = $calendars->get($this->request->data['id'], [
'associated' => [
'Feeds',
],
]);
$calendar = $calendars->patchEntity($calendar, $data);
if ($calendars->save($calendar, ['associated' => ['Feeds']])) {
echo 'yes';